Q: Create and Send envelope with template with REST API - docusignapi

I am trying to add the new witness functionality to my API call. Heres the json that I am sending now:
POST https://demo.docusign.net/restapi/v2/accounts/[my id]/envelopes
{
"emailSubject":"test",
"status":"sent",
"templateId":"[Valid template id]",
"templateRoles":[
{
"roleName":"sign1",
"email":"valid#email.com",
"name":"John",
"recipientId":"1",
"routingOrder":"1",
"tabs":{}
},
{
"roleName":"Witness for sign1",
"witnessFor":"sign1",
"witnessForGuid":"1",
"recipientId":"2",
"routingOrder":"2",
"recipientType":"witness"
}
]
}
I have configured the template in DocuSign and verified the functionality by sending an envelope via the DocuSign website. However, the envelopes created from my API call does not trigger the witness functionality. I am not sure what I am missing, and I really appreciate any help/feedbacks.
Cheers

Here is a successful Envelopes::create call that includes the witness recipient type:
"recipients": {
"witnesses": [
{
"name": "Witness Name",
"email": "witness#example.com",
"recipientId": "2",
"witnessFor": "1"
}
],
"signers": [
{
"email": "someone#example.com",
"name": "Signer name",
"recipientId": "1",
"clientUserId": "1000",
"tabs": {
"signHereTabs": [
{
"anchorString": "/sig1/",
"anchorXOffset": "20",
"anchorUnits": "pixels"
}
]
}
}
]
},
Suggested changes in your templateRoles attributes:
(Not tested)
I'm assuming that you have a witness role set in the template.
If you don't, then I think you'll need to add the additional witness recipient to the envelope via composite templates.
You can also try your idea of including "recipientType":"witness"
At the API level, the witness is a distinct recipient for the envelope. It could also the case that the DocuSign web tool creates a hidden recipient (and recipient role) for the witness. To determine if this is the case, use API logging to see what the DocuSign web tool is actually doing.
"templateRoles":[
{
"roleName":"sign1",
"email":"valid#email.com",
"name":"John",
"recipientId":"1",
"routingOrder":"1",
"tabs":{}
},
{
"roleName":"Witness for sign1",
"witnessFor":"1",
OMIT THIS: "witnessForGuid":"1",
"recipientId":"2",
OMIT THIS: "routingOrder":"2",
OMIT THIS: "recipientType":"witness"
}
]
Note
Older developer sandbox accounts don't include the witness feature. If you receive the error message of not having the witness feature, contact go-live --at-- docusign.com to have the feature added to your developer account.

Turns out to be a bug in DocuSign, I had to split the creation step into 2.
1st POST /envelopes:
{
"emailSubject":"Template Action Test",
"status":"created",
"templateId":"866fcb03-1342-4678-9dc3-107772c59e89",
"templateRoles":[
{"roleName":"sign1","email":"email#test.com","name":"JK","tabs":{}}
]
}
2nd PUT /envelopes/envelope-id:
{
"status":"sent"
}

Related

DocuSign API: Assign a delivery method to a TemplateRole to send SMS to a signer

I'm trying to make it so that specific signers to a document can be sent an envelope via SMS instead of email. I am using server templates to create the envelopes, but the examples don't seem to agree on whether to use a TemplateRole or use a Signer to create the envelope. So far I've been using TemplateRole, but it does not seem like there is a delivery method option (for only SMS).
In looking for answers I found a small reference to a bug "TT-3902" that was referenced two years ago and also on a post to the Java SDK, but at the same time another post from a year ago says it is possible - but the link to the API Explorer shows only using a Signer object, not a TemplateRole object...
Questions: Can I use the TemplateRole this way but haven't found the right example? Is there a workaround? Has bug TT-3902 been fixed? Do I need to recode my entire Envelope creation process to be different just to use the Signer objects instead?
Current Code (using Python SDK):
signer = TemplateRole(
role_name=signer_provided["role_name"],
name=signer_provided["name"],
email=signer_provided["email"],
tabs=tabs,
)
What I want to program for SMS delivery:
phone_number = RecipientPhoneNumber(country_code="1", number=signer_provided["phone_number"])
signer = TemplateRole(
delivery_method="SMS",
role_name=signer_provided["role_name"],
name=signer_provided["name"],
phone_number=phone_number,
tabs=tabs,
)
I also tried:
phone_number = RecipientPhoneNumber(country_code="1", number=signer_provided.get("phone_number"))
additional_notification = RecipientAdditionalNotification(secondary_delivery_method="SMS", phone_number=phone_number)
signer = TemplateRole(
additional_notification=additional_notification,
role_name=signer_provided["role_name"],
name=signer_provided["name"],
email=signer_provided["email"],
tabs=tabs,
)
But this only sent an email (using my developer account) and not an SMS at all. I would like it to only send via SMS in this case.
You will need to use Composite Templates for this to work
Here is what the JSON looks like:
{
"envelopeDefinition": {
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"serverTemplates": [
{
"sequence": "1",
"templateId": "1b66677c-xxxx-xxxx-xxxx-655a7c3890d9"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Signer Name",
"roleName": "signer",
"deliveryMethod": "SMS",
"recipientId": "1",
"phoneNumber": {
"countryCode": "",
"number": ""
},
"tabs": {
"textTabs": [
{
"tabLabel": "signer_title",
"value": "Manager"
}
]
}
}
]
}
}
]
}
]
},
"envelopesCreateQP": {}
}

