I have a client that signs into their DS account, uploads a single 17-page PDF, clicks the action link to the side and selects "Apply Template". The template contains tabs and roles. They fill in the roles in the DS UI and click send. I am attempting to rebuild that process via API.
I found this that looks like it should work for exactly my scenario: How do I apply a template to a document using Docusign REST API
I am getting an envelope with 34 pages instead: the original 17-page uploaded PDF and the 17 pages from the template. The template is being added vs. applied.
The template does have its documents split out (e.g., a 4 page document with two tabs, a 1 page document with 1 tab, etc. total 17 pages). It works great through the UI so not sure if this affects anything.
How do I upload the PDF and apply the template to the document?
Here is my request payload:
POST https://demo.docusign.net/restapi/v2/accounts/ACCTNMBR/envelopes HTTP/1.1
Accept: application/json
Content-Type: multipart/form-data; boundary=myboundary
--myboundary
Content-Type: application/json
Content-Disposition: form-data
{
"emailBlurb": "Test Envelope Blurb",
"emailSubject": "Test Envelope Subject",
"status": "created",
"signingLocation": "Online",
"compositeTemplates": [
{
"document": {
"documentId": 1,
"name": "UPLOADED.pdf"
},
"inlineTemplates": [{
"sequence": "1",
"recipients": {
"signers": [{
"email": "jane.doe@example.com",
"name": "Jane Doe",
"recipientId": "1",
"roleName": "Signer1",
"clientUserId": "123"
}]
}
}]
},
{
"serverTemplates": [{
"sequence": "1",
"templateId": "TEMPLATE_ID"
}]
}]
}
--myboundary
Content-Type: application/pdf
Content-Disposition: file; filename="UPLOADED.pdf"; documentid=1
PDF_BYTES_HERE
--myboundary--