Merge PDF

Combine multiple PDF files into a single document.

POSThttps://api.morphopdf.com/v1/pdf/merge

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

At least one input source is required. Minimum 2 PDF files total.

filesFile[]

Multiple PDF files uploaded via multipart/form-data. Use field name 'files' for each file.

filesobject[]

Array of Base64-encoded file objects. Each object should contain 'content' (base64 string) and 'originalName' (filename).

urlsstring[]

Array of publicly accessible URLs pointing to PDF files.

urlstring

Single public URL pointing to a PDF file. Can be combined with 'files' parameter.

Query Parameters

formatstringOptionalDefault: json

Response format. Use 'binary' to receive the merged PDF file directly, or 'json' (default) to receive metadata with a download URL.

URL Requirements

URLs must be publicly accessible, use http:// or https://, max 50MB per file, 30s timeout. Private IPs (localhost, 192.168.x.x, 10.x.x.x) are blocked for security.

Response

When using format=json (default):

successboolean

Indicates whether the operation completed successfully.

messagestring

Human-readable status message.

fileNamestring

Name of the merged PDF file.

downloadUrlstring

Presigned URL to download the merged file. Valid for 1 hour.

filesMergednumber

Number of files that were merged.

Binary Response

Add ?format=binary to receive the merged PDF file directly with these headers:

  • Content-Type: application/pdf
  • Content-Disposition: attachment; filename="merged.pdf"
  • X-FileCount: Number of files merged

Error Responses

StatusCodeDescription
400INSUFFICIENT_FILESAt least 2 PDF files are required
400INVALID_PDFOne of the files is not a valid PDF
400INVALID_URLURL is not accessible or not a valid PDF
401AUTHENTICATION_REQUIREDMissing or invalid API key
413FILE_TOO_LARGEFile exceeds maximum size (50MB)
500MERGE_FAILEDInternal processing error
POST/v1/pdf/merge
curl -X POST "https://api.morphopdf.com/v1/pdf/merge?format=binary" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "files=@chapter1.pdf" \
  -F "files=@chapter2.pdf" \
  -F "files=@chapter3.pdf" \
  --output merged-book.pdf
200OK
{
  "success": true,
  "message": "File processed successfully",
  "fileName": "merged.pdf",
  "downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/merged.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
  "filesMerged": 3
}