Error Sending Composite Template to Docusign API - docusignapi

I am trying to use the docusign-node-client to send an envelope using the createEnvelope class. This class sends a REST API request to the /envelopes endpoint. The envelope I am trying to send contains a Composite Template.
Here is the body I am attempting to send to docusign
{
"emailSubject": "Sent from Node SDK",
"emailBlurb": "Email body here",
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentBase64": "base64StringHere",
"documentId": "1",
"fileExtension": ".pdf",
"name": "filename.pdf"
}
],
"envelope": {
"emailBlurb": "Email body here",
"emailSubject": "Sent from Node SDK",
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"recipients": {
"signers": [
{
"email": "myEmail#domain.com",
"name": "My Name",
"recipientId": "1"
}
]
}
}
}
],
"serverTemplates": [
{
"sequence": "1"
}
]
}
],
"status": "sent"
}
When I send this body I get the following error: "The request contained at least one invalid parameter. Invalid value specified for \'templateId\' in composite template sequence: 1"
If I remove the serverTemplates array, I get this error: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line."
If I include a valid templateId in the serverTemplate object it creates an envelope successfully.
The as is application I am converting to Node JS used the Docusign SOAP API and is able to send composite templates with 1 to many documents. Each of these documents can be associated to their own document template or no docusign template.
Does docusign not accept composite templates without some sort of reference to a template id?

You are specifying the inlineTemplate.envelope property incorrectly. You can define the recipients and custom fields directly within the inlineTemplate. You do not have to specify the emailSubject/emailBlurb within the inlineTemplate.
Also note that the custom fields specified at the root level will be ignored when using composite templates. See this answer
The following json should work for you.
{
"emailSubject": "Sent from Node SDK",
"emailBlurb": "Email body here",
"status": "sent"
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentBase64": "base64StringHere",
"documentId": "1",
"fileExtension": ".pdf",
"name": "filename.pdf"
}
],
"customFields": {
"textCustomFields": [
{
"name": "DSFSSourceObjectId",
"required": false,
"show": false,
"value": "dealIdHere"
}
]
},
"recipients": {
"signers": [
{
"email": "myEmail#domain.com",
"name": "My Name",
"recipientId": "1"
}
]
}
}
]
}
]
}

Related

Attach document to existing template docusign Rest API

I am able to send a POST request to send an existing template for signing. What I'm trying to do now is attach a PDF to the signature template. The attached PDF does not need to be signed / is not a template. It is just a PDF copy of a document as an appendix to the contract.
The request is going through ok, but I'm getting the error: "TAB_PAGENUMBER_IS_NOT_IN_DOCUMENT",\r\n "message": "The pagenumber specified in the tab element is not in the document that the tab refers to. Tab on Page 8 of Document 1 for Recipient 1"
JSON:
{
"emailSubject": "Please sign this document set",
"templateId": "xxxxxxx",
"templateRoles": [
{
"email": "email#example.com",
"roleName": "Buyer",
"name": "Buyer Name"
}
],
"documents": [
{
"signerMustAcknowledge": "no_interaction",
"order": "asc",
"name": "MyCompany Quote",
"includeInDownload": true,
"documentId": "2",
"documentBase64": "<base64string>",
"display": "inline"
},
],
"status": "sent"
}
How to attach a document to an online template?
The error you are seeing is because DocuSign will try to replace the document in the template with the file you are providing.
You should be able to add this additional document by using composite templates instead. https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-composite-template-embedded/
Here is a sample:
{
"compositeTemplates": [
{
"compositeTemplateId": "1",
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"email": "email#example.com",
"roleName": "Buyer",
"name": "Buyer Name"
}
]
},
"sequence": "1"
}
],
"serverTemplates": [
{
"sequence": "1",
"templateId": "xxxxxxx"
}
]
},
{
"compositeTemplateId": "2",
"document": {
"documentBase64": "<base64string>",
"documentId": "2",
"fileExtension": "pdf",
"name": "MyCompany Quote"
},
"inlineTemplates": [
{
"sequence": "1"
}
]
}
],
"emailSubject": "Please sign this document set",
"status": "sent"
}
The first composite template is used to populate your existing template with the signers information. The second composite template is where you add the additional document you want your users to sign. You can also include additional tabs inside the inlineTemplates if they are needed in the future

DocuSign Envelope creation failed containing PDF fields transformation