POSTMan sample - creating envelope from a template is not populating the user tags

I created a DocuSign template that contains two roles: Provider and Recipient. I did this via the DocuSign Sandbox UI.
In my template, I have one document, with four tabs on it:
1. ProviderName
2. ProviderAddress1
3. RecipientName
4. RecipientAddress
Should I be using CustomFields vs. Tabs?
What's the API call(s) that I should be making to do the following, given a template with a document in it:
create an envelope for specific users
update the text within the document in the template for the specific users
send it out?
In the POSTMan sample, I tried using this URL, doing a POST:
{{baseUrl}}/envelopes
passing in a templateId, and the following JSON below in the POST body:
JSON:
{
"templateRoles": [{
"email": "{{signer1Email}}",
"name": "The Provider",
"roleName": "Provider",
"tabs": {
"textTabs": [{
"tabLabel": "ProviderName",
"value": "This is the provider!"
},
{
"tabLabel": "ProviderAddress1",
"value": "10 Provider Street, Baltimore, MD 21212"
}]
}
},
{
"email": "{{otherEmail}}",
"name": "Test Recipient",
"roleName": "Recipient",
"tabs": {
"textTabs": [{
"tabLabel": "RecipientName",
"value": "This is the recipient!"
},
{
"tabLabel": "RecipientAddress",
"value": "10 Main Street, Baltimore, MD 21212"
}]
}
}],
"emailSubject": "DocuSign API - Signature Request on Document Call",
"templateId": "<<template ID>>",
"status": "sent"
}
This does return an Envelope Id in the response, and I do receive the email with the DocuSign document to sign.
However, the tabs are NOT populated, they're blank.
Are the roles in the Template empty placeholders? If a name/email is defined on the template, the API call won't populate them as you might expect.
Try to add the documentId and pageNumber properties to your tabs. Also, ensure the label matches what is in the original template.
Lastly, you may need to add recipientId as well to each of the recipients to match what is in the template (this one may not be required since you have the roleName but just in case)

Docusign REST API Changing textTabs in a template

I am having trouble updating textTabs when creating an envelope using the rest API (v2).
The json I'm sending looks like this :
{
"status": "sent",
"emailSubject": "Yet another text 13:57",
"templateId": "xxxxxxx-4dcb-xxxx-xxxx-xxxxxxxx",
"templateRoles": [
{
"name": "Persons Name",
"email": "me#me.com",
"roleName": "Signer",
"tabs": {
"textTabs": [
{
"tabLabel": "ClientName",
"value": "My Name"
},
{
"tabLabel": "ClientAddress",
"value": "This will be the client address"
},
{
"tabLabel": "PhoneNumber",
"value": "+1 555 123 4561"
}
]
}
}
]
}
I have textTabs in the template identified with the template ID with tabLabels set to ClientName, etc.
However - when POSTING the JSON above, the text in the template tabLabels is not replaced.
How do I Change text in TextLabel tabs when creating an envelope in JSON?
Please make sure you are providing the correct tab labels in your request.
You can confirm the name of the tabLabels using the GetTemplateRecipients api
GET /v2/accounts/{accountId}/templates/{templateId}/recipients?include_tabs=true
You also need to make sure that the Role used to add the tabs (this is in the top right of the document entry page), is the same as the TemplateRole detailed in the RoleName attribute of your posted JSON.

