Organize PDF

Reorder, remove, or rotate pages within a PDF document.

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

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

One input source is required (file, fileBase64, or url).

fileFile

The PDF file to organize, uploaded via multipart/form-data.

fileBase64string

Base64-encoded PDF content as an alternative to file upload.

urlstring

Public 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[]Optional

Array 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: json

Response 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):

successboolean

Indicates whether the operation completed successfully.

messagestring

Human-readable status message.

fileNamestring

Name of the organized PDF file.

downloadUrlstring

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

pagesReorderednumber

Number of pages in the reordered document.

Error Responses

StatusCodeDescription
400INVALID_PDFInvalid or missing PDF file
400INVALID_PAGE_ORDERnewPageOrder is required and must be an array
400INVALID_PAGE_NUMBERSPage numbers out of range
413FILE_TOO_LARGEFile exceeds maximum size (50MB)
500ORGANIZE_FAILEDInternal processing error
POST/v1/pdf/organize
curl -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
200OK
{
  "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
}