Skip to main content
Newcomer
September 1, 2026
Question

How to fetch envelopes created from a specific template ID without custom fields?

  • September 1, 2026
  • 2 replies
  • 39 views

Hello Developers, I’m Hudson.
 
In our integration, we create templates (name, description, upload document, add recipients, add fields, save). From the template list we copy the unique templateId from the history screen. When sending envelopes in bulk, we currently paste that templateId into a custom field (TEMPLATE_ID) and then use EnvelopesApi.listStatusChanges with options.setCustomField("TEMPLATE_ID=...") to filter envelopes. This works fine — we can import only the envelopes created from that template.

However, if we don’t add the custom field at envelope creation, the envelope JSON does not expose the templateId directly. We can fetch envelopes, but we cannot tell which template they were created from.

Code snippet (current approach):

EnvelopesApi.ListStatusChangesOptions options = envelopesApi.new ListStatusChangesOptions();
options.setFromDate(fromDate);
options.setFromToStatus("sent,delivered");
options.setCustomField("TEMPLATE_ID=" + templateId);

EnvelopesInformation envelopesInfo = envelopesApi.listStatusChanges(accountId, options);

 

Question: Is there a native way in the DocuSign API/Java SDK to query envelopes by their originating templateId (DocGen or non‑DocGen) without relying on custom fields? For example, can listStatusChanges or another endpoint return or filter by envelopeTemplateDefinition.templateId? Or is the recommended approach always to set a custom field at envelope creation and use that for filtering?


Thanks,

Hudson.

2 replies

September 3, 2026

Hi,

The way you are doing it now is the current way, so you add custom fields which you can then use to search.

An envelope can consist of many documents, which can be generated from many templates, so to achieve what you wish, the envelopes would need to store every templateId that has been used to generate an envelope.

https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/envelopes/

You can raise this as an enhancement request here: https://community.docusign.com/ideas

hudsongNewcomerAuthor
Newcomer
September 3, 2026

Thanks, Troy.

Just to confirm — other than passing a custom field with the templateId, is there any native DocuSign metadata (e.g., template name, externalId, etc.) that can be used to query envelopes created from a specific template?

Or is the recommended approach to always add and query against a custom field ourselves?