Merge PDFs
Merge PDFs is an API that combines several PDFs into one, in the order you send them. Great for joining invoices, attachments or reports into a single file from n8n, Make or Zapier, with no servers to maintain.
How it works
You send two or more PDFs (base64-encoded, inside a JSON body) and get back a single PDF with every page from all of them, in the same order you sent them. Nothing is stored: the PDF is generated on the fly.
Unlike the other PDF tools, this one needs several files at once, so it only accepts a JSON body (there's no "paste the raw PDF" mode).
All you need
- Your API key. Create it in your dashboard with "+ Create key". It's shown only once, so copy and save it.
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream… all have one).
- Each PDF converted to base64 before sending it (see the step-by-step below).
The PDFs travel inside a JSON body, so all the files you merge together can't add up to more than about 4 MB combined. For bigger PDFs, shrink them first or merge in batches.
How to use it in n8n (step by step)
In the HTTP Request node:
- Method:
POST - URL:
https://api.cofferdock.com/pdf-merge - Send Headers: on → add two:
x-api-key= your key, andContent-Type=application/json - Send Body: on → Body Content Type: JSON →
{ "files": ["<first PDF base64>", "<second PDF base64>"], "output": "binary" } - Under Options → Response → Response Format: choose File (since you asked for
output: "binary")
If the PDF arrives as binary data from an earlier step (say, from Google Drive or an email), convert it to base64 with a Code node using {{'{{'}}$binary.data.toString('base64'){{'}}'}}, or with the Move Binary Data node in "Binary to Property" mode.
In Make (HTTP → Make a request module): same method and URL, Headers with the two headers, Body type: Raw, Content type: JSON (application/json), and the same JSON with the files array in Request content. Make's "Get a file" module already gives you base64 content directly.
In short: POST to …/pdf-merge, headers x-api-key and Content-Type: application/json, a JSON body with files (array of base64 PDFs) and output: "binary", Response Format as File.
Options (inside the JSON)
| Option | Default | What it does |
|---|---|---|
files | - | Required. Array of 2 to 20 base64 PDFs, in the order you want them merged. |
output | json | Set to binary to receive the PDF directly instead of base64. |
API overview
- Endpoint:
POST https://api.cofferdock.com/pdf-merge - Auth: header
x-api-key: YOUR_KEY. - Input:
application/jsonONLY:{ "files": ["<base64>", ...] }, 2 to 20 files. There's no raw mode (more than one file doesn't fit in it). - Output: JSON with the base64 PDF by default; with
"output": "binary"it returns the binary (application/pdf) directly. - Limits: the full JSON body (all base64 files together) is capped at 6 MB, meaning about 4 MB of real combined PDF across all files. 30 requests/min per IP. 1 merge = 1 credit, no matter how many files you combine.
Options
| Option | Default | Description |
|---|---|---|
files | - | Required. Array of 2 to 20 base64 strings. |
output | json | json (base64) or binary (raw PDF). |
Examples
curl (base64-encode two PDFs and merge them):
B64_1=$(base64 -w0 file1.pdf)
B64_2=$(base64 -w0 file2.pdf)
curl -X POST "https://api.cofferdock.com/pdf-merge" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d "{\"files\":[\"$B64_1\",\"$B64_2\"],\"output\":\"binary\"}" \
-o merged.pdf
JavaScript (Node 18+):
const fs = require('fs');
const files = ['file1.pdf', 'file2.pdf'].map((f) => fs.readFileSync(f).toString('base64'));
const r = await fetch('https://api.cofferdock.com/pdf-merge', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ files, output: 'binary' }),
});
const buffer = Buffer.from(await r.arrayBuffer());
fs.writeFileSync('merged.pdf', buffer);
Python:
import base64, requests
files = [base64.b64encode(open(f, 'rb').read()).decode() for f in ['file1.pdf', 'file2.pdf']]
r = requests.post(
'https://api.cofferdock.com/pdf-merge',
headers={'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json'},
json={'files': files, 'output': 'binary'},
)
open('merged.pdf', 'wb').write(r.content)
Default response (JSON with base64)
Without output, the response carries the merged PDF in base64:
{ "files": ["JVBERi0xLjQ…", "JVBERi0xLjQ…"] }
→ { "success": true, "pdf": "JVBERi0xLjQ…", "mime_type": "application/pdf",
"meta": { "files_merged": 2, "total_pages": 7, "used": 12, "remaining": 488 } }
What you get back
By default, a JSON object with the merged PDF in base64 plus data like the total page count. With "output": "binary" you get the PDF itself, ready to save or send.