Skip to main content

Create a REST API for PDF digital signatures with webhooks

Workflow preview

Workflow preview
100%
Create a REST API for PDF digital signatures with webhooks preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

An automation workflow that creates a complete REST API for digitally signing PDF documents using n8n webhooks. This service demonstrates how to implement secure document signing functionality thro...

Best for

  • Document Extraction automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.switch, n8n-nodes-base.converttofile, n8n-nodes-base.readwritefile, n8n-nodes-base.if, n8n-nodes-base.webhook, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Ferenc Erb.

Original n8n.io source

1.1 Workflow description

Title
Create a REST API for PDF digital signatures with webhooks
Workflow name
Create a REST API for PDF digital signatures with webhooks

Overview

An automation workflow that creates a complete REST API for digitally signing PDF documents using n8n webhooks. This service demonstrates how to implement secure document signing functionality through standardized API endpoints with file upload and download capabilities.

Use Case

This workflow is designed for developers and automation specialists who need to implement digital document signing. It's particularly useful for:

  • Integrating PDF signing capabilities into existing document workflows
  • API-based automation of signature processes
  • Creating proof-of-concept implementations for document verification systems
  • Learning n8n's webhook capabilities and file handling techniques
  • Testing PDF signing in development environments before production implementation

What This Workflow Does

API-Based Document Management

  • Exposes RESTful webhook endpoints for all document operations
  • Handles multipart/form-data uploads for PDF documents
  • Processes JSON payloads for signing configuration
  • Provides download functionality for completed documents

Digital Certificate Handling

  • Uploads existing PFX/PKCS#12 digital certificates
  • Generates new certificates with customizable attributes
  • Securely manages certificate storage and access
  • Associates certificates with signing operations

Cryptographic PDF Signing

  • Applies digital signatures using industry-standard cryptographic methods
  • Embeds signature information within PDF document structure
  • Validates document integrity through cryptographic verification
  • Preserves original document while adding signature elements

Webhook Integration System

  • Routes different API methods to appropriate handlers
  • Validates request payloads and file content
  • Manages authentication through webhook paths
  • Returns structured responses for integration with other systems

Technical Architecture

Components

  1. API Gateway: n8n webhook nodes that receive external requests
  2. Request Router: Switch nodes that direct operations based on method parameters
  3. Document Processor: Function nodes for PDF manipulation and verification
  4. Certificate Manager: Specialized nodes for cryptographic key operations
  5. Storage Interface: File operation nodes for document persistence
  6. Response Formatter: Nodes that structure API responses

Integration Flow

Client Request → Webhook Endpoint → Method Router → 
Processing Engine → Digital Signing → Storage → 
Response Generation → Client Response

Setup Instructions

Prerequisites

  • n8n installation (minimum version 0.214.0)
  • Node.js 14 or higher
  • Required environment variable:
    NODE_FUNCTION_ALLOW_EXTERNAL: "node-forge,@signpdf/signpdf,@signpdf/signer-p12,@signpdf/placeholder-plain"
    

Configuration Steps

  1. Import Workflow

    • Import the workflow JSON into your n8n instance
    • Activate the workflow to enable the webhooks
  2. Configure Storage

    • Set the storage path variables in the workflow
    • Ensure proper permissions on the storage directories
  3. Test API Endpoints

    • Use the included test scripts to verify functionality
    • Test PDF upload, certificate generation, and signing
  4. Integration

    • Document the webhook URLs for integration with other systems
    • Configure error handling according to your requirements

Testing Methods

Test the workflow functionality using various HTTP requests and JSON data:

  • Upload PDF documents to the document processing endpoint
  • Upload or generate digital certificates
  • Execute PDF signing operations
  • Download signed documents from the download endpoint

Webhook Endpoints

The workflow exposes two primary webhook endpoints that form a complete API for PDF digital signing operations:

1. Document Processing Endpoint (/webhook/docu-digi-sign)

This endpoint handles all document and certificate operations:

Method: Upload PDF

  • HTTP: POST
  • Content-Type: multipart/form-data
  • Parameters: method, uploadType, fileName, fileData

Method: Upload Certificate

  • HTTP: POST
  • Content-Type: multipart/form-data
  • Parameters: method, uploadType, fileName, fileData

Method: Generate Certificate

  • HTTP: POST
  • Content-Type: application/json
  • Parameters: method, subjectCN, issuerCN, serialNumber, validFrom, validTo, password

Method: Sign PDF

  • HTTP: POST
  • Content-Type: application/json
  • Parameters: method, inputPdf, pfxFile, pfxPassword

2. Document Download Endpoint (/webhook/docu-download)

This endpoint handles the retrieval of processed documents:

Method: Download Signed PDF

  • HTTP: GET
  • Content-Type: application/json
  • Parameters: method, fileType, fileName

Key Workflow Sections

The workflow is organized into logical sections with clear responsibilities:

  • Request Processing: Parses incoming webhook data
  • Method Routing: Directs requests to appropriate handlers
  • Document Management: Handles file operations and storage
  • Cryptographic Operations: Manages signing and certificate functions
  • Response Formatting: Structures and returns results

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Validate Key Gen Params

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 2 - Validate PDF Sign Params

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 3 - Validate PDF Upload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 4 - Validate Key Upload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 5 - Generate Keys

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 6 - Sign PDF

Type / Role
n8n-nodes-base.code - code
Config choices
Version 1

Block 7 - Prepare Success Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 1

Block 8 - Switch Operation

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 9 - Switch Upload Type

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 10 - Prepare input params

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 11 - set file path

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 12 - Convert PDF to File

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 13 - Write PDF File to Disk

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 14 - Read PDF File from Disk

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 15 - Convert PFX to File

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 16 - Write PFX File to Disk

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 17 - Read PFX File from Disk

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 18 - Check PDF file is OK

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Check PFX file is OK

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 20 - check success

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 21 - set downlowd file info

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 22 - Read download file from Disk

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 23 - API POST Endpoint

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 1

Block 24 - API GET Endpoint

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Showing the first 24 of 32 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Create a REST API for PDF digital signatures with webhooks
Complexity advanced
Nodes 32
Categories Document Extraction
Author Ferenc Erb
Published 10 Mar 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3119/3119.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create a REST API for PDF digital signatures with webhooks do?

An automation workflow that creates a complete REST API for digitally signing PDF documents using n8n webhooks. This service demonstrates how to implement secure document signing functionality thro...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction use case.