Search code examples
docusignapi

JSON request for envelope with single document, two signers, pre-fill fields


I have an envelope with a single document and two signers saved as a server-side template. The signers execute the agreement in a specific order. The document has a number of pre-fill fields in it.

I am trying to automate sending this agreement out using Integromat. Unfortunately, Integromat's module doesn't allow for pre-fill fields in templates, leaving me to create the API request manually. This is where I get stuck.

The closest I have come is the JSON request below, POSTed to: …/v2.1/accounts/{accountId}/envelopes, with capitalised values filled in automatically:

{
  "templateId": "TEMPLATE_ID",
  "templateRoles": [
    {
      "email": "CLIENT_EMAIL",
      "name": "CLIENT_NAME",
      "roleName": "Recipient",
      "tabs": {
        "prefillTabs": {
          "textTabs": [{
            "tabLabel": "Prefill: Purpose",
            "value": "PURPOSE_FIELD_DATA"
          }]
        }
      }
    }, {
      "email": "STAFF_EMAIL",
      "name": "STAFF_NAME",
      "roleName": "Company"
    }
  ],
  "status": "sent"
}

The response from the API is:

The operation failed with an error. [400] A Required field is incomplete. TabId: GUI_HERE

What I can't figure out is how to get the pre-fill data submitted since it's not tied to a particular signer. I have scoured the v2.1 API documentation but there is no scenario simple enough for this request.

Apologies if I am missing something obvious here; this is my first rodeo with DocuSign's API.

Do you have any idea what I am doing wrong or, better yet, what the body of the request should be for this (presumably) simple scenario?


Solution

  • Update: For pre-fill tabs, you need to have both the tabId and tabLabel, not enough to just have tabLabel like regular tabs.

    My guess is a mismatch of the tabId field for the tabs on your template vs. what's in the API request: You had this value in your request:

    Prefill: Purpose
    

    Does it match how the template was set?