Rotate PDF

Rotate PDF pages by specified angles with flexible per-page or global rotation options.

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

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

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

fileFile

The PDF file to rotate, 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 rotate.

Rotation Options (Strategy 1)

Use rotations map for different angles per page:

rotationsobjectOptional

Map of page numbers to rotation angles. Example: {'1': 90, '3': 180, '5': 270}

Rotation Options (Strategy 2)

Use angle with optional pages for uniform rotation:

anglenumberOptional

Rotation angle in degrees (e.g., 90, 180, 270). Can be any value.

pagesnumber[]Optional

Array of 1-based page numbers to rotate. If omitted, rotates all pages.

Rotation Behavior

  • Cumulative: Rotation is added to existing page rotation (90 + 90 = 180)
  • Normalization: Angles are normalized to 0-360 range automatically
  • Strategy priority: If both rotations and angle are provided, rotations takes precedence

Encrypted PDFs

Password-protected PDFs cannot be rotated. Use the Unlock PDF endpoint first to remove protection.

Query Parameters

formatstringOptionalDefault: json

Response format. Use 'binary' to receive the rotated 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 rotated PDF file.

downloadUrlstring

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

pagesRotatednumber

Number of pages that were rotated.

Error Responses

StatusCodeDescription
400INVALID_INPUTMissing file or invalid parameters
400PASSWORD_PROTECTEDCannot rotate password-protected PDF
413FILE_TOO_LARGEFile exceeds maximum size (50MB)
500PROCESSING_FAILEDRotation operation failed
POST/v1/pdf/rotate
curl -X POST "https://api.morphopdf.com/v1/pdf/rotate?format=binary" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@document.pdf" \
  -F "angle=90" \
  -F "pages=[1,3,5]" \
  --output rotated.pdf
200OK
{
  "success": true,
  "message": "File processed successfully",
  "fileName": "rotated.pdf",
  "downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/rotated.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
  "pagesRotated": 3
}