4

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?

Anthony Atkinson
  • 3,101
  • 3
  • 20
  • 22

2 Answers2

8

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.

Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43
Ergin
  • 9,254
  • 1
  • 19
  • 28
  • Once again, you're awesome! I'll be testing this out within the next couple of days, but I also heard the same answer back from my DocuSign account manager, so I'll go ahead and mark this one answered. Thanks! – Anthony Atkinson Aug 16 '13 at 13:45
0

To add to Ergin's answer.

Henry Woody
  • 14,024
  • 7
  • 39
  • 56
Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43