Docs/APIs/PDF Merge

PDF Merge

Combine several PDFs into one

OperationalCredits 10 per callp50 1329msDocumentsStar

Overview

Merging uses the pdf-lib library. A new, empty document is created, and for each input in order every page is copied into it, bringing the page's content and the fonts and images it uses. Only pages are copied: document-level bookmarks and the source files' metadata are not carried into the result.

Input arrives one of two ways. A multipart request is read file by file in form order, and each part must contain a `%PDF-` header in its first kilobyte. Otherwise `urls` is read as a JSON array or a comma-separated string of http(s) links, downloaded one after another with a 10 MB limit each and a 20-second timeout; links must point to public hosts. Fewer than 2 or more than 10 PDFs returns 400. A file over 10 MB, a combined size over 25 MB, or a merge that would pass 500 pages returns 413. A password-protected file returns 400 naming that file, and nothing is merged.

`fileCount` is the number of inputs, `pageCount` the pages in the result, and `size` the byte length of the merged file. `pdfName` is a random file name, `downloadURL` a signed link to the stored copy, and `expires` the moment the link stops working, as Unix time in milliseconds, two days after the call. The PDF is not in the response body, so download it before then.

`sources` lists each input with its 1-based `index`, `name`, `pageCount`, and the `startPage` and `endPage` it occupies in the merged file. For URL inputs, `name` is the last segment of the URL path. On the Free plan `sources` is null.

Live Test PDF Merge API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

POSThttps://api.apiverve.com/v1/pdfmerge
curl -X POST https://api.apiverve.com/v1/pdfmerge \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "urls": [
    "https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/rotation.pdf",
    "https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/sizes.pdf"
  ]
}'

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
urlsOptionalarrayA JSON array of 2 to 10 public PDF URLs, merged in order; a comma- or newline-separated list also works. Or upload the PDFs as multipart files instead

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "pdfName": "a356acc9-c44f-4363-9cda-14ed160d5f5d.pdf",
    "fileCount": 2,
    "pageCount": 5,
    "size": 13539,
    "expires": 1792230036453,
    "downloadURL": "https://storage.googleapis.com/apiverve/APIData/pdfmerge/a356acc9-c44f-4363-9cda-14ed160d5f5d.pdf?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1792230036&Signature=R5%2B…",
    "sources": [
      {
        "index": 1,
        "name": "rotation.pdf",
        "pageCount": 2,
        "startPage": 1,
        "endPage": 2
      },
      {
        "index": 2,
        "name": "sizes.pdf",
        "pageCount": 3,
        "startPage": 3,
        "endPage": 5
      }
    ]
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
pdfNamestring"a356acc9-c44f-4363-9cda-14ed160d5f5d.pdf"File name of the merged PDF
fileCountnumber2Number of PDFs merged
pageCountnumber5Pages in the merged PDF
sizenumber13539Size of the merged PDF in bytes
expiresnumber1792230036453When the download link expires (Unix time in milliseconds)
downloadURLstring"https://storage.googleapis.com/apiverve/APIData/pdfmerge/a356acc9-c44f-4363-9cda-14ed160d5f5d.pdf?Go…"Signed link to download the merged PDF, valid for 2 days
sourcesPremiumarray[2]Each input file and the pages it occupies in the merged PDF
indexPremiumnumber1Position of the file in the request, from 1
namePremiumstring"rotation.pdf"File name of the input
pageCountPremiumnumber2Pages in this input
startPagePremiumnumber1First page of this input in the merged PDF
endPagePremiumnumber2Last page of this input in the merged PDF

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

Document Packets
Bundle a contract, its schedules and supporting documents into one PDF for signing or archiving.
Report Assembly
Join generated report sections, cover pages and appendices into a single deliverable.
Invoice Batches
Combine a customer's invoices or statements for the month into one file to send.
Application Uploads
Merge the separate scans a user uploads into one document before storing it.

Other ways to use PDF Merge

Set up PDF Merge on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →

More in Documents:

Was this page helpful?