Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two Templates in One Envelope with DocuSign API

Tags:

docusignapi

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?

like image 331
Anthony Atkinson Avatar asked Sep 20 '25 06:09

Anthony Atkinson


1 Answers

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": "[email protected]",
                                "name": "First Recipient",
                                "recipientId": "1",
                                "roleName": "RoleOne"
                            }
                        ]
                    }
                }
            ]
        },
        {
            "serverTemplates": [
                {
                    "sequence": "2",
                    "templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": "2",
                    "recipients": {
                        "signers": [
                            {
                                "email": "[email protected]",
                                "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.

like image 55
Ergin Avatar answered Sep 23 '25 11:09

Ergin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!