How to populate package fields with the Rest API

0 votes

When creating a new package from a template I am trying to populate one of the existing text fields only if I have specific information. How can I achieve this using the rest api?

Reply to: How to populate package fields with the Rest API

0 votes

The template only has one signer and this field must be filled out by that signer if it is not populated.

Reply to:

0 votes

Hi Namkai,


Thanks for the post! As per your description, I would suggest you to leave the field as a textfield by default, and only update it as a label field and its value when your application knows the data.
For cases if the field value is NOT populated, you'd directly invoke the clone call in order to create and send the transaction:


  "roles": [


      "id": "06fffb84-e400-46dc-bb49-4ecab0f6218c",

      "signers": [


          "email": "[email protected]",

          "firstName": "John",

          "lastName": "Smith"





  "documents": [


      "id": "2e3a2136c5ec55b35c70bf8b93d81b898f37678cd4885d46"



      "id": "c6cd356a46c16290cd125b1b6c43930fd49a6b1f107676d8"



  "name": "New Transaction Name",

  "language": "fr",

  "emailMessage": "New email message",

  "description": "New Transaction Desc",

  "autocomplete": true,

  "status": "SENT",

  "timezoneId": "EST"



(1)For roles, role ID (not role Name, e.g. Signer1 or Placeholder1 as UI label indicates) is required to match with the template.

(2)You need to provide at least the email, firstName and lastName of the signer

(3)For documents, you can include partial document IDs (like role, document ID is required to find a match)

(4)set the transaction status as "SENT"

(5)You can still customize some of the package level attributes (e.g. transaction name, description, time zone, language, etc.) like I included in the payload


For cases if your application knows the field value, you could below steps.

Step1: invoke the clone call and leave the package in "DRAFT" status


Step2: invoke a GET call to get the text field properties:
GET /api/packages/{newly_created_package_id}/documents/{documentId}/approvals/{signatureId}/fields/{fieldId}

Only the package ID is dynamic, you can get the other three IDs from the template JSON (GET /api/packages/{template_id})


Step3: copy paste the response from above call, modify two fields

-"subtype" from "TEXTFIELD" to "LABEL"

-"value" from null (if you didn't specify the default value) to the populated string

and invoke a PUT call with the payload in order to update the field

PUT /api/packages/{newly_created_package_id}/documents/{documentId}/approvals/{signatureId}/fields/{fieldId}

Note this is a PUT call other than PATCH call, therefore you need to carry all the properties (that's why you'd use a GET call first)


Step4: send the transaction 

PUT /api/packages/{packageId} with payload {"status":"SENT"}


Hope you find these helpful!



Duo Liang OneSpan Evangelism and Partner Integrations Developer

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off