X Enterprises
fastify-x-signwell

xsignwell.templates.create

Create a new reusable SignWell document template with pre-placed fields and recipient placeholders.

xsignwell.templates.create

Create a new reusable SignWell document template. Templates define reusable documents with pre-placed signature, date, and text fields and named recipient placeholders.

Signature

fastify.xsignwell.templates.create(params: {
  name: string;
  files?: Array<{ name: string; url?: string; base64?: string }>;
  recipients?: Array<{ id: string; name?: string }>;
  fields?: Array<Record<string, unknown>>;
  subject?: string;
  message?: string;
}): Promise<Object>

Params

NameTypeRequiredDescription
params.namestringYesTemplate display name.
params.filesarrayNoFiles that make up the template. Each needs name plus url or base64.
params.recipientsarrayNoRecipient placeholder definitions — { id, name }.
params.fieldsarrayNoField placement definitions.
params.subjectstringNoDefault email subject when sending documents from this template.
params.messagestringNoDefault email message.

Returns

The created template object from the SignWell API.

Throws

  • [xSignwell] templates.create: params object is required — if params is not an object.
  • [xSignwell] templates.create: name (string) is required — if name is missing or not a string.
  • Re-throws SignWell API errors with statusCode and signwellError properties.

Examples

Create a template from a PDF URL

const template = await fastify.xsignwell.templates.create({
  name: "Service Agreement",
  files: [
    { name: "service_agreement.pdf", url: "https://cdn.example.com/sa.pdf" },
  ],
  recipients: [
    { id: "vendor", name: "Vendor" },
    { id: "customer", name: "Customer" },
  ],
  subject: "Please sign the service agreement",
});

console.log(template.id); // "tmpl_xyz789"

See also


AI Context

package: "@xenterprises/fastify-xsignwell"
method: fastify.xsignwell.templates.create(params)
use-when: Create a new reusable SignWell template with files, recipient placeholders, and pre-placed fields
params: name (required), files (array with name+url or name+base64), recipients (array with id+name), fields, subject, message
returns: The created template object
Copyright © 2026