This is my JSON code so far:
{
"status": "sent",
"emailSubject": "This is an api Demo Doc, sent for signature",
"recipients": {
"carbonCopies": [
{
"email": "nila#gmail.com",
"name": "Nilashree",
"recipientId": "2"
}
],
"signers": [
{
"email": "{{signer1Email}}",
"name": "Nilashree Nandkumar shirodkar",
"recipientId": "1"
}
]
},
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "nshiro2#students.towson.edu",
"name": "Nila Joseph",
"recipientId": "1",
"defaultRecipient": "true"
}
]
}
}
],
"documents": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
}
]
}
But I am getting the following error:
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line."
Can anyone please let me know what am I doing wrong?
Why are you using a composite template? Perhaps you are planning towards a later, more complicated envelope definition.
Your mistake is that each composite template can optionally contain only one document. The field name is document, not documents.
Instead of
"documents": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
use
"document": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
Also, I don't believe there's a need for the recipients outside of the composite templates structure. I'm not 100% sure about this issue though.

DocuSign TAB_REFERS_TO_MISSING_DOCUMENT but document is attached (REST API)

I'm using the DocuSign REST API to create an envelope from a template. My code works with single document templates or templates with multiple documents where only one document has tabs. If there are tabs on both documents I receive a 400 response with error code TAB_REFERS_TO_MISSING_DOCUMENT.
The response I receive is:
{
"error": "invalid HTTP response",
"message": {
"errorCode": "TAB_REFERS_TO_MISSING_DOCUMENT",
"message": "The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 45159457 which is not present."
},
"status": 400,
"url": "https://demo.docusign.net/restapi/v2/accounts/2826983/envelopes/"
}
My request is as follows:
{
"status": "sent",
"templateId": "bb283bfb-4049-431d-942a-9a485e4ebb41",
"emailSubject": "[[Signer UserName]], please sign this document",
"documents": [
{
"documentId": "27069418",
"documentBase64": "...",
"name": "name.pdf"
},
{
"documentId": "45159457",
"documentBase64": "...",
"name": "secondName.pdf"
}
]
}
From what I've seen people receive this request when they submit invalid documentId's like 1 but the document that's "missing" is clearly attached. Am I missing something?
The final and working JSON request looks like so:
{
"status": "sent",
"emailSubject": "...",
"compositeTemplates": [{
"serverTemplates": [{
"sequence": 2,
"templateId": "..."
}],
"inlineTemplates": [{
"sequence": 1,
"documents": [{
"documentId": "...",
"name": "...",
"documentBase64": "..."
}, {
"documentId": "...",
"name": "...",
"documentBase64": "..."
}]
}]
}]
}
You can overcome the error using composite Templates. Specifying the new documents in an inlineTemplate with lower sequence number("sequence": "1") will ensure the inlineTemplate documents will replace the server template documents.
Here is a sample CreateEnvelope request.
{
"emailSubject": "[[Signer UserName]], please sign this document",
"status": "sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentId": "27069418",
"name": "name.pdf",
"documentBase64": ""
},
{
"documentId": "45159457",
"name": "secondName.pdf",
"documentBase64": ""
}
]
}
],
"serverTemplates": [
{
"sequence": "2",
"templateId": "bb283bfb-4049-431d-942a-9a485e4ebb41"
}
]
}
]
}
To replace the document(s) in a template you must use composite templates instructions in your Envelopes: create call.
In your use case, you want to composite together the template and then a new document "in front" of the existing document in the template.
"Compositing templates" is like compositing together multiple pieces of film to produce a final print.

Error with Composite Templates retrieving Recipients View

