apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Rotate PDF by Degrees API

What it does

The Rotate PDF API turns sideways or upside-down pages the right way up. Send a PDF as a public pdf_url or a pdf_base64 string, choose an angle, and get the rotated PDF back in one call.

Set degrees to 90, 180 or 270. A value of 0 or 360 leaves pages unchanged, and 0 is the default. To rotate only some pages, pass page_numbers as a list of 1-based page numbers. Leave it out to rotate every page. Use filename to name the output file.

Choose how the file comes back with response_mode. The default, binary, returns raw bytes. Use base64 for an encoded string, or url for a temporary link. Use json to get the file with its name, size in bytes and creation time.

Teams use the Rotate PDF API to fix scanned documents that arrive sideways. It also corrects one page inside a longer packet, and sets page orientation before OCR, storage or merging.

The API rotates pages only. It does not resize, crop, compress or edit page content. An angle outside the allowed values, such as 45, or a page number outside the document returns a 422 error.

If you don't know which pages are sideways, the PDF Orientation API finds and fixes them with OCR. After rotating, combine files with the Merge Files to PDF API.

AI agents can call it through ApyHub MCP.

POST
Rotate pages within a PDF
https://api.eu.apyhub.com/sarvasoft/rotate-pdf-by-degrees

QUICKSTART

GUIDE

Quickstart

Rotate every page of a PDF by 90 degrees and get the file back as JSON.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/rotate-pdf-by-degrees" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pdf_url":"https://assets.apyhub.com/samples/sample.pdf","degrees":90,"response_mode":"json"}'

What you'll get back

Returns a JSON object with the rotated file and its metadata.

{
  "filename": "rotated.pdf",
  "size": 675,
  "created_at": "2026-11-20T07:52:44Z",
  "pdf_base64": "JVBERi0xLjMKJb/3ov4KMSAwIG9iago8PCAvUGFnZXMgMiAwIFI..."
}
TRY ITLIVE · 7 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Rotation angle in degrees. 0 and 360 leave pages unchanged.
Public URL of the source PDF. Required if pdf_base64 is not set. Must be http or https. Provide exactly one of pdf_url or pdf_base64.
Suggested name for the output file.

About this endpoint

What it does

Rotates all pages in a PDF, or only the pages you choose. Send the PDF as a public URL or Base64 in a JSON body, set the angle, and pick how the file comes back.

Request Body

ParameterTypeDescription
pdf_urlStringRequired if pdf_base64 is not set. Public URL of the source PDF. Must be http or https.
pdf_base64StringRequired if pdf_url is not set. Base64-encoded PDF. Provide exactly one of pdf_url or pdf_base64.
degreesIntegerRotation angle. Allowed values: 0, 90, 180, 270, 360. 0 and 360 leave pages unchanged. Default: 0.
page_numbersInteger Array1-based page numbers to rotate. Omit to rotate every page.
filenameStringSuggested name for the output file.
response_modeStringHow the rotated PDF is returned. Allowed values: binary, base64, json, url. Default: binary.

Response

Returns the rotated PDF in the shape set by response_mode. In json mode, returns a JSON object with the file and its metadata.

ParameterTypeDescription
filenameStringName of the rotated PDF.
sizeIntegerSize of the rotated PDF in bytes.
created_atStringUTC timestamp when the file was created.
pdf_base64StringBase64-encoded rotated PDF.

Notes

  • Provide exactly one of pdf_url or pdf_base64. Sending neither returns a 422 error.
  • page_numbers must be within the document. Out-of-range values, 0, and negatives return a 422 error.
  • degrees must be one of the allowed values. Other numbers (for example 45) return a 422 error.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.