Developer Guide

How to Sign PDFs with JavaScript

To sign a PDF with JavaScript: Install the TurboDocx SDK (npm install @turbodocx/sdk), configure your API key, and call TurboSign.sendSignature() with your document and recipient details.

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

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.ts
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.

webhook-handler.ts
import express from 'express';

const app = express();
app.use(express.json());

app.post('/webhooks/turbosign', async (req, res) => {
  const { event_type, data } = req.body;

  if (event_type === 'document.completed') {
    console.log('Document signed:', data.documentId);

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

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

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

Conclusion

You now have everything you need to integrate document signing into your JavaScript application. The TurboDocx SDK handles authentication, document delivery, signature collection, and provides legally-binding audit trails.

What you can do next:

  • Add multiple recipients with sequential signing order
  • Use different field types: initials, dates, text, checkboxes
  • Embed signing directly in your app with iframe integration
  • 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.

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.