Hello all,
I am a developer using the eSignature API (specifically the Envelopes API) to construct Envelopes from multiple Composite templates.
My goal: I have a use case where I need to download a specific document from a signed Envelope. I want to understand the best / most efficient way to accomplish this.
After taking a look at the API documentation, I see that the only way to download a specific document from an Envelope is to use the EnvelopeDocuments:get API, which requires passing in the documentId.
I also know that despite specifying unique documentIds in each composite template, the documentId field is not guaranteed to stay the same as the envelope assigns new values to avoid any potential collisions. (See Referencing ID values here).
This makes getting the documentId challenging, and I am wondering what is the best way to accomplish this. After reading How to track recipients and documents when IDs change, I can think of three ways to identify a specific document:
- The article recommends to use EnvelopeDocuments:list API to retrieve all documents and use the filename field to identify the documentId. In my opinion, this method is brittle, as the filename is controlled via the template in the Docusign template UI. If the filename were to change tomorrow, any application logic we write around this field would break.
- The alternative approach mentioned in the article is to provide EnvelopeDocumentFields and use those to identify the document in question. In theory, I could pass a custom document field for the specific document I need to download and then search for this custom field in order to identify the documentId for download. However, I discovered that custom document fields are not included in the EnvelopeDocuments:list API response. As a result, this approach requires many API calls:
- 1 call to write the custom field
- 1 call to list the documents in the envelope
- n calls to iterate through each document and check it for the custom field
- 1 call to download the document with found documentId.
- A third approach would be to use the templateId of the document I am searching for. I have this information available to me, but the solution would require me to list all documents and iterate through each one, calling EnvelopeTemplates:listByDocument to check if the document’s templateId matches the one I am searching for. Also very inefficient.
Is there a better way to identify a specific document within an Envelope constructed from multiple Composite templates?
Thank you for taking the time to read. I appreciate any support!