I would like to create envelopes using static/composite templates. I have created template, roles and have
configured tags related to the roles into my DocuSign account. I also have retrieved the templateid
of this template to reference this template from API call.
Is there a way to overlay the document from the template with another document at runtime using an
API call?
I tried doing the same using the API Explorer(using REST based API call) but instead of overlaying the
document, it got appended to the document from the template.
My main reason of doing this is to use the tags for recipient roles so that at run time, I do
not need configure the tags for the recipients. In my case, the recipient tags remain the same
for all the recipients/envelopes but the document changes every time I create an envelope.
Please advise,
Yes you can do this. Composite templates are the way to go. When you make the call, create a single composite template structure which references both the server-side template and your document. The inlineTemplate with your document should be in sequence 1 whereas your serverTemplate should be in sequence 2. E.g.:
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject":"DocuSign API - Composite Templates",
"emailBlurb":"Composite Templates Sample 1",
"status":"sent",
"compositeTemplates":[
{
"compositeTemplateId": "1",
"inlineTemplates":[
{
"sequence":"1",
"recipients":{
"signers":[
{
"email":"me#u.them",
"name":"My Signer",
"recipientId":1,
"roleName":"Signer1",
"tabs":{
"textTabs":[
{
"tabLabel":"NDACompany",
"value":"ACME Co USA"
}
]
}
}
]
},
"documents": [
{
"documentId": "1",
"name": "Test Doc.txt"
}
]
}
],
"serverTemplates":[
{
"sequence":"2",
"templateId":"83A07CB0-CF0C-4823-B68A-42EE983F301A"
}
]
}
]
}
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: text/plain
Content-Disposition: file; filename="Test Doc.txt"; documentid=1; compositeTemplateId=1
Howdy. Please sign!
--f6e755d3-bbcf-44e5-b276-8ae626f97220--
Related
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"
}
I'm working on get the signing process on an iFrame to Embedded docusign on my app.
I have trying to work on this based on this tutorials:
Docusign Embedded Signing using template
https://developers.docusign.com/esign-rest-api/guides/features/embedding
Based on what I understood, if you want to embedded you have to create the "create the envelope on the fly". So you don't specify the templateId correct?
So what I don't fully get is, how I get the documentBase64 string value? I have to get it manually? Or docusing api has an endpoint that will return that?
Also I want to know, what happen to the custom fields I added to the template? I can't use them?
Right now this is the json I'm sending:
{{baseUrl}}/envelopes
{
"emailSubject":"This is a custom email subjet, look at the doc.",
"status":"sent",
"templateId":"a0847413-35ac-48ed-9ed6-9b7f96019eda",
"templateRoles":[
{
"email":"mauriciotaranto#email.com",
"name":"Mauricio T",
"clientUserId": "1234",
"roleName":"Test",
"routingOrder":"1",
"tabs": {
"textTabs": [
{
"tabLabel": "Custom",
"value": "This is a custom value"
},
{
"tabLabel": "NewCustom",
"value": "Another custom value added using API"
},
{
"tabLabel": "NewCustom1",
"value": "Last custom value added using API"
}
]
}
}
],
}
And then I go to the recipient view to get the URL:
{{baseUrl}}/envelopes/{{envelopeId}}/views/recipient
{
"returnUrl": "https://www.google.com.uy",
"authenticationMethod": "None",
"email": "mauriciotaranto#email.com",
"userName": "Mauricio T",
"clientUserId": "1234"
}
As far as I understood this way will not allow the user to sing the document.
Need to do it with the document instead.
Can you explain to me how this should work?
Thanks!
UPDATE:
Im manually parsing the bytes of the document to base64. and send this json:
"status":"sent",
"emailSubject":"Envelope with Embedded Signer",
"documents":[
{
"documentId":"1",
"name":"contract.pdf",
"documentBase64":bytes
}
],
"recipients":{
"signers":[
{
"email":"mauriciotaranto#hotmail.com",
"name":"Mauricio T",
"recipientId":"1",
"clientUserId":"1234"
}
]
}
}
I change the headers, add the accept: application/json and content-type: multipart/from-data
And this is the response I get:
{
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
}
You can create envelopes in any way, either by using Templates or by passing base64 of document or both as well using Composite Template. When you send templates, then you already have added signers tabs on the document in the templates so you just need to populate the signer details like name and email in creating an envelope and/or pre-populate the DS Tabs value. But when you send document as base64, then you need to tell DocuSign how to add DS Tabs on the document, either by using
X and Y position of the tabs
AnchorString
PDF Field Transformation
Embedded Signing is a type of signing, to implement that you need to just add clientUserId in the signers details. This can be done in both ways either by using template or by passing document as base64 or both as well using Composite Template. Once you have an embedded signer by adding clientUserId then you need to generate signing URL as explained in your qs, by using Recipient View URL, as soon as URL is generated then you will open this URL in IFrame or on new tab.
In the link which you shared is having very small code snippet and it does not have complete example, check Complete Example, and you will see that they are adding DS Tabs on the document using X/Y position.
I am embedding the signing of a set of documents in a web application. Ultimately, the documents will be filled in with answers provided during an online interview. Three or four documents are needed in the envelope. The documents are server-based templates. In the template definitions I have left the name and email fields blank for the Applicant role (signer), as they are generic templates that will be used by many applicants.
In a test scenario, I can load a single template in an envelope and carry it through the process, but when I convert to a composite template, I get the error "errorCode": "RECIPIENTS_NOT_PROVIDED", "message": "No recipients were found in the request." from the envelope request. I have compared the code to many examples and haven't been able to see anything different. There has to be something basic that I'm missing--not surprising, as this is my first attempt with the DocuSign API. Can someone please enlighten me?
The failing code:
{
"accountId":"xxxxxxx",
"emailSubject":"WOTC Certification Documents - Test Dummy",
"emailBlurb":"Documentation to be submitted by Consultant",
"status":"sent",
"compositTemplates":{
"serverTemplates":[{
"sequence":"1",
"templateId":"ca18aba4-49bd-4c28-9dce-fbd2dd3fbb7b",
"recipients":{
"signers":{
"name":"Test Dummy",
"roleName":"Applicant",
"recipientId":"1",
"clientUserId":"Dummy1234",
"email":"dummy#mydomain.com"
}
}
},{
"sequence":"2",
"templateId":"5ed3d600-5a57-4fee-931f-53233858dc65",
"recipients":{
"signers":{
"name":"Test Dummy",
"roleName":"Applicant",
"clientUserId":"Dummy1234",
"email":"dummy#mydomain.com"
}
}
}]
}
}
Thank you.
You're on the right track, but I'd suggest you make the following changes to the JSON that you've posted:
"compositTemplates" is missing an "e" -- should be compositeTemplates
compositeTemplates needs to be an Array of objects
each object within the compositeTemplates Array needs to contain a serverTemplates property (an Array that specifies the template info) and an inlineTemplates property (an Array that specifies the recipient info)
within each recipients object, signers needs to be an Array of objects
each signer object needs a recipientId property
Here's your JSON again, modified to implement the changes I've listed above:
{
"accountId":"xxxxxxx",
"emailSubject":"WOTC Certification Documents - Test Dummy",
"emailBlurb":"Documentation to be submitted by Consultant",
"status":"sent",
"compositeTemplates":[
{
"serverTemplates":[
{
"sequence":"1",
"templateId":"ca18aba4-49bd-4c28-9dce-fbd2dd3fbb7b"
}],
"inlineTemplates":[
{
"sequence" : 2,
"recipients":{
"signers":[{
"name":"Test Dummy",
"roleName":"Applicant",
"recipientId":"1",
"clientUserId":"Dummy1234",
"email":"dummy#mydomain.com"
}]
}
}],
},
{
"serverTemplates":[
{
"sequence" : 3,
"templateId":"5ed3d600-5a57-4fee-931f-53233858dc65"
}],
"inlineTemplates":[
{
"sequence" : 4,
"recipients": {
"signers" : [{
"name":"Test Dummy",
"roleName":"Applicant",
"recipientId": "1",
"clientUserId":"Dummy1234",
"email":"dummy#mydomain.com"
}]
}
}]
}]
}
I saw the DocuSign API can automatically transform and assign pdf fields to a single default recipient (Docusign Transform Pdf Fields For single recipient?).
Is it possible to do the assignment for multiple recipients?
I am hoping to leverage the auto transform feature but at the same time assign different pdf fields to different recipients during envelope creation.
Thanks.
The following sample creates an envelope using the REST API using base64 encoded pdfBytes that represents a PDF document that contains a number of adobe form fields: option field, check boxes, signature fields. We use name of the adobe field to map this field to a DocuSign tag created for each recipient.
Note that the key here is to name each PDF form field with a format that it is easily assignable to recipient by using a wildcard.
Please refer to the Document Parameters (under note) for the rules used to match adobe fields to DS fields. We will be transforming all adobe fields and assigning them to two recipients, to do this we will be creating each signer and tags, the way we will be binding each DS tag created by using wildcards on the tabLabel. We will be also setting values for some of the data fields and we will be selecting radio button grouped in a parent and selecting check boxes that we have created as a result of transforming these fields.
HTTP Headers:
Accept: application/json
X-DocuSign-Authentication: {"Username": "your_sender#mail", "Password":"your_password", "IntegratorKey":"your_integration_key"}
Content-Type: multipart/form-data; boundary=e6e95273-cafb-4dbf-86b8-a1c0ed85b5c5
Resource: https://{env}.docusign.net/restapi/{version}/accounts/{accountId}/envelopes
Method: POST
Payload:
--e6e95273-cafb-4dbf-86b8-a1c0ed85b5c5
Content-Type: application/json
Content-Disposition: form-data
{
"status":"sent",
"emailSubject":"Test transforming pdf forms and assigning them to each user",
"compositeTemplates":[
{
"inlineTemplates":[
{
"sequence":1,
"recipients":{
"signers":[
{
"email":"[replace this with a valid email]",
"name":"Signer One",
"recipientId":"1",
"routingOrder":"1",
"tabs":{
"textTabs":[
{
"tabLabel":"PrimarySigner\\*",
"value":"Signer One"
}
],
"checkboxTabs":[
{
"tabLabel":"PrimarySigner\\*",
"selected":true
}
],
"signHereTabs":[
{
"tabLabel":"PrimarySigner\\*"
}
],
"dateSignedTabs":[
{
"tabLabel":"PrimarySigner\\*"
}
],
"radioGroupTabs":[
{
"groupName":"PrimarySigner\\*",
"radios":[
{
"value":"M",
"selected":true
}
]
}
]
}
},
{
"email":"[replace this with a valid email]",
"name":"Signer Two",
"recipientId":"2",
"routingOrder":"2",
"tabs":{
"textTabs":[
{
"tabLabel":"SecondarySigner\\*",
"value":"Secondary One"
}
],
"checkboxTabs":[
{
"tabLabel":"SecondarySigner\\*",
"selected":true
}
],
"signHereTabs":[
{
"tabLabel":"SecondarySigner\\*"
}
],
"dateSignedTabs":[
{
"tabLabel":"SecondarySigner\\*"
}
],
"radioGroupTabs":[
{
"groupName":"SecondarySigner\\*",
"radios":[
{
"value":"F",
"selected":true
}
]
}
]
}
}
]
}
}
],
"document":{
"documentId":1,
"name":"test.pdf",
"transformPdfFields":true
}
}
]
}
--e6e95273-cafb-4dbf-86b8-a1c0ed85b5c5
Content-Type: application/pdf
Content-Disposition: file; filename="test1.pdf"; documentId=1
Content-Transfer-Encoding: base64
[replace this with a base64 encoded]
--e6e95273-cafb-4dbf-86b8-a1c0ed85b5c5--
I have the following requirement:
Five of my documents are generated from our system dynamically. The sixth document is an appendix. It's just a static pdf file. That appendix is 55 pages long.
So far I've been creating the envelope with the five documents, then I pull the appendix from a shared folder on our server, then I send it to docusign. The appendix takes about half of the upload time.
It would be more efficient if I had a template on Docusign that only includes the appendix, then I call it and add my five documents. My concerns are:
Is mixing and matching templates with stand alone documents supported?
The number of recipients and the signing tags change dynamically depending on our business rules. A template requires predefined roles and tags on the template. Is there a way to inject more recipients and tags to an Envelope that uses a template?
Using a "Composite Template" structure in your Create Envelope API request will allow you to create an Envelope using a combination of document(s) from DocuSign template(s) and document(s) specified at runtime via the API request, and gives you fairly dynamic control over recipients as well. For more information about using Composite Templates in a Create Envelope API request, search the API guide (either REST or SOAP) for "Composite".
When you use Composite Templates in your Create Envelope request, each individual Composite Template object in your request has to provide information required for a complete envelope (i.e., at least 1 recipient and 1 document...or a Server Template that defines the documents and/or recipients). Then DocuSign essentially combines all of the recipient and document info from all of your Composite Template objects in the request to form the Envelope. In the case of the example JSON request below, the resulting envelope contains:
3 recipients (populated dynamically via the API request: 1-Abby, 2-Bob, 3-Charlie)
3 documents (the first specified via the API request, the second specified via the API request, the third specified via a DocuSign template)
POST https://demo.docusign.net/restapi/v2/accounts/YOUR_ACCOUNT_NUMBER/envelopes
X-DocuSign-Authentication: {"Username":"YOUR_USER_NAME","Password":"YOUR_PASSWORD","IntegratorKey":"YOUR_INTEGRATOR_KEY"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"status" : "sent",
"emailSubject" : "Test Envelope",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence" : 1,
"recipients": {
"signers" : [{
"email": "abbysEmailAddr#outlook.com",
"name": "Abby Abbott",
"recipientId": "1"
}, {
"email": "bobsEmailAddr#outlook.com",
"name": "Bob Burns",
"recipientId": "2",
"routingOrder":"2"
},
{
"email": "charliesEmailAddr#outlook.com",
"name": "Charlie Carlson",
"recipientId": "3",
"routingOrder":"3"
}]
}
}],
"document": {
"documentId": 1,
"name": "Customer Agreement",
"fileExtension": "pdf"
}
},
{
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "abbysEmailAddr#outlook.com",
"name": "Abby Abbott",
"recipientId": "1"
}]
}
}],
"document": {
"documentId": 2,
"name": "Test File",
"fileExtension": "pdf"
}
},
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "YOUR_TEMPLATE_ID"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "abbysEmailAddr#outlook.com",
"name": "Abby Abbott",
"recipientId": "1",
"roleName": "Customer",
"routingOrder":"1"
}
]
}
}]
}
]}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"
**pdf bytes removed for brevity**
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="TestFile.pdf"; documentid="2"
**pdf bytes removed for brevity**
--MY_BOUNDARY--
Using Composite Templates is kind of tricky (and not well documented), so it may require some trial and error to get things to work exactly as you require -- but hopefully this example sheds some light on how Composite Templates can be used to create an envelope from a combination of DocuSign templates and documents specified dynamically via the API request.