SalesForce DocuSign REST API createAndSendenvelope - docusignapi

Can anyone give a sample apex code REST API example for createAndSendenvelope. I am using demo DocuSign sandbox and I get INCOMPLETE ENVELOPE error. I do have all the required elements in my envelope, so looking to see what I am missing or if I am not creating it in a correct manner. Below is the json that I pass as request and I get response: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"status": "created",
"recipients": {
"signers": [{
"tabs": {
"signHeretabs": [{
"yPosition": "15",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"recipientId": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentid": "1",
"anchorYoffset": null,
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Sign Here",
"anchorIgnoreIfNotPresent": "true"
}],
"initialsTabs": [{
"yPosition": "45",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"receipientId": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentId": "1",
"anchorYoffset": null,
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Initials Here",
"anchorIgnoreIfNotPresent": "true"
}],
"dateSignedTabs": [{
"yPosition": "65",
"xPosition": "249",
"width": "100",
"tablabel": null,
"required": "TRUE",
"receipientid": "1",
"pagenumber": "1",
"fontSize": "Size12",
"font": "Calibri",
"documentid": "1",
"anchorYoffset": "-5",
"anchorXOffset": null,
"anchorUnits": "pixels",
"anchorString": "Date Signed",
"anchorIgnoreIfNotPresent": "true"
}]
},
"routingorder": "1",
"rolename": "First Signer",
"recipientid": "1",
"name": "Marisol L Testcase",
"email": "testfd1#gcpa.com"
}]
},
"emailsubject": "TestDocuSign Call",
"emailBlurb": "Test Email Blurb",
"documents": [{
"name": "Name1",
"fileExtension": ".txt",
"documentId": "1",
"documentBase64": null
}]
}
--BOUNDARY
Content-Type: application/octet-stream
Content-Disposition: file; filename="Name1"; documentid=1
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIHNhbXBsZSBmaWxlIHVwbG9hZCBmb3IgdGVzdGluZy4=
--BOUNDARY--
Update: I could get rid of the boundary parameter error and now get "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Envelope definition missing."

You should not put "documentBase64": null in the "documents" node as you are already passing document as multipart request and "fileExtension" should be "txt" not ".txt". Now coming to the tabs assignment, you are mixing two strategies, one is X/Y position and another is Anchor String. You should use one of them, X/Y position will put a DocuSign tab at specified X/Y position, whereas AnchorString will try to find the that string in the document and if it finds then attaches the DocuSign tab on it. And there is no fall back strategy, means if anchor string is not available then put X/Y position, this is not possible. So either your document should have anchor string then use Anchor String strategy else, remove Anchor string related property from JSON and place tags as per X/Y position.

Related

DocuSign API yields CANNOT_EXCLUDE_DOCUMENT error

