Create eSign from Templates
This guide walks you through creating an eSignature transaction from pre-configured templates using the Stewart Sign API. Templates allow you to define document layouts, tag placements, and roles ahead of time, then reuse them for multiple transactions.
When to Use
Creating an eSign session from templates is useful when you need to:
- Automate recurring signing workflows (e.g., mortgage agreements, employment contracts)
- Ensure consistent tag placement across transactions
- Pre-fill dynamic text fields in documents (e.g., names, dates, terms)
- Assign participants to predefined roles
Note: This endpoint requires the
apiTemplatingEsignfeature to be enabled for your organization. Contact Stewart Sign support if you receive a401 Unauthorizedresponse.
Requirements
- You need to have Node.js installed on your system.
- You'll also need the axios library. You can install it using the following command:
npm install axios
- A valid Bearer token (JWT) for authentication.
- One or more template IDs — use
GET /esign/templates/{id}to retrieve template details including roles and free-text fields.
Endpoint
POST /esign/create-from-templates
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
templates | array | Yes | List of templates to use. Each template has an id and optional fields. |
templates[].id | string (UUID) | Yes | The template ID. |
templates[].fields | array | No | Free-text field values for document generation. Each field has an id and text. |
participants | array | Yes | List of participants (max 4). Each participant must be assigned a role from the template. |
participants[].email | string | Yes | Participant's email address (must be unique). |
participants[].firstName | string | Yes | Participant's first name. |
participants[].lastName | string | Yes | Participant's last name. |
participants[].roleId | string (UUID) | Yes | The role ID from the template (must be unique per participant). |
participants[].primary | boolean | Yes | Exactly one participant must be marked as primary: true. |
participants[].order | number | No | Signing order (0-based, sequential). Required if signing order is used. |
participants[].phone | string | No | Phone number (required if authenticationType is two-factor-authentication and twoFactorContact is sms). |
participants[].authenticationType | string | No | none, personal-password, or two-factor-authentication. Defaults to none. |
participants[].twoFactorContact | string | No | email or sms. Required if authenticationType is two-factor-authentication. |
participants[].personalPasswordQuestion | string | No | Security question (required if authenticationType is personal-password). |
participants[].personalPassword | string | No | Security answer (required if authenticationType is personal-password). |
Code Snippet
Use the following code snippet to create an eSign session from templates. Replace the placeholder values with your actual data.
const axios = require("axios");
const config = {
method: "post",
url: "https://public-api.sign.stewart.com/esign/create-from-templates",
headers: {
Authorization: "Bearer <accessToken>",
"Content-Type": "application/json",
},
data: {
templates: [
{
id: "b88e7650-eb03-4246-8f0f-2d40659c9158",
fields: [
{
id: "f3be5369-8670-4474-9644-db09ede40263",
text: "Standard Terms and Conditions apply.",
},
],
},
],
participants: [
{
email: "buyer@example.com",
firstName: "Jane",
lastName: "Smith",
roleId: "7dfcc661-8669-4189-a375-2d8c21bbf9b0",
primary: true,
order: 0,
authenticationType: "none",
},
{
email: "seller@example.com",
firstName: "John",
lastName: "Doe",
roleId: "a1b2c3d4-5678-90ab-cdef-1234567890ab",
primary: false,
order: 1,
authenticationType: "none",
},
],
},
};
axios(config)
.then(function (response) {
console.log("eSign session created from template:", response.data);
})
.catch(function (error) {
console.log(error.response?.data || error.message);
});
Successful Response
On success, the API returns the eSign and transaction IDs:
{
"esignId": "3d976a23-b865-4fcd-9165-ddc0aedaf614",
"transactionId": "4a976a23-b865-4fcd-9165-ddc0aedaf614"
}
Validation Rules
- Maximum 4 participants per transaction
- Exactly one participant must have
primary: true - Each participant's
roleIdmust be unique and match a role from the template - Each participant's
emailmust be unique - If
orderis provided on any participant, it must be sequential starting from 0 - Templates must be of type
esign
Error Responses
| Status | Reason |
|---|---|
400 Bad Request | Validation error (see detail field for specifics) |
401 Unauthorized | Invalid token or apiTemplatingEsign feature not enabled |
404 Not Found | Template not found with the provided ID |
Error Response Format
{
"detail": "participants[0].email is not a valid email address",
"error": "enl-api-400",
"message": "Bad request. Validation error.",
"help": "https://integration.sign.stewart.com/docs/troubleshooting/enl-api-400"
}
Steps to Execute the Code Snippet
- Create a new file named
create_from_templates.js. - Copy and paste the code snippet provided above into the new file.
- Replace
<accessToken>and the template/participant data with your actual values. - Save the file and open a terminal or command prompt.
- Navigate to the folder where you saved the
create_from_templates.jsfile. - Run the following command to execute the script:
node create_from_templates.js
If the request is successful, you'll see the eSign and transaction IDs displayed in the console. In case of an error, the error details will be displayed instead.
Additional Resources
- Get Template Details — Retrieve template roles and free-text fields before creating a session.
- API Reference
If you need further assistance or have questions, feel free to reach out to our support team.