Insert a text field inside existing template using REST API - docusignapi

I'm trying to insert a text field into an existing DocuSign template using REST API, and I was wondering how I can do this. I checked the TemplateDocuments:update where it sends a PUT request using API, but I'm assuming that this request changes all the text tabs in the template. Would it be possible if someone can help me insert a text field inside an existing template without changing the other already existing fields?

Yes, you can add a text field to an existing template at the time of calling Envelopes:create. Do this via composite templates.
The key is to include the documentId attribute for the right document in the template. You also need to specify the page number, x, and y information.
Determining the document ID
The template's first document usually has ID 1. To see the document's ID:
Open the template for editing
Click View for the document of interest
On the document's modal display: open the browser's menu and choose "Open image in new tab"
Inspect the new tab's URL. The number after /documents/ is the document ID. Eg URL .../documents/456/pages/... has document ID 456
Example
Here's an example which adds a text field and a list (dropdown) field.
The text field is locked (not-editable). It serves as a label for the new list field.
"envelopeDefinition": {
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"serverTemplates": [
{
"sequence": "1",
"templateId": "f4e5bdd4-xxxx-xxxxx-xxxx-5fd6b1ebe2fc"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "name#example.com",
"name": "Signer Name",
"roleName": "signer",
"recipientId": "1",
"tabs": {
"textTabs": [
{
"documentId": "1",
"locked": "true",
"value": "Added via the API. Office:",
"font": "Helvetica",
"fontSize": "Size12",
"pageNumber": "3",
"xPosition": "40",
"yPosition": "428"
}
],
"listTabs": [
{
"documentId": "1",
"font": "Helvetica",
"fontSize": "Size12",
"locked": "false",
"required": "false",
"pageNumber": "3",
"xPosition": "190",
"yPosition": "428",
"listItems": [
{
"text": "San Francisco",
"value": "SF"
},
{
"text": "London",
"value": "LON"
},
{
"text": "Paris",
"value": "PAR"
},
{
"text": "Jerusalem",
"value": "JLM"
},
{
"text": "São Paulo",
"value": "SP"
}
]
}
]
}
}
]
}
}
]
}
]
}

Related

Docusign API Explorer not pre-populating fields

I tried filling in the tabs with labels and values, but when I send the request the tabs are not pre-populated, also does anyone know how does the fullname tab get populated?
{
"emailSubject": "Welcome to Soul Gym",
"status": "sent",
"templateId": "196b0d27-b967-4380-bb2c-013051ec9e45",
"templateRoles": [
{
"clientUserId": "marcus.yeo#business.edu.sg",
"email": "marcus.yeo#business.edu.sg",
"name": "Marcus Yeo",
"roleName": "New Member",
"tabs": {
"emailTabs": [
{
"tabLabel": "Email",
"value": "marcus.yeo#business.edu.sg"
}
],
"fullNameTabs": [
{
"tabLabel": "FullName"
},
{
"tabLabel": "FullName2"
}
],
"textTabs": [
{
"tabLabel": "Address",
"value": "32 Duke Road"
}
]
}
}
]
It looks like you're missing the documentId and tabPositions to display the full name on your document. Here is an example working request body with raw document omitted:
{
"documents": [
{
"documentBase64": "<Base64BytesHere>",
"documentId": "1",
"fileExtension": "docx",
"name": "testFile"
}
],
"emailSubject": "testing envelope",
"recipients": {
"signers": [
{
"email": "john.doe#example.com",
"name": "Docusign Test Signer",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"fullNameTabs": [
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "280",
"yPosition": "172"
},
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "480",
"yPosition": "300"
}
],
"signHereTabs": [
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "120",
"yPosition": "300"
}
]
}
}
]
},
"status": "sent"
}
And the resulting fullName placement shown on a demo document I tried with this request json:
Though I didn't use an envelope templateId here, the mechanism works the same, set the documentID, pageNumber, & x/y coordinates to inject the fullName on your documents. Feel free to check out the Quickstart tool as well to find a full DocuSign implementation in a language of your choice that you can modify to suit your needs.

