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
| Name | Type | Required | Description |
|---|---|---|---|
params.name | string | Yes | Template display name. |
params.files | array | No | Files that make up the template. Each needs name plus url or base64. |
params.recipients | array | No | Recipient placeholder definitions — { id, name }. |
params.fields | array | No | Field placement definitions. |
params.subject | string | No | Default email subject when sending documents from this template. |
params.message | string | No | Default email message. |
Returns
The created template object from the SignWell API.
Throws
[xSignwell] templates.create: params object is required— ifparamsis not an object.[xSignwell] templates.create: name (string) is required— ifnameis missing or not a string.- Re-throws SignWell API errors with
statusCodeandsignwellErrorproperties.
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
- templates.get — fetch a template after creation
- templates.update — update a template
- templates.list — list all templates
- documents.createFromTemplate — instantiate a document from a template
- bulk-send.create — send a template to many recipients at once
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
