Skip to navigation

How to set envelope tab values

View as Markdown

This topic demonstrates how to set envelope tab values using embedded signing and sends an envelope with an editable numerical tab and editable text tabs.

Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.

Required data

Running the code in this how-to requires this data:

Data elementDescription
{API_ACCOUNT_ID}A GUID value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the API Account ID field on the Apps and Keys page.
{BASE_PATH}A string value that forms the root of the URL required to make API calls. The base path value in the example code is set to target the developer environment at
https://<domain>/restapi
Where <domain> is demo.docusign.net for the developer environment and is the result of the GetUserInfo call in production.
{CLIENT_USER_ID}A string value that serves as an identifier of an individual signer throughout the signing process. The combination of this value, the signer’s name, and the signer’s email is used to uniquely identify them.
Document to be signedYou must provide at least one document to be signed. Document used in this how-to:
{RECIPIENT_ID}A unique string value that you assign to identify each recipient. This value assigns tabs on a per-recipient basis.
{REDIRECT_URI}A URL to which the user will be forwarded after authentication. The value for this URL must exactly match one of those pre-registered for the integration key in your Docusign account. See redirect URI for details.
{SIGNER_EMAIL}A string value for the email address where the signer will receive a notification of the signing request.
{SIGNER_NAME}A string value for the full name of the signer.

Step 1. Obtain your OAuth token

To make the API calls shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.

See Confidential Authorization Code Grant for guidance on your options to get an Confidential Authorization Code Grant OAuth token.

Three icons that represent the three methods a user can use to obtain an OAuth token: JSON Web Token (JWT), Public Authorization Code Grant (ACG), and Confidential Authorization Code grant

Step 2. Construct your API headers

After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for {ACCESS_TOKEN}.

declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
'--header' "Accept: application/json"
'--header' "Content-Type: application/json")

Step 3. Construct the request body

If you’re using a Docusign SDK, you can prepare a compatible request body by creating an envelope definition using the included makeEnvelope method.

  • Set a signHere tab to collect signature information.
  • Create two text tabs to collect a full name and a familiar name of the signer to prefill the document.
  • Create a numerical tab for salary.
  • Set the associated anchor strings so they match their placement within the document and include a tab ID so they are easy to retrieve.
printf \
'{
"customFields": {
"textCustomFields": [{
"name": "salary",
"required": "false",
"show": "true",
"value": "123000"
}]
},
"documents": [
{
"documentBase64": "' > $request_data
cat $doc1_base64 >> $request_data
printf '",
"documentId": "1",
"fileExtension": "docx",
"name": "Lorem Ipsum"
}
],
"emailBlurb": "Sample text for email body",
"emailSubject": "Please Sign",
"envelopeIdStamping": "true",
"recipients": {
"signers": [{
"clientUserId": "1000",
"email": "'"${SIGNER_EMAIL}"'",
"name": "'"${SIGNER_NAME}"'",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "/sn1/",
"anchorUnits": "pixels",
"anchorXOffset": "20",
"anchorYOffset": "10"
}],
"textTabs": [{
"anchorString": "/legal/",
"anchorUnits": "pixels",
"anchorXOffset": "5",
"anchorYOffset": "-9",
"bold": "true",
"font": "helvetica",
"fontSize": "size11",
"locked": "false",
"tabId": "legal_name",
"tabLabel": "Legal name",
"value": "'"${SIGNER_NAME}"'"
}, {
"anchorString": "/familiar/",
"anchorUnits": "pixels",
"anchorXOffset": "5",
"anchorYOffset": "-9",
"bold": "true",
"font": "helvetica",
"fontSize": "size11",
"locked": "false",
"tabId": "familiar_name",
"tabLabel": "Familiar name",
"value": "'"${SIGNER_NAME}"'"
}],
"numericalTabs" : [
{
"pageNumber" : "1",
"documentID" : "1",
"xPosition" : "210",
"yPosition" : "235",
"height" : "20",
"width" : "70",
"minNumericalValue" : "0",
"maxNumericalValue" : "1000000",
"validationType" : "Currency",
"bold": "true",
"font": "helvetica",
"fontSize": "size11",
"tabId": "salary",
"tabLabel": "Salary",
"numericalValue": "123000",
"localePolicy" : {
"cultureName" : "en-US",
"currencyCode": "usd",
"currencyPositiveFormat" : "csym_1_comma_234_comma_567_period_89",
"currencyNegativeFormat" : "minus_csym_1_comma_234_comma_567_period_89",
"useLongCurrencyFormat" : "true"
}
}]
}
}]
},
"status": "Sent"
}' >> $request_data

Step 4. Call the eSignature REST API

Now that you have constructed your API headers, make a request to Envelopes:create to send an envelope. Here’s how you make the call, but make sure to substitute your valid API account ID for {account_id}.

Status=$(curl --request POST ${base_path}/v2.1/accounts/${account_id}/envelopes \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response})

Step 5. Create the recipient view definition

The recipient view is the screen that Docusign generates and displays in your app to enable your signers to sign documents. The recipient view request returns a link that enables your recipients to sign documents from your app. To create the definition, you must add the signer’s information and the redirect URI.

  1. Set the redirect URI to which the user will be forwarded after signing is complete. This URI must exactly match one that is preregistered for the integration key in your Docusign account.

    Note: You can include a state parameter in the URI string to record your application’s state and provide recovery information, potentially enabling it to resume interrupted operations using only callback data.

  2. Add the recipient information to the view, including the signer’s email, name, and client user ID.

View the source code for this how-to on GitHub: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.

curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary '
{
"returnUrl": "http://httpbin.org/get",
"authenticationMethod": "none",
"email": "'"${SIGNER_EMAIL}"'",
"userName": "'"${SIGNER_NAME}"'",
"clientUserId": 1000,
}' \
--request POST ${base_path}/v2.1/accounts/${account_id}/envelopes/${envelope_id}/views/recipient \
--output ${response}

Expected response

Use the return URL in the JSON response to start the embedded signing session in your browser.

Sample response
{
"url": "https://demo.docusign.net/Signing/MTRedeem/v1/54984548-xxxx-xxxx-xxxx-cd0772818bbf?slt=eyJ0eX...m87j8w"
}

Next steps