Skip to main content

PDF Tools API

Merge PDF API

Combine multiple PDFs into one ordered document from your backend, batch job, or product workflow without building PDF merge infrastructure.

Credits

1 Credit / call

1 Credit per successful API request. Failed processing attempts are refunded automatically.

Pricing

1,000 Credits = $1

Every signed-in user receives 100 free API Credits each month.

Endpoint

/api/external/pdf-tools/merge-pdf

Use your API Key in the x-api-key header.

cURL example

curl -X POST https://itextmaster.com/api/external/pdf-tools/merge-pdf \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@first.pdf;type=application/pdf' \
  -F 'file=@second.pdf;type=application/pdf' \
  -F 'options={}' \
  --output merged.pdf

Node.js example

import { writeFile } from 'node:fs/promises';

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/merge-pdf', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.ITEXTMASTER_API_KEY
  },
  body: JSON.stringify({
  files: [
    { name: 'input.pdf', dataBase64: 'JVBERi0xLjcK...' }
  ],
  options: {}
})
});

if (!response.ok) {
  throw new Error(await response.text());
}

await writeFile('merged.pdf', Buffer.from(await response.arrayBuffer()));

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/merge-pdf',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'files': [
            {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'}
        ],
        'options': {}
    },
)
response.raise_for_status()

with open('merged.pdf', 'wb') as f:
    f.write(response.content)

Error codes

401invalid_api_key

The x-api-key header is missing, invalid, or has been rotated.

402insufficient_credits

The account does not have enough API Credits for the request.

422pdf_tool_processing_failed

The file, options, or PDF structure could not be processed.

Limits

  • Requires two or more valid PDF files.
  • Password-protected PDFs should be unlocked before calling the endpoint.
  • Very large batches should be split into smaller requests.

Example output

merged.pdf with X-Credits-Charged: 1 and X-Credit-Balance response headers.

X-Credits-Charged: 1

X-Credit-Balance: 99

Content-Disposition: attachment; filename="merged.pdf"

FAQ

How much does the Merge PDF API cost?

Each successful Merge PDF API request uses 1 Credit. 1,000 Credits cost $1, and every signed-in user receives 100 free API Credits each month.

Can I control file order?

Yes. Send files in the order you want them to appear in the merged output.

What happens if merging fails?

Failed processing attempts are refunded automatically, and the API returns an error response you can log or retry.

Start with 100 free API Credits

Create an API Key, test Merge PDF API, and buy more Credits only when automation volume grows.