Skip to main content

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 apiTemplatingEsign feature to be enabled for your organization. Contact Stewart Sign support if you receive a 401 Unauthorized response.

Requirements

  1. You need to have Node.js installed on your system.
  2. You'll also need the axios library. You can install it using the following command:
npm install axios
  1. A valid Bearer token (JWT) for authentication.
  2. 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

FieldTypeRequiredDescription
templatesarrayYesList of templates to use. Each template has an id and optional fields.
templates[].idstring (UUID)YesThe template ID.
templates[].fieldsarrayNoFree-text field values for document generation. Each field has an id and text.
participantsarrayYesList of participants (max 4). Each participant must be assigned a role from the template.
participants[].emailstringYesParticipant's email address (must be unique).
participants[].firstNamestringYesParticipant's first name.
participants[].lastNamestringYesParticipant's last name.
participants[].roleIdstring (UUID)YesThe role ID from the template (must be unique per participant).
participants[].primarybooleanYesExactly one participant must be marked as primary: true.
participants[].ordernumberNoSigning order (0-based, sequential). Required if signing order is used.
participants[].phonestringNoPhone number (required if authenticationType is two-factor-authentication and twoFactorContact is sms).
participants[].authenticationTypestringNonone, personal-password, or two-factor-authentication. Defaults to none.
participants[].twoFactorContactstringNoemail or sms. Required if authenticationType is two-factor-authentication.
participants[].personalPasswordQuestionstringNoSecurity question (required if authenticationType is personal-password).
participants[].personalPasswordstringNoSecurity 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 roleId must be unique and match a role from the template
  • Each participant's email must be unique
  • If order is provided on any participant, it must be sequential starting from 0
  • Templates must be of type esign

Error Responses

StatusReason
400 Bad RequestValidation error (see detail field for specifics)
401 UnauthorizedInvalid token or apiTemplatingEsign feature not enabled
404 Not FoundTemplate 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

  1. Create a new file named create_from_templates.js.
  2. Copy and paste the code snippet provided above into the new file.
  3. Replace <accessToken> and the template/participant data with your actual values.
  4. Save the file and open a terminal or command prompt.
  5. Navigate to the folder where you saved the create_from_templates.js file.
  6. 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

If you need further assistance or have questions, feel free to reach out to our support team.