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

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": {}
}

Related

How to get embedded signing URL for signers who are assigned by agents/intermediaries in DocuSign?

When using agents/intermediaries to assign signers in DocuSign, we set the clientUserId for the signers to use the embedded signing feature. But DocuSign will automatically send out the email to the assigned signers and we are not able to obtain the signing URL through the API POST {{baseUrl}}/v2.1/accounts/{{accountId}}/envelopes/{{envelopeId}}/views/recipient.
As suggested in this thread: https://stackoverflow.com/a/63810135/13191875 . It's due to the clientUserId was removed when agents/intermediaries change the signer's email/name info. It suggests that a workflow could be added to pause the process after the signer's email/name info is changed, and then add the clientUserId to the signer, then resume the workflow.
I tried with request body:
{
"recipients": {
"intermediaries": [
{
"clientUserId": "1",
"email": "aaa#example.com.au",
"name": "Intermediary",
"recipientId": "1",
"routingOrder": "1"
}
],
"signers": [
{
"clientUserId": "2",
"email": "example#example.com",
"name": "example",
"recipientId": "2",
"routingOrder": "2",
"tabs": {
"signHereTabs": [
{
"anchorIgnoreIfNotPresent": "false",
"anchorString": "Signature_anchor_1",
"anchorUnits": "pixels",
"anchorYOffset": "0",
"name": "Please sign here",
"recipientId": "1"
}
]
}
}
]
},
"workflow": {
"workflowSteps": [
{
"action": "pause_before",
"itemId": "2",
"triggerOnItem": "routing_order"
}
]
},
"emailSubject": "DocuSign API - Signature Request on Document Call",
"documents": [
{
"documentId": "1",
"name": "{{fileName}}",
"documentBase64": "{{fileBase64}}"
}
],
"status": "sent"
}
I can set the clientUserId after the signer's email/name is changed. But the workflow cannot be resumed by calling the API PUT {{baseUrl}}/v2.1/accounts/{{accountId}}/envelopes/{{envelopeId}}?resend_envelope=true. So the signer's signing URL cannot be obtained since the process is paused, the signer's status stays in created.
I also tried the with agents:
{
"recipients": {
"agents": [
{
"clientUserId": "1",
"email": "aaa#example.com.au",
"name": "Agent",
"recipientId": "1",
"routingOrder": "1"
}
],
"signers": [
{
"clientUserId": "2",
"email": "",
"name": "",
"recipientId": "2",
"routingOrder": "2",
"tabs": {
"signHereTabs": [
{
"anchorIgnoreIfNotPresent": "false",
"anchorString": "Signature_anchor_1",
"anchorUnits": "pixels",
"anchorYOffset": "0",
"name": "Please sign here",
"recipientId": "1"
}
]
}
}
]
},
"workflow": {
"workflowSteps": [
{
"action": "pause_before",
"itemId": "2",
"triggerOnItem": "routing_order"
}
]
},
"emailSubject": "DocuSign API - Signature Request on Document Call",
"documents": [
{
"documentId": "1",
"name": "{{fileName}}",
"documentBase64": "{{fileBase64}}"
}
],
"status": "sent"
}
After the name/email is added by the agent, the process is paused and I set the clientUserId for the signer, I verified that it is added by calling the get recipients info API. After I resume the process, an email is sent by DocuSign to the signer and I cannot get the embedded signing URL for that signer. I can see the clientUserId is removed for that signer by calling the get recipients info API again.
My question is:
when using agents/intermediaries in DocuSign, is it possible that we can obtain the embedded signing URL for the assigned signer whose email is updated/added by agents/intermediaries?
when using agents/intermediaries in DocuSign, is it possible that we can turn off that email from DocuSign to the signer, whose email is updated/added by agents/intermediaries?
when using agents/intermediaries in DocuSign, is it possible that we can obtain the embedded signing URL for the assigned signer whose email is updated/added by agents/intermediaries?
Yes, but you'll first need to assign a clientUserId to the recipient.
And since the recipient has already been sent an email invite to the signing ceremony, adding a clientUserId attribute is problematic since doing so will invalidate the email invite.
when using agents/intermediaries in DocuSign, is it possible that we can turn off that email from DocuSign to the signer, whose email is updated/added by agents/intermediaries?
To do this, you need to stop the workflow as I described in the other answer.
Much better would be to expand your API application so that it is used to change the name/email of the signer. That way your application can also set the clientUserId at the same time and the signer won't receive any email.
Basically, embedded signing is only intended to work if the envelope is created/edited via an API program. Your goal of using an API program and using the regular DocuSign Web App (which focuses on email delivery, not embedded signing) is mixing apples and oranges. It is possible but problematic.
You can potentially use the new Advanced Recipient Routing (ARR) feature to pause the envelope, obtain the information about the next recipient (via GET call to listRecipients) and then modify it to add the clientUserId. I have not tried this, but in theory that should work.
ARR is now available in demo/developer accounts for all new accounts created.
https://developers.docusign.com/docs/esign-rest-api/how-to/pause-workflow has information about how to create the envelope such that it pauses after a specific routing number.
https://developers.docusign.com/docs/esign-rest-api/how-to/unpause-workflow shows how to resume the envelope once you made your change.
The other thing you may need to do is add a webhook call for when the status of the intermediary was updated so you know when to update the next recipient (but before you can do that you would have to obtain the information about the new recipient).

