Merge PDF
Combine multiple PDF files into a single document.
https://api.morphopdf.com/v1/pdf/mergeAuthentication
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.
urlstringSingle public URL pointing to a PDF file. Can be combined with 'files' parameter.
Query Parameters
formatstringOptionalDefault: jsonResponse 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):
successbooleanIndicates whether the operation completed successfully.
messagestringHuman-readable status message.
fileNamestringName of the merged PDF file.
downloadUrlstringPresigned URL to download the merged file. Valid for 1 hour.
filesMergednumberNumber of files that were merged.
Binary Response
Add ?format=binary to receive the merged PDF file directly with these headers:
Content-Type: application/pdfContent-Disposition: attachment; filename="merged.pdf"X-FileCount: Number of files merged
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INSUFFICIENT_FILES | At least 2 PDF files are required |
| 400 | INVALID_PDF | One of the files is not a valid PDF |
| 400 | INVALID_URL | URL is not accessible or not a valid PDF |
| 401 | AUTHENTICATION_REQUIRED | Missing or invalid API key |
| 413 | FILE_TOO_LARGE | File exceeds maximum size (50MB) |
| 500 | MERGE_FAILED | Internal processing error |
/v1/pdf/mergecurl -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{
"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
}