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.pdf

When 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

HeaderValue
Content-Typeapplication/pdf (or appropriate MIME type)
Content-Dispositionattachment; 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

FieldTypeDescription
successbooleanWhether the request succeeded
messagestringHuman-readable status message
fileNamestringName of the output file
downloadUrlstringPresigned URL to download the processed file