Hello, @Aymeric.P
Welcome to the Docusign Community!
Have you read this article?
Creating and using templates - using REST API
https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/templates/creating/
There are some examples and other more specifc links for your need.
I hope that helps.
Best,
Alexandre
Hi Alexandre,
Thanks for your answer, I read the article and related links. I forgot to mention that we are not using the API to create the envelopes, it is done through the Web UI by selecting a template and then the “Use” button.
As you can see on the “Envelope report” screenshot above, all envelopes have a template ID but the API query does not return them.
The issue occurs when we create an envelope using a template without any document, then we manually upload the document to be signed.
In those cases, the query /templates on the envelope is empty {} but we still need to get the selected template ID.
If you are not seeing the template show up in the GET Request when you use the below endpoint it might be caused if the envelope was in fact not created using a template.
https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopetemplates/list/
You might also want to try using the additional but optional query parameters. For example
GET: https://demo.docusign.net/restapi/v2.1/accounts/accountIDHere/envelopes/EnvelopeIDHere/templates?include=matching
or
GET: GET: https://demo.docusign.net/restapi/v2.1/accounts/accountIDHere/envelopes/EnvelopeIDHere/templates?include=applied
If this is reproducible on command and you are sure templates are being used to create the envelope, a case with our developer support team would be the suggested next step.
If you do end up creating a support case you would want to capture an API log of the issue being reproduced and attach the log onto the support case. You can capture API logs by following the steps shown here while logged into the account of the user making the API request: https://support.docusign.com/s/document-item?language=en_US&rsc_301&bundleId=jux1643235969954&topicId=poz1578456669909.html&_LANG=enus
One other approach would be to follow the guide below in order to track template usage when creating envelopes: https://www.docusign.com/blog/developers/the-trenches-track-your-templates-envelope-custom-fields
Thank you KollK for your help. The case is indeed reproducible, I captured the log and I will open a support case.
Meanwhile we might go for the alternative approach using a custom field to store the template ID.