apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Merge Multiple PDFs API

What it does

The Merge Multiple PDFs API combines several PDFs into one file. Send the PDFs as base64 strings or public URLs in a JSON body, and get back a single merged PDF. Files are joined in the order you list them.

Use pdf_urls for an array of public http or https links, or pdf_base64 for an array of base64-encoded PDFs. Send one of the two lists per request, not both. The whole request body must stay under 5 MB. Set filename to name the output, which defaults to merged.pdf.

Choose how the merge PDF base64 API returns the result with response_mode. binary returns the PDF file itself and is the default. base64 returns the file as a base64 string. json adds the file size and creation time. url returns a temporary download link with its expiry time.

Teams use it to combine invoices into one monthly statement. They also attach terms to generated contracts and bundle onboarding forms into one packet. As a merge PDF base64 API, it fits backends and serverless functions that never write files to disk.

Before merging, the Rotate PDF from URL API can fix sideways pages. After merging, the Extract PDF Content API reads the combined text.

AI agents can call it through ApyHub MCP.

POST
Merge multiple PDF documents
https://api.eu.apyhub.com/sarvasoft/merge-pdfs/pdf/merge

QUICKSTART

GUIDE

Quickstart

Merge a couple of public PDF files and return the result as a temporary download link.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/merge-pdfs/pdf/merge" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "merged.pdf",
    "pdf_urls": [
      "https://example.com/invoice-1.pdf",
      "https://example.com/invoice-2.pdf"
    ],
    "response_mode": "url"
  }'

What you'll get back

Returns a JSON object with the merged file and its metadata.

{
  "filename": "merged.pdf",
  "size": 1123,
  "created_at": "2026-01-15T10:30:00Z",
  "pdf_base64": "JVBERi0xLjcKJb/3ov4KMSAwIG9iago8PCAvVHlwZSAvT2JqU3RtIC9MZW5ndGggMjI5..."
}
TRY ITLIVE · 15 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
body*

About this endpoint

What it does

Merges several PDFs into one file. Send the PDFs as public URLs or Base64 in a JSON body, and pick how the merged file comes back.

Request Body

ParameterTypeDescription
pdf_urlsString ArrayRequired if pdf_base64 is not set. Public URLs of the PDFs to merge, in order. Each must be http or https. Max length 2083 characters per URL.
pdf_base64String ArrayRequired if pdf_urls is not set. Base64-encoded PDFs to merge, in order. Provide exactly one of pdf_urls or pdf_base64.
filenameStringName of the merged file. Default: merged.pdf. Max length 255 characters.
response_modeStringHow the merged PDF is returned. Allowed values: binary, base64, json, url. Default: binary.

Response

Returns the merged PDF in the shape set by response_mode. In json mode, returns a JSON object with the file and its metadata.

ParameterTypeDescription
filenameStringName of the merged PDF.
sizeIntegerSize of the merged PDF in bytes.
created_atStringUTC timestamp when the file was created.
pdf_base64StringBase64-encoded merged PDF.

Notes

  • Provide exactly one of pdf_urls or pdf_base64.
  • binary returns the PDF file itself, not JSON. base64 returns only filename and pdf_base64. url returns file_url, expires_at and expires_in_seconds. The link needs no authentication and stops working after it expires.
  • The request body must be under 5 MB. Larger bodies return 413.
  • PDFs are merged in the order they appear in the list.
  • If an item is not a readable PDF, is password-protected, or its URL cannot be loaded, it is currently left out of the merged file while at least one item is valid. Check the result if you need every input included.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.