We have had code using the DocuSign C# API in production for well over a year now, including some that successfully excludes documents from some recipients but not others. Now, on a new envelope type, I am getting the above error and can't figure out why. Below are the lightly edited/anonymized JSON request payload and DocuSign response with the error (both captured with Fiddler).
As you can see, there are three documents and two signers, with both signers getting document id 1, and one signer being excluded from document id 2 and the other signer excluded from document id 3. There are also two carbon copy recipients who are both internal employees on our account. For what it's worth, the Document Visibility setting on the account is "Must sign to view, unless a member of sender's account."
Here is the JSON payload being sent to DocuSign to create the envelope:
{
"documents": [
{
"documentId": "1",
"name": "Document1",
"fileExtension": "pdf",
"order": "1",
"documentBase64": "blahblahblah"
},
{
"documentId": "2",
"name": "Document2",
"fileExtension": "pdf",
"order": "2",
"documentBase64": "blahblahblah"
},
{
"documentId": "3",
"name": "Document2",
"fileExtension": "pdf",
"order": "3",
"documentBase64": "blahblahblah"
}
],
"recipients": {
"signers": [
{
"tabs": {
"signHereTabs": [
{
"name": "Joe Smith",
"tabLabel": "Signature1",
"scaleValue": "0.9",
"documentId": "1",
"recipientId": "1",
"anchorString": "Some anchor text",
"anchorXOffset": "4",
"anchorYOffset": "46",
"anchorMatchWholeWord": "true",
"tabId": "Signature1"
},
{
"name": "Joe Smith",
"tabLabel": "Signature2",
"documentId": "2",
"recipientId": "1",
"anchorString": "Some other anchor text",
"anchorXOffset": "4",
"anchorYOffset": "67",
"anchorMatchWholeWord": "true",
"tabId": "Signature2"
}
],
"dateSignedTabs": [
{
"tabLabel": "DateSigned1",
"documentId": "1",
"recipientId": "1",
"anchorString": "Some anchor text",
"anchorXOffset": "175",
"anchorYOffset": "38",
"anchorMatchWholeWord": "true",
"tabId": "DateSigned1"
}
],
"textTabs": []
},
"recipientSuppliesTabs": "false",
"excludedDocuments": [ "3" ],
"name": "Joe Smith",
"email": "joesmith#example.com",
"emailRecipientPostSigningURL": "https://www.foocorp.com/e-consent-complete/",
"recipientId": "1",
"customFields": [],
"routingOrder": "1",
"roleName": "Signer",
"emailNotification": {
"emailSubject": "Joe Smith has documents from Foo Corp",
"emailBody": "Blah blah blah"
}
},
{
"tabs": {
"signHereTabs": [
{
"name": "Bob Jones",
"tabLabel": "Signature1",
"scaleValue": "0.9",
"documentId": "1",
"recipientId": "2",
"anchorString": "Some anchor text",
"anchorXOffset": "277",
"anchorYOffset": "46",
"anchorMatchWholeWord": "true",
"tabId": "Signature1"
},
{
"name": "Bob Jones",
"tabLabel": "Signature3",
"documentId": "3",
"recipientId": "2",
"anchorString": "Some other anchor text",
"anchorXOffset": "4",
"anchorYOffset": "67",
"anchorMatchWholeWord": "true",
"tabId": "Signature3"
}
],
"dateSignedTabs": [
{
"tabLabel": "DateSigned1",
"documentId": "1",
"recipientId": "2",
"anchorString": "Some anchor text",
"anchorXOffset": "448",
"anchorYOffset": "38",
"anchorMatchWholeWord": "true",
"tabId": "DateSigned1"
}
],
"textTabs": []
},
"recipientSuppliesTabs": "false",
"excludedDocuments": [ "2" ],
"name": "Bob Jones",
"email": "bobjones#example.com",
"emailRecipientPostSigningURL": "https://www.foocorp.com/e-consent-complete/",
"recipientId": "2",
"customFields": [],
"routingOrder": "1",
"roleName": "Signer",
"emailNotification": {
"emailSubject": "Bob Jones has documents from Foo Corp",
"emailBody": "Blah blah blah"
}
}
],
"carbonCopies": [
{
"name": "Sue Employee",
"email": "sue#foocorp.com",
"emailRecipientPostSigningURL": "https://www.foocorp.com/e-consent-complete/",
"recipientId": "3",
"customFields": [],
"routingOrder": "1",
"roleName": "Internal",
"emailNotification": {
"emailSubject": "Joe Smith has documents from Foo Corp",
"emailBody": "Blah blah blah"
}
},
{
"name": "Sam Employee",
"email": "sam#foocorp.com",
"emailRecipientPostSigningURL": "https://www.foocorp.com/e-consent-complete/",
"recipientId": "4",
"customFields": [],
"routingOrder": "1",
"roleName": "Internal",
"emailNotification": {
"emailSubject": "Joe Smith has documents from Foo Corp",
"emailBody": "Blah blah blah"
}
}
],
"certifiedDeliveries": []
},
"status": "created",
"emailSubject": "Joe Smith has documents from Foo Corp",
"emailBlurb": "Blah blah blah",
"allowMarkup": "false",
"allowReassign": "false",
"recipientsLock": "true",
"emailSettings": {
"replyEmailAddressOverride": "sue#foocorp.com",
"replyEmailNameOverride": "Sue Employee"
}
}
And here is the HTTP response:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-Length: 177
Content-Type: application/json; charset=utf-8
X-RateLimit-Reset: 1519927200
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 997
X-DocuSign-TraceToken: deadbeef-dead-beef-dead-beefdeadbeef
Date: Thu, 01 Mar 2018 17:25:01 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains
{
"errorCode": "CANNOT_EXCLUDE_DOCUMENT",
"message": "This document cannot be excluded for this recipient. Recipient: Joe Smith cannot be excluded from Document:"
}
Any direction appreciated.
Edited to show that the excluded documents both share the same name because it's a "logical name" to me, e.g., "W9" that I use in combination with custom fields on the document to then route to the right place in doc management when it comes back via a Connect call. If I send document id 2 and 3 with different names, then it all works. But exclusions work by document id, not document name, so why would that matter?
Edit #2: I was able to prove to myself that it doesn't matter what the document name is - whether they're the same or different, I get the error.
When you use Anchor string then DocuSign searches for that anchor string on complete envelope and anchors are not at document scope instead anchors are on envelope scope. So if you have same two documents added into the envelope then DocuSign will find the anchor string in both the documents and will assign DS Tabs on both documents to the recipients. Now since you are using same documents twice, so DS Tabs from both documents will be assigned to the recipient and excludedDocuments will not make sense in this scenario.

