Search code examples
docusignapidocusigncompositetmplts

Docusign Rest API supports Attaching files to a template?


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.


Solution

  • 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.