Q: Create and Send envelope with template with REST API

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"
}

Docusign signing url - Showing document 1 of a composite template

Using the docusign rest api i would like to create an envelope with 2 documents.
I will then be using the Post Recipient view to show document 1 to the first recipient (in an iframe) and once signed show document 2 in the same envelope to another recipients.
i have created the templates with different tempalteRoles (different names, order 5 and 10).
Its my understanding using a userId and the right settings in my docusign account, i can show document 1 to recipient 1 and then document 2 to recipient 2.
When i try and create the composite envelope the whole document is shown.
when i call the recipient status for the envelope it only shows one signer.
I have found the envelope will only create when the 2 template roles have the same clientUserId, userName and email, otherwise i get the error "ONESIGNALLSIGN_NOT_SATISFIED"
here is the envelope i am sending through
{
"accountId": "ACCOUNT_ID",
"emailSubject": "Email subject",
"status": "sent",
"templateId": "TEMPLATE_ID",
"templateRoles": [
{
"roleName": "PDS Customer",
"email": "pds#example.com",
"name": "TestFirstName TestSurname",
"clientUserId": "1",
"tabs": {
"textTabs": [
{
"tabLabel": "DocumentNumber",
"value": "123456789",
"locked": true,
"documentId": 1,
"pageNumber": 1
}
...removed some
]
}
},
{
"roleName": "Customer",
"email": "test#example.com",
"name": "mrTestFirstName TestSurname",
"clientUserId": "2",
"tabs": {
"textTabs": [
{
"tabLabel": "StorerEmail_LocalPart",
"value": "test",
"locked": true,
"documentId": 2,
"pageNumber": 1
}
...removed some
]
}
}
],
"compositeTemplates": [
{
"compositeTemplateId": 1,
"serverTemplates": [
{
"sequence": 1,
"templateId": "TEMPLATE_ID_2"
}
]
}
]
}
The error message is due to having Document Visibility enabled. In that scenario, each signer must have at least one tab present. Your second signer (embedded or not) must have at least one tab. In this case it'd probably be on the second document.
Your API call above does refer to a second documentId though so you may be okay there.
I would suggest that you not mix the "simple" sending (using templateRoles at the top level) with composite templates. Instead, add an inline template to the compositeTemplates structure with all of your recipient information. You may be seeing some odd behavior due to mixing those.
Lastly, the default Document Visibility configuration will show a document to a recipient only if they have a tab on that document. If your second signer should see all documents then you must either add a tab for them on each document or explicitly set visibility per document.

How do I docuSign multiple documents in an envelope once using docuSign Rest API?