dateSignedTabs is not giving right date

i have created an envelope using rest api
endpoint :- {{baseUrl}}/envelopes
method :-post
body:
{
"emailSubject": "Please sign this document sent from Node SDK",
"documents": [
{
"documentId": "1",
"name": "<NAME>",
"documentBase64": "base64DOC"
}
],
"recipients": {
"signers": [
{
"email": "<EMAIL#EMAIL>COM",
"name": "<USERNAME>",
"clientUserId": 1,
"recipientId": 1,
"tabs": {
"dateSignedTabs": [
{
"tabLabel": "todaysDate",
"xPosition": "20",
"yPosition": "75",
"documentId": "1",
"pageNumber": "1"
},
{
"anchorString": "/sn1/",
"anchorYOffset": "10",
"anchorUnits": "pixels",
"anchorXOffset": "20",
"documentId": "1",
"pageNumber": "1"
}
]
}
}
]
},
"status": "sent"
}
envelope is created succesfully ,when i am opening the url of recipient view UI. A static value "10/3/2018" is filled in the dateSignedTabs. Why current date is not filled in the dateSignedTabs.
The date is populated the first time the recipient opens the envelope for signing.
Each tab (including date tab) is for a specific recipient.
When that specific recipient first clicks on the link (or if using embedded signing - opens the view) then the date is populated. It will not be updated again if you open it again and it's not updated for other recipients, only for the one for which this tab was set.
Hope this helps.

Docusign API - Create envelope, apply template, prefill values

Many questions address portions of my request, but I cannot seem to make a complete solution work. I have created a template on my site (it has various text fields, initial fields, and signature block). Single recipient, using anchor tags for the fields. When I take a .docx file, create an envelope via the api, I want to apply the template previously mentioned, and then prefill 4 text fields on the document/template.
Anchor tags are not placing the fields appropriately.
Any advise/suggestions?
Working request call is:
{
"documents":
[
{
"documentBase64":"<BASE64STREAM>",
"documentId":"3",
"fileExtension":"docx",
"name":"10001000_20170803_FILE"
}
],
"emailSubject": "TEST - Group Audit - 10001000",
"templateId": "TEMPLATE_ID",
"templateRoles" :
[
{
"email": "JDOE#email.com",
"name": "JOHN DOE",
"roleName": "signer1",
"tabs":
{
"textTabs":
[
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupname",
"value": "TEST GROUP ONE"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupnumber",
"value": "10001000"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "txt",
"value": "my#email.com"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "fein",
"value": "870142380"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "physicaladdress",
"value": "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
],
"status":"sent"
}
Based on the information you've provided, I understand your scenario to be as follows:
You've created a template via the DocuSign UI; that template contains a 'placeholder' document (which you will replace at run-time via your Create/Send Envlope API call) and defines the recipient(s) and tabs for that document.
When you create/send the envelope via API, you want to specify the document as part of the API request (i.e., to be used instead of the 'placeholder' document that the DocuSign template contains) and also auto-populate some of the tabs that the template defines.
If that's an accurate description of what you're trying to achieve, then you need to use Composite Templates in the API request structure. Here's an example of a Create/Send Envelope JSON request that uses composite templates (and contains data based upon the information you provided in your question):
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "TEMPLATE_ID"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "JOHN DOE",
"email": "JDOE#email.com",
"roleName": "signer1",
"tabs":
{
"textTabs":[
{
"tabLabel" : "groupname",
"value" : "TEST GROUP ONE"
},
{
"tabLabel" : "groupnumber",
"value" : "10001000"
},
{
"tabLabel" : "txt",
"value" : "my#email.com"
},
{
"tabLabel" : "fein",
"value" : "870142380"
},
{
"tabLabel" : "physicaladdress",
"value" : "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
]
}
}
],
"document": {
"documentId": "3",
"name": "10001000_20170803_FILE.docx",
"fileExtension": "docx",
"documentBase64": "BASE64STREAM"
}
}
],
"status": "sent",
"emailSubject": "TEST - Group Audit - 10001000"
}

