Response Formats
The API supports two response formats: Binary and JSON.
Binary Response (Recommended)
Add ?format=binary to the URL to receive the processed file directly.
bash
curl -X POST "https://api.morphopdf.com/v1/pdf/merge?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "files=@doc1.pdf" \
-F "files=@doc2.pdf" \
--output merged.pdfWhen to use Binary
Use binary format when you want to save or stream the file directly without a second download step. This is more efficient for most use cases.
Response Headers
| Header | Value |
|---|---|
Content-Type | application/pdf (or appropriate MIME type) |
Content-Disposition | attachment; filename="output.pdf" |
JSON Response (Default)
Without the format parameter, the API returns a JSON response with a download URL.
Response
{
"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
}Download URL
The downloadUrl is a presigned URL valid for 1 hour. Make a GET request to download the file directly.
Common Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the request succeeded |
message | string | Human-readable status message |
fileName | string | Name of the output file |
downloadUrl | string | Presigned URL to download the processed file |