We are trying to create a composite template using 2+ templates using the REST API. We create a draft envelope first from the templates, then send the envelope.
We call the REST URI:
https://demo.docusign.net/restapi/v2/accounts/e3a6986d-edb6-465d-8b7a-782867f37dd8/envelopes
with the JSON
Body:
{
"status": "created",
"emailBlurb": null,
"emailSubject": null,
"eventNotification": {},
"compositeTemplates": [
{
"serverTemplates": [
{
"templateId": "4da7730b-fc1a-4ea1-bcd9-bc7e55e13271",
"sequence": 1
}
],
"inlineTemplates": [
{
"sequence": 1,
"recipients": {
"signers": [
{
"roleName": "RoleOne",
"recipientId": "49c9c05b-b0c2-4c68-8260-28b574119e7f",
"name": "Tester N",
"email": "YYYYY#gmail.com"
}
]
}
}
]
},
{
"serverTemplates": [
{
"templateId": "3ae253af-4884-4185-9354-b80f37511ce4",
"sequence": 2
}
],
"inlineTemplates": [
{
"sequence": 2,
"recipients": {
"signers": [
{
"roleName": "RoleOne",
"recipientId": "ee3cb7f5-8c38-4790-af81-2c49726e27c3",
"name": "Tester N",
"email": "YYYYYY#gmail.com"
}
]
}
}
]
}
]
}
This creates the draft envelope, and we can access it and retrieve the tabs. We get the signers information for each template separately with a call to Get Recipients Status
/accounts/e3a6986d-edb6-465d-8b7a-782867f37dd8/envelopes/#{template_id}/recipients
then we "send" the draft envelope using
PUT https://demo.docusign.net/restapi/v2/accounts/e3a6986d-edb6-465d-8b7a-782867f37dd8/envelopes/476ad2d1-2134-402d-9404-ed04df15508f
{"status":"sent"}
and the response is
status: 200 {}
Finally when we try to get the recipients view to show it to the signer using
/accounts/e3a6986d-edb6-465d-8b7a-782867f37dd8/envelopes/476ad2d1-2134-402d-9404-ed04df15508f/views/recipient
We get the error response:
{"errorCode"=>"UNKNOWN_ENVELOPE_RECIPIENT",
"message"=>
"The recipient you have identified is not a valid recipient of the specified envelope."}
Can someone please help determine what we are doing wrong?
Thanks
LON

Get recipient view not working for composite envelope

I want to create a composite envelope and then do an embedded signing. The issue is that the envelope is created but the call to get the url fails.
First I create the composite envelope:
https://demo.docusign.net/restapi/v2/accounts/ACCOUNT/envelopes
{
"emailSubject": "DocuSign API - Composite Templates",
"emailBlurb": "Composite Templates Sample 1",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "1AA7BA0B-9079-4F8C-915B-739576297D62"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "email#email.com",
"name": "Signer Name",
"recipientId": "1",
"roleName": "Account Holder"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "77343ECC-391F-46A1-BFC3-92A3CD8C93E3"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "email#email.com",
"name": "Signer Name",
"recipientId": "1",
"roleName": "Account Holder",
"tabs": {
"textTabs": [
{
"tabLabel": "AccountFirstName",
"value": "Client"
},
{
"tabLabel": "AccountLastName",
"value": "Name"
},
{
"tabLabel": "Email1",
"value": "someEmail#email.com"
}
]
}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "ADADDD87-E831-4EF3-A160-BBE73F449C8E"
}
],
"inlineTemplates": [
{
"sequence": "3",
"recipients": {
"signers": [
{
"email": "email#email.com",
"name": "Signer Name",
"recipientId": "1",
"roleName": "Account Holder"
}
]
}
}
]
}
]
}
The response is:
{
"envelopeId": "99f4c73d-6420-4e3b-88eb-2447139a2616",
"uri": "/envelopes/99f4c73d-6420-4e3b-88eb-2447139a2616",
"statusDateTime": "2014-08-14T21:09:09.0430000Z",
"status": "sent" }
Next I try to get the recipient view
https://demo.docusign.net/restapi/v2/accounts/ACCOUNT/envelopes/99f4c73d-6420-4e3b-88eb-2447139a2616/views/recipient
{
"authenticationMethod": "email",
"email": "email#email.com",
"returnUrl": "www.someUrl.com",
"userName": "Signer Name"
}
And I get this error:
{
"errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
"message": "The recipient you have identified is not a valid recipient of the specified envelope. Envelope recipient could not be determined. 'clientUserId', 'email', or 'userName' in request and envelope may not match."
}
The email and the names match up so I do not understand why I am unable to get the url. I should point out that this all works if I use the same name and email that is on the DocuSign account, but this needs to work for an external recipient.
To designate a recipient as an embedded/captive recipient when creating an Envelope, such that you'll subsequently be able to submit a "Get Recipient View" request to retrieve a URL that can be used to initiate the recipient's signing session, your "Create Envelope" request must specify the clientUserId property for the recipient. This property should appear as a peer to the other recipient properties (i.e.: email, name, etc.) -- like this:
"signers": [
{
"email": "email#email.com",
"name": "Signer Name",
"recipientId": "1",
"roleName": "Account Holder",
"clientUserId": "12345"
}
]
Then, when you submit the "Get Recipient View" request, you'll need to specify the same value for clientUserId there:
POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/ENVELOPE_ID/views/recipient
{
"authenticationMethod": "Email",
"email": "email#email.com",
"returnUrl": "www.someUrl.com",
"userName": "Signer Name",
"clientUserId": "12345"
}
The value of clientUserId can be anything you wish, but max length is 100 characters. See the DocuSign REST API Guide for more details about embedded signing.

Resources