DocuSign Rest API- Is there a way to configure three optional fields such that if one of them is filled the other two must also field

Hi I am using Docusign rest api. I have a scenario where I have three fields that needs to be filled by the same person(2 text and 1 signature all of them optional). Is there a way to make them such that if one of the text field is filled the signature must be required?
I am trying to use "conditionalParentLabel" and "conditionalParentValue" to achieve this fuctionality but I am not sure what value to give for "conditionalParentvalue" so that the required will get activated for all text input except blank.
Here is a sample CreateEnvelope call that could work for you.
POST /v2/accounts/{accountId}/envelopes
{
"recipients": {
"signers": [
{
"email": "janedoe#yourdomain.com",
"name": "Jane Doe",
"recipientId": 1,
"tabs": {
"signHereTabs": [
{
"optional": "false",
"documentId": "1",
"pageNumber": "1",
"xPosition": "279",
"yPosition": "89",
"conditionalParentLabel": "Amount",
"conditionalParentValue": "##ANY##"
}
],
"textTabs": [
{
"height": 11,
"width": 78,
"required": "false",
"locked": "false",
"maxLength": 100,
"tabLabel": "Amount",
"documentId": "1",
"pageNumber": "1",
"xPosition": "117",
"yPosition": "119"
}
]
}
}
]
},
"emailSubject": "Requesting signature with conditional fields",
"documents": [
{
"documentId": "1",
"name": "Doc One",
"fileExtension": "txt",
"documentBase64": "RG9jIFRXTyBUV08gVFdP"
}
],
"status": "sent"
}

DocuSign Rest API send envelope using composite template

