I am creating envelopes from a template. I need to know the documentIds that will be created in the envelope ahead of time so I can deal with a strange special case prefilling radio buttons. (I can explain why in more detail, but it's not really relevant to this question.)
So where do these document IDs come from? I am using the REST api for all of this.
This is my template:
GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/templates/78b351c5-84f8-49c9-af48-redacted
{
"envelopeTemplateDefinition": {
"templateId": "78b351c5-84f8-49c9-af48-redacted",
"name": "my dev template",
.... truncated for brevity ....
},
"documents": [
{
"documentId": "73370178",
"uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/73370178",
"name": "DS_Testing_Doc1.pdf",
"order": "1",
"pages": "1"
},
{
"documentId": "13535052",
"uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/13535052",
"name": "DS_Testing_Doc2.pdf",
"order": "2",
"pages": "1"
}
],
"recipients": {
.... truncated for brevity ....
}
}
This is my Create Envelope from Template call:
POST https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/
{ "envelopeId":null,
"accountId":"redacted",
"templateId":"78b351c5-84f8-49c9-af48-redacted",
"status":"sent",
"templateRoles":[
{
"id":null,
"roleName":"producer",
"email":"[email protected]",
"name":"Eric",
"clientUserId":"",
"status":"sent",
"tabs":{
.... truncated for brevity ....
}
},
{
"id":null,
"roleName":"hidden",
"email":"[email protected]",
"name":"My Agent",
"clientUserId":"",
"status":"created",
"tabs":{
.... truncated for brevity ....
}
}
],
"voidedReason":null
}
Response from creating envelope:
{
"envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted",
"statusDateTime": "2016-01-26T20:41:59.2400000Z",
"status": "sent"
}
Now get the details about Documents in the envelope:
GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents
{
"envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
"envelopeDocuments": [
{
"documentId": "1",
"name": "DS_Testing_Doc1.pdf",
"type": "content",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/1",
"order": "1",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
},
{
"documentId": "2",
"name": "DS_Testing_Doc2.pdf",
"type": "content",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/2",
"order": "2",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
},
{
"documentId": "certificate",
"name": "Summary",
"type": "summary",
"uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/certificate",
"order": "999",
"pages": "1",
"availableDocumentTypes": [
{
"type": "electronic",
"isDefault": "true"
}
]
}
]
}
In the final call where I view details about Documents in the Envelope, the IDs are "1" and "2". However, in my template, the documentIDs are "73370178" and "13535052".
So, how do documentIds get assigned when creating an Envelope from a template? Do they correspond to 'order' in the template, as they appear to? Can I rely on them always starting at 1 incrementing from there?
Is it possible to define the documentIds in my template and have them be the same when I create an Envelope?
Is it possible to assign the documentIds when creating the envelope from the template (assuming the PDF is uploaded to the template, not sending the whole PDF byte stream)?
Cheers
The documentId is actually completely up to you - it's a client defined value and takes a string so really you can use any naming standard you want (i.e. numbers, letters, or a combo). Many integrations use simple numbers (1, 2, 3, etc.) for the documentIds whereas others others use strings or other identifiers.
In any case, you just need to remember what value you set for a given a document if you want to later assign a radio tab to a recipient of that document.
Note: If you do NOT provide a documentId when creating an envelope the system will automatically generate and assign an GUID as the documentId, you can then make the Get Documents API call to retrieve that ID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With