I am creating composite templates that work correctly and I'm running into this issue.
I am adding 2 templates to sign via docusign. I set the routing orders for both of them as shown below:
Form 1
Order 1 RoleName signer test1#gmail.com
Order 2 RoleName signer2 test2#gmail.com
Form 2
Order 1 RoleName dataEntry test1#gmail.com
Order 2 RoleName dataEntry2 test2#gmail.com
This will send one email to test#gmail.com. This user completes all of his fields for both Form 1 and Form 2 in one request. This is what I want and expect. However, when test1#gmail.com completes their process, test2#gmail.com will receive 2 different emails. One to sign form 1 and the other to sign form 2. I'm trying to understand why test2#gmail.com doesn't work the same as test1#gmail.com. Can someone help explain what the reason is for receiving 2 separate emails for test2#gmail.com may be and if there's a way to fix it?
Note: When I do this via the docuSign website, it doesn't allow for the same recipient to be in that same routingOrder. It will bring up the error:
The role 'signer' conflicts with 'dataEntry'
The role 'signer2' conflicts with 'dataEntry2'
This behavior seemed strange to me since I'm able to send the envelope using the docusign rest API. If somebody could give me some clarification on this as well I'd appreciate it.
Thank you!
I am unable to repro the issue you describe. Here's what I did, and the Result:
I created two separate templates in DocuSign, each having a single document and two recipients/signers (with Role Names and Routing Orders that you specify above in your question).
I used the REST API (JSON request included below) to create/send an Envelope from these two Templates, specifying identical recipient information (name/email/recipient ID/routing order) for Recipient 1 and Recipient 2 across both Inline Template structures.
Result: Recipient 1 receives an email first, opens the envelope, and signs both documents at once. Then Recipient 2 receives an email, opens the envelope, and signs both documents at once. The Envelope status is "Completed" at that point.
I've included my API request below for your reference -- perhaps compare/contrast this with what you're doing? Also -- make sure that Recipient information (Name / Email / Recipient ID / Routing Order) is identical (including case) for each recipient between the first Inline Template and the second Inline template within the API Request -- any small difference in Name/Email/Recipient Id/Routing Order, and DocuSign will treat them as different/separate people (recipients).
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_1"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "adamsemail#outlook.com",
"name": "Adam Adamson",
"recipientId": "1",
"roleName": "signer",
"routingOrder": "1"
},
{
"email": "bobsemail#outlook.com",
"name": "Bob Burns",
"recipientId": "2",
"roleName": "signer2",
"routingOrder": "2"
}
]
}
}]
},
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "TEMPLATE_ID_2"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "adamsemail#outlook.com",
"name": "Adam Adamson",
"recipientId": "1",
"roleName": "dataEntry",
"routingOrder": "1"
},
{
"email": "bobsemail#outlook.com",
"name": "Bob Burns",
"recipientId": "2",
"roleName": "dataEntry2",
"routingOrder": "2"
}
]
}
}]
}]
}

Two Templates in One Envelope with DocuSign API

I've been able to successfully start an envelope with a template using the templateID, but I'm attempting to generate an envelope with two documents inside that both have templates. In the DocuSign website interface it's possible to start a new envelope then "check off" multiple templates to add to the envelope.
I've found the API calls to:
Start an envelope with a template
Get a template
Add a document to an envelope
However, there's unfortunately nothing that I can find to add a template to a draft envelope once it's been created. The question here, in case it's not obvious, is: what is the API call to generate a new document from a template and add it to a pre-existing envelope in created status?
You can create an envelope based on multiple templates. The trick is to use the compositeTemplates optional property of the request.
Back in April 2013 I hosted a webinar focused on templates where I demonstrated 3 different template examples. They were increasing in complexity leading up to the third, where that last one shows how to combine multiple templates into one envelope. Here is the Gist for it, which contains PHP code and sample JSON bodies:
https://github.com/Ergin008/DocuSign-REST-API-Webinar-April2013
Here is the JSON for the third example, you'll want to add something similar to your request body:
{
"emailSubject": "DocuSign Templates Webinar - Example 3",
"emailBlurb": "Example #3 - Composite Templates",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "55A80182-2E9F-435D-9B16-FD1E1C0F9D74"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "test#docusign.com",
"name": "First Recipient",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "test2#docusign.com",
"name": "Recipient 2",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
}
]
}
Note that the sequence property of the server template can be used to change the order that the template documents show up in the envelope.
To add to Ergin's answer.
You can add a template to an existing envelope using the applyEnvelopeTemplates api.
You can add templates to a document in the specified envelope using the EnvelopeTemplate:applyToDocuments api

Resources