I have a composite template that I use to send the following:
1 document for signing
Another document that doesn't requiring signing, but is included
A document stored in a template
I am receiving the this error : Error performing web request. {
"errorCode": "UNSPECIFIED_ERROR",
"message": "Invalid length for a Base-64 char array or string." I have verified that the Base64 is a multiple of 4. I think that the issue is that I don't have the right content type. I am using Nintex and SharePoint to send the Rest API to DocuSign.
Content type: multipart/form-data;boundary=MY_BOUNDARY
Accept: application/json
Host: na2.docusign.net
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject": "Contract Package for {ItemProperty:Title}",
"status" : "sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [
{
"email": "{WorkflowVariable:varCreatedByEmail}",
"name": "{WorkflowVariable:varCreatedByName}",
"recipientId": "1",
"roleName": "MI Employee",
"routingOrder": "1",
"tabs":
{"signerAttachmentTabs": [
{"anchorString": "/ea1/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Scope of Work Attachment",
"optional": "true",
"tabOrder": 1},
{"anchorString": "/ea2/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Pricing Attachment",
"optional": "true",
"tabOrder": 3}],
"textTabs":[
{"anchorString": "/ec1/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Scope of Work Text",
"disableAutoSize": true,
"width": 550,
"height": 220,
"tabOrder": 2},
{"anchorString": "/ec2/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Pricing Text",
"disableAutoSize": true,
"width": 550,
"height": 220,
"tabOrder": 4}]
}
},
{
"email": "{ItemProperty:E_x002d_Mail}",
"name": "{ItemProperty:Primary_x0020_Contact}",
"recipientId": "2",
"roleName": "Vendor",
"routingOrder": "2",
"tabs":
{"fullNameTabs": [
{"anchorString": "/vn/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"signHereTabs":[
{"anchorString": "/vs/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"dateSignedTabs":[
{"anchorString": "/dvs/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"initialHereTabs":[
{"anchorString": "/vi/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"titleTabs":[
{"anchorString": "/vt/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"emailAddressTabs":[
{"anchorString": "/ve/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"textTabs":[
{"anchorString": "/va1/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Address Line 1"},
{"anchorString": "/va2/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Address Line 2",
"required": false},
{"anchorString": "/va3/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Address Line 3",},
{"anchorString": "/vc/",
"anchorXOffset": "1",
"anchorYOffset": "0",
"tabLabel": "Vendor Name",
"disableAutoSize": true,
"width": 225,
"height": 32}]
}
},
{
"email": "{WorkflowVariable:varContractApproverEmail}",
"name": "{WorkflowVariable:varContractApproverName}",
"recipientId": "3",
"roleName": "MI Approver",
"routingOrder": "3",
"tabs":
{"signHereTabs":[
{"anchorString": "/as/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"dateSignedTabs":[
{"anchorString": "/das/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"fullNameTabs":[
{"anchorString": "/an/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"titleTabs":[
{"anchorString": "/at/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
,
"emailAddressTabs":[
{"anchorString": "/ae/",
"anchorXOffset": "1",
"anchorYOffset": "0"}]
}
} ]
}
} ],
"document": {
"documentId": 1,
"name": "{WorkflowVariable:varContractName}",
"documentbase64": "{WorkflowVariable:varContractBase64}"
}
},
{
"inlineTemplates": [
{
"sequence" : 3,
"recipients": {
"carbonCopies" : [
{
"email": "{WorkflowVariable:varCreatedByEmail}",
"name": "{Common:InitiatorsDisplayName}",
"recipientId": "1",
"roleName": "MI Employee",
"routingOrder": "1"
},
{
"email": "{ItemProperty:E_x002d_Mail}",
"name": "{ItemProperty:Primary_x0020_Contact}",
"recipientId": "2",
"roleName": "Vendor",
"routingOrder": "2"
},
{
"email": "{WorkflowVariable:varContractApproverEmail}",
"name": "{WorkflowVariable:varContractApproverName}",
"recipientId": "3",
"roleName": "MI Approver",
"routingOrder": "3"
}]
}
}],
"document": {
"documentId": 2,
"name": "{WorkflowVariable:varExhibitAName}",
"documentbase64": "{WorkflowVariable:varExhibitABase64}"
}
},
{
"serverTemplates": [
{
"sequence" : 6,
"templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83"
}],
"inlineTemplates": [
{
"sequence" : 7,
"recipients": {
"signers" : [{
"email": "{WorkflowVariable:varCreatedByEmail}",
"name": "{Common:InitiatorsDisplayName}",
"recipientId": "1",
"roleName": "MI Employee",
"routingOrder": "1"
},
{
"email": "{ItemProperty:E_x002d_Mail}",
"name": "{ItemProperty:Primary_x0020_Contact}",
"recipientId": "2",
"roleName": "Vendor",
"routingOrder": "2",
"tabs": {
"textTabs": [
{
"tabLabel": "VendorName"}]}
},
{
"email": "{WorkflowVariable:varContractApproverEmail}",
"name": "{WorkflowVariable:varContractApproverName}",
"recipientId": "3",
"roleName": "MI Approver",
"routingOrder": "3"
}
]
}
}],
"document": {
"documentId": 4,
"name": "CCare_Pledge.pdf"
}
}]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varContractName}"; documentid="1"
<document bytes removed>
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}"; documentid="2"
<document bytes removed>
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"
Link to base64-
http://www.mihomes.com/corp/vit/Base64.txt
In looking at the request you've posted, a few things jump out at me:
First, you've incorrectly specified the boundary separator for the part that specifies documentid=2 as "--MY_BOUNDARY--"
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}"; documentid="2"
By including the -- at the end of this boundary string, you're indicating the end of the multipart message, so it's quite possible that DocuSign is not reading any of the request content that follows this string. I'd suggest changing this to "--MY_BOUNDARY"
Secondly, you're specifying document bytes multiple times for two of the documents (documentid=1 and documentid=2) -- once as part of the document object (using the documentbase64 attribute) in each Composite Template, and again in the additional parts of the multipart request. I'd suggest removing the documentbase64 attribute from the document object of each Composite Template object -- it's not needed if you're specifying the document bytes in additional parts of the multipart message.
Next, if CCare_Pledge.pdf is the first document contained in the Template you're using, then you should remove the document attribute (object) from that Composite Template object:
"document": {
"documentId": 4,
"name": "CCare_Pledge.pdf"
}
And also remove the final part of the request:
--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"
This is not needed because the document's coming from the Template itself, so you don't need to specify document info in the request.
Finally, make sure that your request ends with the correct boundary terminator string:
--MY_BOUNDARY--
(The answer to this other post shows a good example of overall request structure with regard to boundary separators.)
Once you've implemented these suggested changes, your request structure should look like this:
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject": "Contract Package for {ItemProperty:Title}",
"status" : "sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
...
}
}
],
"document": {
"documentId": 1,
"name": "{WorkflowVariable:varContractName}"
}
},
{
"inlineTemplates": [
{
"sequence" : 3,
"recipients": {
...
}
}
],
"document": {
"documentId": 2,
"name": "{WorkflowVariable:varExhibitAName}"
}
},
{
"serverTemplates": [
{
"sequence" : 6,
"templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83"
}
],
"inlineTemplates": [
{
"sequence" : 7,
"recipients": {
...
}
}
]
}
]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varContractName}"; documentid="1"
<document bytes removed>
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}"; documentid="2"
<document bytes removed>
--MY_BOUNDARY--

