// api reference

Merge PDFs API

Combine multiple PDF documents into a single file. Great for stitching invoices, reports, and attachments together in one automated step.

How it works

Every PDF tool runs as a small CustomJS function using our built-in pdfUtils. Write a few lines of JavaScript, deploy once, and you get a private API endpoint you can call from anywhere. Make.com, n8n, or plain curl.

01

Paste the function below into the editor at app.customjs.space.

02

Set the Response Type to PDF and deploy.

03

Call your function URL with the x-api-key header.

The CustomJS function

Import PDF_MERGE from ./utils and return its result. Remember to set the function's Response Type · PDF

const { PDF_MERGE } = require('./utils');

const pdfInputs = [...(input.urls || []), ...(input.files || [])].filter(Boolean);

return PDF_MERGE(pdfInputs);

Calling your endpoint

POST to your function URL. Pass the source PDF either as a public URL or a Base64 string. The request payload is capped at 6 MB.

Request body

FieldTypeDescription
urlsstring[]Array of public PDF URLs, merged in order. Combine with files if needed.
filesstring[]Array of Base64-encoded PDFs (total payload max 6 MB).

Example. Source from a URL

curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "urls": [
      "https://css4.pub/2017/newsletter/drylab.pdf",
      "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
  }' --output merged.pdf

Example. Source as Base64

curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "files": [
      "JVBERi0x..........EyNzg3CiUlRU9GCg==",
      "JVBERi0x..........EyNzg3CiUlRU9GCg=="
    ]
  }' --output merged.pdf

Other PDF tools

// try it first

Prefer to play before you code?

Open the interactive playground on the product page. Generate PDFs live, tweak the code, and copy the generated curl or SDK snippet straight into your stack.

merge-pdfs.curl
curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "urls": [
      "https://css4.pub/2017/newsletter/drylab.pdf",
      "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
  }' --output merged.pdf

600 free operations / month · no credit card

Frequently Asked Questions