How to create a template
This topic demonstrates how to create a template.
Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
Required data
Running the code in this how-to requires this data:
Step 1. Obtain your OAuth token
To make the API call shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.
See Confidential Authorization Code Grant for guidance on your options to get an Confidential Authorization Code Grant OAuth token.
Step 2. Create a template
-
Create a new template definition.
- Add a document to the definition by saving it to a variable as a base64 string. If you intend to attach multiple documents, specify the document order using an array. The order of the array will be the document order.
- Create role placeholders for your recipients. For this template, we are assigning placeholders to a ‘Signer’ role and a carbon copy ‘CC’ role. These placeholder roles contain an ID, a role name, and a routing order that determines the order of delivery.
- Create and assign signable fields (also known as tabs) for each specific signer within the document. This code example uses absolute positioning to set each tab a specific number of points from the corner of the screen.
- Set the template definition data, including a description, name, email subject, recipients, and status.
-
Create the template object from your definition using the Templates:create method.
Step 3. Call the eSignature REST API
Make a POST request to Templates:create to create the template. Here’s how you make the call, but make sure to substitute your API account ID for {ACCOUNT_ID} and your template ID for {TEMPLATE_ID}.
Expected response
“Example Signer and CC template” is created under Templates in the Templates.
Next steps
- Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
- Learn about templates or see How to request a signature by email using a template.
- Learn about composite templates or see How to request a signature using a composite template.
- Review Working with Templates.
- See how to Go-Live with a completed app and find the base path for API calls in the production environment.