Skip to content

Node.js SDK

The @insigner/node SDK provides a typed client for the inSigner Cloud API with built-in error handling, automatic pagination, and TypeScript support.

Terminal window
npm install @insigner/node
import { InSigner } from '@insigner/node';
const client = new InSigner({
apiKey: process.env.INSIGNER_API_KEY! // isk_...
});
// Create and send a document
const doc = await client.documents.create({
name: 'Sales Agreement Q3',
signingType: 'sequential'
});
// Upload PDF
await client.documents.upload(doc.id, {
file: './sales-agreement.pdf'
});
// Add signers
await client.documents.addSigner(doc.id, {
email: 'jane@acme.com',
name: 'Jane Smith',
role: 'signer',
order: 0
});
// Add fields
await client.documents.addField(doc.id, {
type: 'signature',
label: 'Client Signature',
page: 1,
x: 100, y: 650,
width: 200, height: 60
});
// Send for signing
await client.documents.send(doc.id);

Until the SDK is released, use the REST API directly:

const INSIGNER_API = 'https://app.insigner.co/api/v1';
const API_KEY = process.env.INSIGNER_API_KEY;
async function insignerFetch(path: string, options: RequestInit = {}) {
const res = await fetch(`${INSIGNER_API}${path}`, {
...options,
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
...options.headers,
},
});
if (!res.ok) {
const error = await res.json();
throw new Error(`${error.title}: ${error.detail}`);
}
if (res.status === 204) return null;
return res.json();
}
// Example: List documents
const { data, meta } = await insignerFetch('/documents?limit=10');
// Example: Create a document
const { data: doc } = await insignerFetch('/documents', {
method: 'POST',
body: JSON.stringify({ name: 'My Document' }),
});
try {
await client.documents.send('invalid-id');
} catch (error) {
if (error instanceof InSignerError) {
console.error(`${error.status}: ${error.detail}`);
// Handle specific error types
if (error.type === 'https://docs.insigner.com/errors/not-found') {
console.error('Document not found');
}
}
}
// Auto-paginate through all documents
for await (const doc of client.documents.list({ status: 'completed' })) {
console.log(doc.name);
}
// Or get a single page
const page = await client.documents.list({
limit: 10,
cursor: 'cm5x9abc123'
});
console.log(page.data, page.meta);