1

We use Docusign Rest API to pre-populate template data before sending the signer request to the customer by email. We can populate the text field values through the API. But it seems that we cannot attach a file from API.

Is there a direct way or a workaround for attaching files (images, pdfs ...) to a Docusign template by using Rest API? I show the SignerAttachmentTab in the template designer (Web UI), but we cannot set a file path or a byte stream to it programmatically.

Thanks in advance.

J4Priyan
  • 224
  • 1
  • 2
  • 14

1 Answers1

2

You can use Docusign composite templates to attach additional documents while sending an envelope using a template.

Here is a sample request

POST /v2/accounts/{accountId}/envelopes

Request Body:

{
    "emailSubject": "Please complete the following forms 11",
    "status": "sent",
    "compositeTemplates": [
        {
            "serverTemplates": [
                {
                    "sequence": "1",
                    "templateId": "<Template ID Goes here.>"
                }
            ],
            "inlineTemplates": [ ],
        },
        {
            "serverTemplates": [],
            "inlineTemplates": [ {"sequence": "2" }],
            "document": {
                "documentId": "2",
                "name": "Attachment",
                "fileExtension": "txt",
                "documentBase64": "VGVzdCBEb2N1bWVudA=="
            }
        }
    ]
}

Here is great video which demonstrates the power of composite templates.

Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43
  • Thank you for your help. I tried to achieve this from Java SDK, but no luck. For this composite templates, do we have to reconfigure our server template? And could you please post an Java SDK equivalent for this.? – J4Priyan Sep 19 '17 at 11:44
  • You are not required to configure your server templates differently when using composite templates. I don't have a java example handy. But here is a C# [example](https://gist.github.com/codingdawg/736280cc43e91752eb64a0221db80896#file-createenvelopefromtemplate-cs-L16-L80) .. It should be pretty similar when you use the Java SDK. – Praveen Reddy Sep 19 '17 at 14:48