Skip to main content

Merge PDFs with the API

Combine multiple existing PDFs into one document. Send publicly accessible HTTPS URLs or Base64-encoded files in the required order, and receive the merged PDF or a temporary download link. Merge reports with their attachments or combine multiple invoices into one PDF.

Try it in the Playground

Upload PDFs or add PDF URLs, arrange them in the order you need, and merge them without writing code.

Try in Playground

Endpoints​

MethodEndpointSuccessful response
POST/v1/tools/merge/directPDF bytes with Content-Type: application/pdf
POST/v1/tools/merge/syncJSON with result metadata and a download URL when using default storage

Both endpoints wait for merging to complete before responding.

Authentication​

Use a conversion API key in the API-KEY header.

API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Find your key on the API Credentials page in your Dashboard.

Merge PDFs from URLs​

The examples combine two sample PDFs and save the result as merged.pdf. Replace the sample URLs with direct HTTPS URLs to your files. PDFs are merged in the order listed in inputs.

The examples use the Direct endpoint. To receive a download URL, replace /direct with /sync and read the response as JSON. The documentUrl field contains the download URL.

{
"inputs": [
{"url": "https://pdfbolt.com/samples/merge-sample-1.pdf"},
{"url": "https://pdfbolt.com/samples/merge-sample-2.pdf"}
]
}

Merge Local PDF Files​

Encode each PDF as Base64 and use the encoded data in the inputs[].pdf fields shown below, without the data:application/pdf;base64, prefix.

{
"inputs": [
{"pdf": "BASE64_FIRST_PDF"},
{"pdf": "BASE64_SECOND_PDF"}
]
}

Request Parameters​

Set the Content-Type header to application/json.

inputs​

Type: array of objects

Required: Yes

Details: An array of 2–20 PDF sources in merge order. Each item must contain either url or pdf, not both. You can mix both source types in the same request. All pages from each source are included.

Usage:

{
"inputs": [
{"url": "https://pdfbolt.com/samples/merge-sample-1.pdf"},
{"pdf": "BASE64_SECOND_PDF"}
]
}

inputs[].url​

Type: string

Required: Yes, if pdf is omitted from the same item

Details: Direct, publicly accessible HTTPS URL of the input PDF. Maximum length: 2,048 characters.

URLs must not contain credentials or fragments such as #page=2. Redirects and private network addresses are not supported. Custom headers cannot be supplied when fetching the PDF.

inputs[].pdf​

Type: string

Required: Yes, if url is omitted from the same item

Details: Base64-encoded contents of the input PDF, without the data:application/pdf;base64, prefix.

filename​

Type: string

Required: No

Default Value: merge.pdf

Details: Output PDF filename in the Content-Disposition header. Maximum 255 characters. Allowed characters: A–Z, a–z, 0–9, ., _, and -. Provide the filename with or without the .pdf extension.

contentDisposition​

Type: string

Required: No

Default Value: inline

Details: Specifies whether the browser should display or download the PDF.

  • "inline": Display the PDF in the browser, if supported.
  • "attachment": Prompt a download.

Usage:

{
"inputs": [
{"url": "https://pdfbolt.com/samples/merge-sample-1.pdf"},
{"url": "https://pdfbolt.com/samples/merge-sample-2.pdf"}
],
"filename": "combined-report.pdf",
"contentDisposition": "attachment"
}

customS3PresignedUrl​

Type: string

Required: No

Details: Uploads the merged PDF to your S3-compatible bucket using an HTTPS pre-signed PUT URL. Available only with /v1/tools/merge/sync on paid plans. Maximum 2048 characters.

The URL must remain valid until the upload completes. On success, isCustomS3Bucket is true, and documentUrl and expiresAt are null. Omit this parameter to use PDFBolt's temporary storage.

See Uploading to Your S3 Bucket for setup details.

Usage:

{
"inputs": [
{"url": "https://pdfbolt.com/samples/merge-sample-1.pdf"},
{"url": "https://pdfbolt.com/samples/merge-sample-2.pdf"}
],
"filename": "combined-report.pdf",
"contentDisposition": "attachment",
"customS3PresignedUrl": "https://your-bucket.s3.amazonaws.com/combined-report.pdf?<presigned-query-params>"
}

Successful Response​

The response format depends on the endpoint.

Returns HTTP 200 with the merged PDF in the response body.

Content-Type: application/pdf

Save the response body as a PDF file. The result is not stored for later download.

Failure Response​

If any input fails validation or cannot be downloaded, the entire request fails. No partial PDF is returned and no credits are charged. Check errorCode and errorMessage for details before retrying.

HTTP statusCommon causeAction
400Invalid parameters, fewer than 2 or more than 20 inputs, an inaccessible URL or PDF download timeout, or an encrypted or invalid PDF.Check errorMessage and correct the input or settings.
400Custom S3 upload failed (CUSTOM_S3_UPLOAD_ERROR, Sync only).Check the pre-signed URL and upload permissions.
413The combined input PDFs, request body, or output PDF exceeds its size limit.Reduce the combined file size or request size.
See Limits and Credits.
422Processing exceeded its time limit (CONVERSION_TIMEOUT).Use smaller or less complex PDFs.

Input errors may include inputs[index] to identify the affected PDF.

Example validation error:

{
"timestamp": "2026-11-04T10:00:00Z",
"httpErrorCode": 400,
"errorCode": "BAD_REQUEST",
"errorMessage": "Expected 2-20 PDF files."
}

See Error Handling for the error response format and other common errors.

Limits and Credits​

LimitValue
Input files per request2–20 PDFs
Combined input PDF size100 MB

Encrypted, empty, and invalid PDFs are rejected. On the Free API plan, the output PDF is limited to 2 MB.

Successful merges cost one credit per started 5 MB of output. Failed operations consume no credits.

Requests share your account's rate limits. The x-pdfbolt-conversion-cost response header reports the credits charged.