Filtering Envelopes based on a type

I have a situation where I want to be able to differentiate between envelopes based on a 'type'. For example, I'll have quotes and invoices, both of these can be sent to the same person so I'd like to know if there's a way of checking some sort of field that could differentiate the two. Currently I'm rather crudely post processing the API results and checking for 'quote' in the document type and I'd like a rather more reliable solution
thanks,
Oliver
You can use Envelope Custom Fields aka Document labels to specify additional metadata for an envelope.
Envelope Custom fields aka Document labels can be used in the envelopes for your account to record information about the envelope, help search for envelopes and track information. The envelope custom fields are not seen by the envelope recipients.
The DocuSign Web sending tool refers to the Envelope Custom fields as Document Labels. You can configure Document Labels as an Administrator on the Account. See instructions here
Once the Document labels are configured at the account level, you can provide label values for each envelope you send through the web sending tool. See instructions here
The other option is to specify Envelope Custom fields using the API. Here is a sample createEnvelope api request that specifies custom Fields associated with the envelope
{
"emailSubject": "Envelope with custom fields",
"status": "sent",
"customFields": {
"listCustomFields": [
{
"listItems": [
"sample string 1"
],
"name": "myListField",
"required": "true",
"show": "true",
"value": "MyListValue"
}
],
"textCustomFields": [
{
"name": "MyOwnTextField",
"required": "true",
"show": "true",
"value": "MyValue"
}
]
},
"recipients": {
"signers": [
{
"recipientId": 1,
"email": "kaysmith#acme.com",
"name": "kay smith",
"routingOrder": "1"
}
]
},
"documents": [
{
"documentId": "1",
"name": "Agreement",
"fileExtension": "txt",
"documentBase64": "RG9jIFRXTyBUV08gVFdP"
}
]
}
More good news: the DocuSign Sending web tool automatically enables the sender, from the web tool, to set the Envelope Custom Fields.
So if you are sending envelopes programmatically or your users are sending them, it is easy to set custom field values.

List of Envelope Documents request does not return envelopeDocuments

I'm having an issue with the following request:
/accounts/{accountId}/envelopes/{envelopeId}/documents
Request:
GET https://na2.docusign.net/restapi/v2/accounts/ACCT_ID/envelopes/ENVELOPE-GUID/documents
And the response looks like this:
{
"envelopeId": "ENVELOPE-GUID"
}
That's the full response I get. It does reproduce at least for several envelopes for me. The envelopes in question are all in 'Completed' or 'Awaiting my signature' sate and have been sent from other DocuSign accounts.
If requested using the sender account, I get a normal response containing the envelopeDocuments array. Same goes for other recipients accounts present in the envelope. The request for those accounts however uses **www.**docusign.net as the baseUrl based on the login_information response.
This also reproduces if I send from the na2 account and later try to retrieve documents list from the www ones so I would say it's some kind of sharding issue.
The request used to work fine with the same accounts earlier.
This is a bug and I've filled it as such with DocuSign's support department.
Authenticating as the sender will be the only workaround you could do for now.
Here's the actual issue:
Create envelope on NA2 and send it to an active account on NA1
Run the following call against REST (v2 or vdev, same results) with the Signer's account information
GET:https://www.docusign.net/restapi/v2/accounts/{accountId}/envelopes/{envelopeId}/documents
Actual Results:
{
envelopeId: "EnvelopeIdGUID"
}
Desired Results:
{
"envelopeId": "EnvelopeIdGUID",
"envelopeDocuments": [
{
"documentId": "1",
"name": "Document1.pdf",
"type": "content",
"uri": "/envelopes/{EnvelopeId}/documents/1",
"order": "1",
"pages": "1"
},
{
"documentId": "2",
"name": "Document2.pdf",
"type": "content",
"uri": "/envelopes/{EnvelopeId}/documents/2",
"order": "2",
"pages": "1"
},
{
"documentId": "certificate",
"name": "Summary",
"type": "summary",
"uri": "/envelopes/{EnvelopeId}/documents/certificate",
"order": "999",
"pages": "4"
}
]
}

Resources