How can we add a attachment tab while creating an envelope via template using REST API?

Is there any REST API call to add a attachment tab while sending envelopes? For this I am referring to this link, but I don't know how to use this. Can you please tel me the full API call?
It's just like any other DocuSign tab, you just need to reference the name properly and set its parameters. Here's an example that would send one signature tab and one signer attachment tab:
POST v2/accounts/{accountId}/envelopes
{
"emailSubject": "Please sign this document",
"documents": [
{
"name": "test.pdf",
"documentId": "1"
}
],
"recipients": {
"signers": [
{
"tabs": {
"signHereTabs": [
{
"pageNumber": "1",
"documentId": "1",
"yPosition": "100",
"xPosition": "100",
"tabLabel": "Signature Tab",
}
],
"signerAttachmentTabs": [
{
"pageNumber": "1",
"documentId": "1",
"yPosition": "100",
"xPosition": "200",
"required": "true",
"tabLabel": "Signer Attachment Tab",
}
]
},
"routingOrder": "1",
"recipientId": "1",
"name": "Jon Dough",
"email": "jon.dough#email.com"
}
]
},
"status": "sent"
}

Sending Signing Request Envelope with template and PDF Document

In my application I have a requirement where I need to send envelope for multiple documents. I have partially achieved this by using Composite templates. But having issues in scenario described below.
"Envelope to contain multiple templates (using Composite templates) and also PDF document with meta data(along with pdf bytes)."
I am able to achieve sending envelope with my document pdf bytes and meta data, but could not combine this along with templates in same envelope.
Can you suggest a way forward?
UPDATE: I have progressed to generate the envelope for above scenario but having problem-Now problem is that, I am using anchor text to put "sign here" tab in this pdf document and unfortunately anchor text is also present in other templates too. This is resulting in two sign here tabs on templates(These are proper templates and are not empty) with anchor text.
Adding JSON string for more visibility. Please note that I am sending PDF bytes along with this json string which is acting as backing document for empty template.
{
"status": "sent",
"templateId": "Empty Template ID(This template does not contain anything and just a blank pdf page in background)****************",
"templateRoles": [{
"name": "****************",
"accessCode": "1234",
"roleName": "employee",
"email": "****************",
"recipientId": "1",
"tabs": {
"textTabs": [{
"name": "Hyperlink Here",
"documentId": "1",
"anchorString": "Employee Signature:",
"anchorXOffset": "185",
"anchorYOffset": "-39",
"anchorUnits": "pixels",
"font": "arial",
"fontSize": "size7",
"fontColor": "brightblue",
"value": ": Click Here",
"tabLabel": "#HREF termsAndConditionLink"
}],
"dateSignedTabs": [{
"name": "DateSigned",
"tabLabel": "DateSigned",
"documentId": "1",
"additionalProperties": {
},
"anchorString": "Employee Signature:",
"anchorXOffset": "430",
"anchorYOffset": "1",
"anchorUnits": "pixels"
}],
"signHereTabs": [{
"documentId": "1",
"anchorString": "Employee Signature:",
"anchorXOffset": "180",
"anchorYOffset": "10",
"anchorUnits": "pixels",
"scaleValue": 0.0,
"anchorIgnoreIfNotPresent": "true"
}]
}
}],
"brandId": "Brand****************",
"documents": [{
"name": "Doc2.pdf",
"documentId": "1"
}],
"compositeTemplates": [{
"serverTemplates": [{
"sequence": "1",
"templateId": "Proper Template ID****************"
}],
"inlineTemplates": [{
"sequence": "1",
"recipients": {
"signers": [{
"name": "****************",
"accessCode": "1234",
"roleName": "employee",
"email": "****************",
"recipientId": "1",
"tabs": {
"textTabs": [{
"value": "VALUE1",
"tabLabel": "TEXTTAB1"
},
{
"value": "VALUE2",
"tabLabel": "TEXTTAB2"
}]
}
}]
}
}]
}],
"emailBlurb": "Please sign document using link below",
"emailSubject": "Please complete the documents."
}

Resources