fastify-x-signwell
documents.send / documents.remind / documents.delete
Send a draft document, remind unsigned recipients, or delete a document.
documents.send / documents.remind / documents.delete
Workflow operations on an existing document: send a draft, nudge unsigned recipients, or permanently delete.
Signatures
fastify.xsignwell.documents.send(
documentId: string,
params?: Record<string, unknown>
): Promise<Object>
fastify.xsignwell.documents.remind(
documentId: string
): Promise<Object>
fastify.xsignwell.documents.delete(
documentId: string
): Promise<Object>
// remove is an alias for delete
fastify.xsignwell.documents.remove(documentId: string): Promise<Object>
Params
send
| Name | Type | Required | Description |
|---|---|---|---|
documentId | string | Yes | ID of the draft document to send. |
params | object | No | Additional send options passed to the SignWell API. |
remind
| Name | Type | Required | Description |
|---|---|---|---|
documentId | string | Yes | ID of the document to send reminders for. |
delete / remove
| Name | Type | Required | Description |
|---|---|---|---|
documentId | string | Yes | ID of the document to delete. |
Returns
All three methods return the SignWell API response object for the operation.
Throws
[xSignwell] documents.send: documentId (string) is required— ifdocumentIdis missing.[xSignwell] documents.remind: documentId (string) is required— ifdocumentIdis missing.[xSignwell] documents.remove: documentId (string) is required— ifdocumentIdis missing.- Re-throws SignWell API errors with
statusCodeandsignwellErrorproperties.
Examples
send — send a draft document
const draft = await fastify.xsignwell.documents.create({
name: "Agreement",
recipients: [{ email: "client@example.com" }],
files: [{ name: "agreement.pdf", url: "https://cdn.example.com/agreement.pdf" }],
draft: true,
});
// Later, after review:
await fastify.xsignwell.documents.send(draft.id);
remind — nudge recipients
await fastify.xsignwell.documents.remind("doc_abc123");
// All unsigned recipients receive a reminder email
delete — remove a document
await fastify.xsignwell.documents.delete("doc_abc123");
// or equivalently:
await fastify.xsignwell.documents.remove("doc_abc123");
Realistic — automated expiry and reminder workflow
// Cron or scheduled job
async function processStaleDocuments() {
const pendingContracts = await db.contracts.findStale({ olderThanDays: 3 });
for (const contract of pendingContracts) {
if (contract.reminderCount < 3) {
await fastify.xsignwell.documents.remind(contract.documentId);
await db.contracts.incrementReminder(contract.id);
} else {
// Exceeded reminder limit — delete the document and mark expired
await fastify.xsignwell.documents.delete(contract.documentId);
await db.contracts.update(contract.id, { status: "expired" });
}
}
}
See also
- documents.create — create a document (with
draft: trueto usesend()later) - documents.get — check document status before reminding
- documents.getCompletedPdf — download after completion
AI Context
package: "@xenterprises/fastify-xsignwell"
methods: fastify.xsignwell.documents.send(documentId) | fastify.xsignwell.documents.remind(documentId, recipientId) | fastify.xsignwell.documents.delete(documentId)
use-when: send — send a draft document to recipients | remind — send a reminder to a specific signer | delete — permanently delete a document