can i modify tabs of a template using API in docusign

Reading the API documentation i understood that I can edit the tabs of recipients for an envelope which is created/sent
However i am trying to undertsand can i also modify tabs for a template?
When i used the same request, as the one below i am getting error
Any reference would be appreciable.
The reason for my question is, everytime when i update the feed document for some corrections i have to redo creating the fields over it. Rather if i can send the fields through API that would save me a lot of time
Thank you
Sample JSON while updating the TABS (trying to add Tabs)
{
"signers": [
{
"tabs": {
"fullNameTabs": [
{
"name": "Full Name",
"tabLabel": "Full Name",
"bold": "false",
"italic": "false",
"underline": "false",
"documentId": "1",
"recipientId": "5b46b9dc-d40d-493d-b319-5757bf1d5cb4",
"pageNumber": "1",
"xPosition": "321",
"yPosition": "676",
"tabId": "82be754a-47c6-47fc-9793-6fdec6758060"
}
],
"dateSignedTabs": [
{
"name": "Date Signed",
"value": "",
"tabLabel": "Date Signed",
"bold": "false",
"italic": "false",
"underline": "false",
"documentId": "1",
"recipientId": "5b46b9dc-d40d-493d-b319-5757bf1d5cb4",
"pageNumber": "1",
"xPosition": "504",
"yPosition": "676",
"tabId": "1e3f16e8-77a9-4726-9876-66e6d377a0c1"
}
]
},
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "5b46b9dc-d40d-493d-b319-5757bf1d5cb4",
"recipientIdGuid": "5b46b9dc-d40d-493d-b319-5757bf1d5cb4",
"requireIdLookup": "false",
"routingOrder": "1",
"roleName": "ONE",
"status": "created",
"templateLocked": "false",
"templateRequired": "false",
"emailNotification": {
"emailSubject": "Subject",
"emailBody": "Body",
"supportedLanguage": "en"
}
},
{
"tabs": {
"signHereTabs": [
{
"name": "Sign Here",
"tabLabel": "Signature 3",
"scaleValue": 0.9,
"optional": "false",
"documentId": "1",
"recipientId": "d4f63c18-8ccc-4ed3-bacb-660bebf829bf",
"pageNumber": "1",
"xPosition": "106",
"yPosition": "591",
"tabId": "9b20f825-f37c-4dc6-aa57-d29b3d531d6b"
}
],
"fullNameTabs": [
{
"name": "Full Name",
"tabLabel": "Full Name",
"bold": "false",
"italic": "false",
"underline": "false",
"documentId": "1",
"recipientId": "d4f63c18-8ccc-4ed3-bacb-660bebf829bf",
"pageNumber": "1",
"xPosition": "319",
"yPosition": "622",
"tabId": "79c35daf-cada-4a57-ac82-8a2a149839e8"
}
],
"dateSignedTabs": [
{
"name": "Date Signed",
"value": "",
"tabLabel": "Date Signed",
"bold": "false",
"italic": "false",
"underline": "false",
"documentId": "1",
"recipientId": "d4f63c18-8ccc-4ed3-bacb-660bebf829bf",
"pageNumber": "1",
"xPosition": "504",
"yPosition": "622",
"tabId": "14d47f01-a911-49b9-bf04-1c4cadb2924a"
}
]
},
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "d4f63c18-8ccc-4ed3-bacb-660bebf829bf",
"recipientIdGuid": "d4f63c18-8ccc-4ed3-bacb-660bebf829bf",
"requireIdLookup": "false",
"routingOrder": "2",
"roleName": "TWO",
"status": "created",
"templateLocked": "false",
"templateRequired": "false",
"emailNotification": {
"emailSubject": "Subject",
"emailBody": "Body",
"supportedLanguage": "en"
}
},
{
"tabs": {
"approveTabs": [
{
"buttonText": "Approve",
"width": 60,
"height": 18,
"tabLabel": "Approve 9",
"font": "lucidaconsole",
"bold": "false",
"italic": "false",
"underline": "false",
"fontSize": "size9",
"documentId": "1",
"recipientId": "95f1d73e-df27-4f19-86ea-c921f0321d26",
"pageNumber": "1",
"xPosition": "228",
"yPosition": "718",
"tabId": "5083943e-bdf0-42fe-87ff-d92778b13be7"
}
],
"declineTabs": [
{
"buttonText": "Decline",
"width": 60,
"height": 18,
"declineReason": "",
"tabLabel": "Decline 10",
"font": "lucidaconsole",
"bold": "false",
"italic": "false",
"underline": "false",
"fontSize": "size9",
"documentId": "1",
"recipientId": "95f1d73e-df27-4f19-86ea-c921f0321d26",
"pageNumber": "1",
"xPosition": "350",
"yPosition": "718",
"tabId": "b1c1ad78-e3b9-4630-b411-09127997f7dd"
}
]
},
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "95f1d73e-df27-4f19-86ea-c921f0321d26",
"recipientIdGuid": "95f1d73e-df27-4f19-86ea-c921f0321d26",
"requireIdLookup": "false",
"routingOrder": "3",
"roleName": "THREE",
"status": "created",
"templateLocked": "false",
"templateRequired": "false",
"emailNotification": {
"emailSubject": "Subject",
"emailBody": "Body",
"supportedLanguage": "en"
}
}
],
"agents": [],
"editors": [],
"intermediaries": [
{
"name": "",
"email": "",
"recipientId": "fa2bffdb-81d7-4de4-a964-e543e2d1d3cf",
"recipientIdGuid": "fa2bffdb-81d7-4de4-a964-e543e2d1d3cf",
"requireIdLookup": "false",
"routingOrder": "3",
"roleName": "FOUR",
"status": "created",
"templateLocked": "false",
"templateRequired": "false",
"emailNotification": {
"emailSubject": "Subject",
"emailBody": "Body",
"supportedLanguage": "en"
}
}
],
"carbonCopies": [],
"certifiedDeliveries": [],
"inPersonSigners": [],
"recipientCount": "5"
}
URL (tried both POST/PUT)
https://DOMAIN/restapi/v2/accounts/ACCTID/envelopes/ENVELOPID/recipients
RESPONSE
{
"errorCode": "ENVELOPE_CANNOT_CORRECT_INVALID_STATE",
"message": "This account may not have 'correct' permission, or the envelope state is not 'sent' or 'delivered'."
}
I don't believe it's possible to modify the tabs in the Template itself, using the API. The "Modify or Correct Recipient Information" operation you're trying to use allows you to "modify recipients in a draft envelope or correct recipient information for an in process envelope." (from p156 of the REST API guide: https://08d1d92f490618f41c65-8fb00e97ac499a7066a18ce9c66b019b.ssl.cf2.rackcdn.com/REST_API_Guide_v2.pdf). Since a Template is neither a draft envelope nor an in-process envelope, I wouldn't expect this operation to work for modifying tags within a Template.
If you wanted to use a template to specify the document(s), and then specify fields via the "Create Envelope" API call each time you send the envelope, you could achieve this by using a technique like I describe below. (The same technique could also be applied if you're using "Composite Templates" in your Create Envelope API call.)
For example, let's say that I've created a template via the DocuSign UI that has a single recipient (Signer1) and no tags within the document(s). I could then use the following request to create an Envelope that has the document(s) and recipient(s) that the template defines, with the tag(s) that my API request specifies (in this example, just a single Text Tab):
POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
"emailSubject": "Please sign this",
"emailBlurb": "Please sign...thanks!",
"templateId": "TEMPLATE_ID",
"templateRoles": [
{
"roleName": "Signer1",
"name": "John Doe",
"email": "johnsemail#outlook.com",
"recipientId": "1",
"tabs":{
"textTabs":[
{
"documentId": "1",
"pageNumber": "1",
"recipientId": "1",
"xPosition": "100",
"yPosition": "400",
"tabLabel":"Address",
"name":"Address",
"value":"123 Main Street",
"locked": "false"
},
],
}
}
],
"status": "sent"
}
The example above uses templateRoles in the "Create Envelope" request. If you're instead using Composite Templates in your "Create Envelope" request, the request body would look like this:
POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
"emailSubject": "Please sign",
"emailBlurb": "Please sign...thanks!",
"status": "sent",
"compositeTemplates": [{
"serverTemplates": [{
"sequence": 1,
"templateId": "TEMPLATE_ID"
}],
"inlineTemplates": [{
"sequence": 2,
"recipients": {
"signers": [{
"email": "sallysemail#outlook.com",
"name": "Sally Adamson",
"recipientId": "1",
"roleName": "Signer1",
"tabs":{
"textTabs":[
{
"documentId": "1",
"pageNumber": "1",
"recipientId": "1",
"xPosition": "100",
"yPosition": "400",
"tabLabel":"Address",
"name":"Address",
"value":"123 Main Street",
"locked": "false"
},
],
}
}]
}
}]
}]
}
If you're going to implement this approach, I'd suggest that you consider using the "anchor text" technique of specify tag placement, rather than specifying x-y coordinates for each and every tag. Using "anchor text" placement technique means that you specify placement of each tag relative to some existing text within your document(s), such that the tag location will always be correct, even if the format of your document changes slightly -- as long as the anchor text string still exists in the doc and can therefore be used to place the tag. See pages 324-325 of the REST API guide for more info on using anchor text to specify tag placement.

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