Developer Guide

How to Sign PDFs with JavaScript

3 steps to sign a PDF with JavaScript: Install the TurboDocx SDK (npm install @turbodocx/sdk), configure TurboSign.configure() with your API key, org ID, and sender email, then call TurboSign.sendSignature() with the PDF file, recipients, and signature field placement. TurboDocx emails each recipient a signing link and returns a document ID you can poll or track by webhook.

This guide shows you how to integrate e-signatures into your Node.js or TypeScript application in under 5 minutes.

Last updated: September 23, 2026

5 min

Setup time

TypeScript

TypeScript

Full type support

Async/Await

Modern patterns

1

Installation

Install the TurboDocx SDK from npm. The package includes full TypeScript definitions.

npm / yarn / pnpm
npm install @turbodocx/sdk

Requirements: Node.js 18+ or modern browser. TypeScript 4.7+ optional for type checking.

2

Obtaining an API Key

Before you begin, you'll need your API credentials from the TurboDocx dashboard.

  1. Sign up for a free account at TurboDocx
  2. Navigate to Settings → API Keys
  3. Copy your API Key and Organization ID
.env
TURBODOCX_API_KEY=your_api_key_here
TURBODOCX_ORG_ID=your_org_id_here
TURBODOCX_SENDER_EMAIL=you@company.com
TURBODOCX_SENDER_NAME=Your Company Name
3

Sending a Signing Request

Use the SDK to send a document for signature. The recipient will receive an email with a link to sign.

send-signature.js
import { TurboSign } from '@turbodocx/sdk';
import { readFileSync } from 'fs';

// Configure with your API credentials
TurboSign.configure({
  apiKey: process.env.TURBODOCX_API_KEY,
  orgId: process.env.TURBODOCX_ORG_ID,
  senderEmail: process.env.TURBODOCX_SENDER_EMAIL,  // REQUIRED
  senderName: process.env.TURBODOCX_SENDER_NAME     // Recommended
});

// Read PDF file
const pdfBuffer = readFileSync('contract.pdf');

// Send document for signature
const result = await TurboSign.sendSignature({
  file: pdfBuffer,
  documentName: 'Partnership Agreement',
  recipients: [
    { name: 'John Doe', email: 'john@example.com', signingOrder: 1 }
  ],
  fields: [
    {
      type: 'signature',
      recipientEmail: 'john@example.com',
      template: {
        anchor: '{signature1}',
        placement: 'replace',
        size: { width: 100, height: 30 }
      }
    }
  ]
});

console.log('Document ID:', result.documentId);

Important: The senderEmail is required and will be used as the reply-to address for signature request emails.

4

Processing Results with Webhooks

Configure webhooks to receive real-time notifications when documents are signed. Verify the X-TurboDocx-Signature header with verifyWebhookSignature() before trusting a payload; it needs the raw request body, so mount the route with express.raw() instead of express.json().

webhook-handler.js
import express from 'express';
import { TurboSign, verifyWebhookSignature } from '@turbodocx/sdk';

const app = express();

// Raw body required for signature verification; a JSON body parser would rewrite the bytes
app.post('/webhooks/turbosign', express.raw({ type: 'application/json' }), async (req, res) => {
  const valid = verifyWebhookSignature(
    req.body,
    req.headers['x-turbodocx-signature'],
    req.headers['x-turbodocx-timestamp'],
    process.env.TURBODOCX_WEBHOOK_SECRET,
  );
  if (!valid) return res.status(401).json({ error: 'invalid signature' });

  const { event, data } = JSON.parse(req.body.toString());

  if (event === 'signature.document.completed') {
    console.log('Document signed:', data.document_id);

    // Download the signed PDF
    const signedPdf = await TurboSign.download(data.document_id);

    // Save to your storage
    await saveToStorage(signedPdf, `signed-${data.document_id}.pdf`);
  }

  res.status(200).json({ received: true });
});
5

Conclusion

You now have everything you need to integrate document signing into your JavaScript application using the TurboDocx e-signature API. It handles authentication, document delivery, signature collection, status webhooks, and legally-binding audit trails.

What you can do next:

  • Add multiple recipients with sequential signing order
  • Use different field types: initials, dates, text, checkboxes
  • Poll TurboSign.getStatus() or nudge outstanding signers with sendReminder()
  • Get audit trails and compliance certificates

Related Guides

Resources

Frequently Asked Questions

How do I sign a PDF with JavaScript?

To sign a PDF with JavaScript, install the TurboDocx SDK (npm install @turbodocx/sdk), configure it with your API key, then use TurboSign.sendSignature() to send the document for e-signature. The recipient receives an email with a signing link.

How do I integrate PDF signature status into a JavaScript app?

Poll TurboSign.getStatus(documentId) for on-demand checks, or verify the X-TurboDocx-Signature header on your webhook endpoint with verifyWebhookSignature() to get a push notification the moment a signature.document.completed event fires.

Is the TurboDocx JavaScript SDK free?

TurboDocx offers a free tier that includes API access and a limited number of signature requests per month. The JavaScript SDK itself is free and open source on GitHub.

Does the JavaScript SDK support TypeScript?

Yes, the TurboDocx JavaScript SDK includes full TypeScript definitions out of the box. No additional @types packages are needed.

Ready to Get Started?

Create a free account and get your API key. Start sending documents for signature in minutes.