Organize PDF
Reorder, remove, or rotate pages within a PDF document.
https://api.morphopdf.com/v1/pdf/organizeAuthentication
Retrieve your API Key from Dashboard.
Request Body
One input source is required (file, fileBase64, or url).
fileFileThe PDF file to organize, uploaded via multipart/form-data.
fileBase64stringBase64-encoded PDF content as an alternative to file upload.
urlstringPublic URL of PDF file to fetch and organize.
Organization Options
newPageOrdernumber[]Array of 1-based page numbers in the desired order. Omit page numbers to remove them from the output.
rotatedPagesnumber[]OptionalArray of 1-based page numbers to rotate 90 degrees clockwise.
Usage Tips
- Reorder pages: Specify page numbers in the new sequence (e.g., [3, 1, 2])
- Remove pages: Simply omit them from newPageOrder
- Rotate pages: Add page numbers to rotatedPages array
Array Format
For multipart form data, pass arrays as JSON strings (e.g., '[3, 1, 2]'). For JSON request body, pass them as native arrays.
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the organized PDF file directly, or 'json' (default) to receive metadata with a download URL.
Response
When using format=json (default):
successbooleanIndicates whether the operation completed successfully.
messagestringHuman-readable status message.
fileNamestringName of the organized PDF file.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pagesReorderednumberNumber of pages in the reordered document.
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_PDF | Invalid or missing PDF file |
| 400 | INVALID_PAGE_ORDER | newPageOrder is required and must be an array |
| 400 | INVALID_PAGE_NUMBERS | Page numbers out of range |
| 413 | FILE_TOO_LARGE | File exceeds maximum size (50MB) |
| 500 | ORGANIZE_FAILED | Internal processing error |
/v1/pdf/organizecurl -X POST "https://api.morphopdf.com/v1/pdf/organize?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "newPageOrder=[3,1,2]" \
--output organized.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "organized.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/organized.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pagesReordered": 5
}