PDF Remove Pages API - Delete Pages, Ranges, or Even/Odd from Any PDF
A scanned contract padded with blank separator pages, or a report still carrying its internal draft appendix, is not ready to send - and opening every file in a desktop editor does not scale. The PDF Remove Pages API deletes the pages you specify from any PDF through a single asynchronous REST request. Send individual page numbers, ascending ranges, or even/odd selections, and get back a rebuilt document containing only the pages you kept, with fonts, images, and layout untouched. Built for developers automating document intake, legal-ops preparation, and report distribution pipelines. Start with 10,000 free credits, no credit card required - credits are only charged on successful responses.
Where removal takes pages out, the PDF Split API keeps the pages you select and returns them as new files. Pick whichever selection is easier to describe.
Features
Flexible Page Selection with Keywords
The required pages parameter accepts individual page numbers, ascending ranges, and mixed lists like 1,3-5,10 in a single request. The keywords even and odd remove alternating pages on their own, and last combines with numbers or ranges (5-last, 1,last) to target the end of a document without knowing its length.
Use it to encode complex cleanup patterns - scattered blanks, trailing signature pages - in one call instead of several.
Asynchronous Processing
Every request returns a taskId immediately instead of holding the connection open while the document processes. Poll the task-status endpoint to track progress through queued, processing, and completed states, and use the inputIds in the response to reference your uploaded source file.
Use it to keep request threads free while large documents process in the background, no timeout tuning required.
Webhook Notifications with HMAC Verification
Add webhook_url to any request and the API POSTs the result to your endpoint the moment processing completes or fails. Delivery is attempted up to 3 times, a custom X-Webhook-Authorization header secures your receiver, and webhook_failure_notification sends an email alert if all retries fail. Verify every payload against the HMAC-SHA256 X-Signature header computed from the request body with your API key.
Use it for event-driven pipelines where documents must move the moment they are ready.
Clean Stored Files Without Re-Uploading
Pass a file_id instead of a multipart upload to remove pages from a file already on APIFreaks servers - the output of a previous merge, split, or upload call. Files are retained for up to 30 days depending on your plan, so multi-step pipelines never transfer the same bytes twice.
Use it to chain PDF operations without re-uploading large documents at every step.
1GB Payload per Request
Each request accepts a payload of up to 1GB, which covers scanned archives, image-heavy reports, and high-resolution print files. Combined with asynchronous processing, oversized documents run in the background with no connection-timeout risk on your side.
Use it to clean large batch scans straight from a document-intake pipeline instead of pre-processing them by hand.
Zero Data Retention on Request
Enable destroy and your input file is deleted immediately after the output is generated, instead of being held for the standard retention window - the response then returns only the taskId. File-status calls report creation and deletion timestamps, so you can audit exactly when data left the platform.
Use it for compliance-sensitive workloads (legal, healthcare, and financial documents) where storage minimization is a hard requirement rather than a preference.
No Quality Loss
The remaining pages keep the source document exactly as authored: fonts, embedded images, vector graphics, page dimensions, and layout carry over with no recompression and no downsampling. Page removal is a structural operation, not a re-render, so every kept page in the output is identical to the same page in the input.
Use it when output must stay print-ready or legally faithful: court filings, signed contracts, archival records.
Built for These Use Cases
Scan cleanup at document intake
Batch scanners insert blank separator pages and cover sheets that pollute every downstream system. One PDF page removal API call per document strips them at the intake boundary, before OCR, indexing, or archival ever sees them. The cleaned file flows on with its original quality intact.
Duplex scan correction
When a single-sided stack goes through a duplex scanner, every second page comes back blank. Delete the even or odd pages with one keyword instead of enumerating them, and run it as the delete PDF pages API step in your scan-processing queue.
Confidential page stripping in legal workflows
Remove internal notes, pricing exhibits, or privileged sections from executed documents before they leave the firm. If a file arrives encrypted, pass it through the Unlock PDF API first - page removal requires an unprotected PDF. What remains is a clean, shareable record.
Report sanitization before distribution
Finalized reports often still carry draft appendices, revision logs, or region-specific sections that only one audience should see. Remove them per recipient, then hand the output to the PDF Compress API to shrink it before email delivery or long-term storage.
API Endpoint
Utility & Resource APIs
Use these endpoints to manage files and check task status.
Task Status API
task_id. The response includes creation and expiry timestamps to help you track result availability, along with specific error details if a task fails. Results are retained for up to 7 days, depending on the operation.File Status API
file_id. Returns details including file name, size, type, and creation/deletion timestamps. Generated or uploaded files are retained up to 30 days based on user's plan, unless destroy is enabled to delete them immediately. You can use this endpoint to check if the file has expired using its file_id.File Download API
PDF Delete API
Files List API
File Upload API
multipart/form-data request. Each file receives a unique file_id that can be used with the PDF APIs.Upload Binary API
file_id for uses with the PDF APIs.All Endpoints
| Endpoint | Description | Credits | Reference | Playground |
|---|---|---|---|---|
| Delete PDF Page | Remove specific pages, ranges, or even/odd pages from a PDF. | 200 | Reference | Playground |
How-To-Guides
Removing Pages
A document that is mostly right, with a few pages that should not ship - that is the job this walkthrough automates end to end: upload the PDF and mark the pages to delete, poll the task status, and download the cleaned result. The same three steps sit behind any removal workflow you build; only the page selection changes.
Step 1: Upload and Remove Pages
Kick off the job by POSTing to /pdf/remove-pages. Attach the document as a multipart file field or reference a stored file_id, and pass the required pages selection - numbers, ascending ranges, or the even/odd/last keywords - everything a remove pages from PDF API call needs in one request. The response returns a taskId for tracking and inputIds confirming the source file that entered the job.
# Standard Response { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "inputIds": [ "7a9e4b12-f3c8-4d56-b7e1-8c2f9d0a3e6f" ] } # Response with destroy=true (No File IDs as they are deleted right away) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d" }curl -X POST "https://api.apifreaks.com/v1.0/pdf/remove-pages?pages=1,5,10&output=cleaned_document" \ -H "X-apikey: YOUR_API_KEY" \ -F "file=@/path/to/document.pdf"
Notes:
- The API accepts only one PDF file per request (multipart file takes priority over file_id)
- If your PDF is large, using the Upload Binary API ensures significantly faster transfer speeds
- The
pagesparameter is required and specifies which pages to remove - Only ascending page ranges are allowed (e.g., 3-7, not 7-3)
- Keywords “even” and “odd” must be used alone, not mixed with page numbers
- Only “last” keyword can be combined with specific pages or ranges
- Use the
destroy=trueparameter to delete input file after removal completes (returns onlytaskId) - File IDs must reference valid, active files stored on the API Freaks server. You can verify if a file is still available using the File Status API
Step 2: Check Task Status
The removal runs in the background, so your request thread is already free. Poll the Task Status API with your taskId until it reports completed. The response carries the output file reference you'll download in the next step, and a failed status carries the error details your retry logic needs - including Encrypted PDF Provided when a protected file must be unlocked before removal.
# Response (completed) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "status": "completed", "createdAt": "2025-01-26 10:30:00", "outputUrls": [ "https://api.apifreaks.com/v1.0/pdf/resource/download?resource_id=9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f" ], "outputFileId": [ "9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f" ], "inputIds": [ "7a9e4b12-f3c8-4d56-b7e1-8c2f9d0a3e6f" ], "expiresAt": "2025-01-27 10:30:00" }curl -X GET "https://api.apifreaks.com/v1.0/pdf/task-status?task_id=04a06cd5-158d-4191-a45b-6f58249c599d" \ -H "X-apikey: YOUR_API_KEY"
# Response (failed) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "status": "failed", "createdAt": "2025-01-26 10:30:00", "inputIds": [ "7a9e4b12-f3c8-4d56-b7e1-8c2f9d0a3e6f" ], "error": "Invalid PDF File", "message": "The provided file is not a valid PDF file.", "expiresAt": "2025-01-27 10:30:00" }curl -X GET "https://api.apifreaks.com/v1.0/pdf/task-status?task_id=04a06cd5-158d-4191-a45b-6f58249c599d" \ -H "X-apikey: YOUR_API_KEY"
Step 3: Download Cleaned PDF
Once the task status shows completed, fetch the cleaned document through the File Download API using the outputFileId from the task-status response. Store the ID instead of downloading if the next step is another PDF operation on the same file.
curl -X GET "https://api.apifreaks.com/v1.0/pdf/resource/download?resource_id=9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f" \ -H "X-apikey: YOUR_API_KEY" \ --output cleaned_document.pdf
Webhook Support
Polling wastes cycles when documents finish on their own schedule. Provide a webhook with your request and the API calls your endpoint the moment a task completes or fails, with an HMAC signature you can verify before trusting the payload.
Get automatic notifications when your task completes instead of polling the task status endpoint. Good for event-driven applications and real-time document processing.
Add webhook_url to your request. We'll send a POST request to this URL when the task finishes (either completed or failed).
See the Complete Webhook Example section below for a full demonstration including custom authorization headers.
Webhook Delivery
Webhook delivery will be attempted up to 3 times. If all retries fail and webhook_failure_notification is enabled, we'll send an email notification to the requesting user or their organization admin.
Custom Authorization Header
Use X-Webhook-Authorization to add a custom header to webhook requests for endpoint security.
Format: Key:Value
Example: If you send Authorization:Bearer token123, the webhook request will include: Authorization: Bearer token123
See the Complete Webhook Example below for a full demonstration.
Complete Webhook Example
Here's a complete example showing webhook integration with custom authorization header and failure notifications:
# Response { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "inputIds": [ "566dc743-d8fe-4943-8cef-61e5d3d6096c" ] }curl -X 'POST' \ 'https://api.apifreaks.com/v1.0/pdf/remove-pages?webhook_url=https://yourdomain.com/webhook/pdf-remove-pages&webhook_failure_notification=true' \ -H 'X-apiKey: YOUR_API_KEY' \ -H 'X-Webhook-Authorization: Authorization:Bearer token123' \ -F 'file=@/path/to/document.pdf'
Webhook Request Format
When your task completes, we send a POST request to your webhook_url with these headers:
| Header | Description |
|---|---|
Content-Type | Always application/json |
X-Signature | HMAC-SHA256 signature of the request body using your API key. Use this to verify the payload is authentic. |
| Custom Header | (If provided) Your custom header from X-Webhook-Authorization |
Webhook Response
The webhook payload contains the same response structure as the Task Status API endpoint when checked for the task ID.
Verifying Webhook Authenticity
Use the X-Signature header to verify webhook requests actually came from API Freaks and weren't tampered with.
How the signature works:
- We compute an HMAC-SHA256 hash of the request body using your API key as the secret
- We Base64-encode the result
- We send this as the
X-Signatureheader value
To verify the webhook:
- Take the raw payload body (JSON string exactly as received without parsing it)
- Compute HMAC-SHA256 of the payload using your API key as the secret
- Base64-encode the result of the hash
- Compare with the
X-Signatureheader value
Important: Don't transform or process the raw request body before verification. Adding whitespace or other formatting creates a different signature and verification will fail.
Frequently Asked Questions
5), ascending ranges (3-7), and comma-separated combinations (1,3-5,10). The keywords even and odd must be sent on their own, while last combines with numbers and ranges (5-last or 1,last). Unlike the split endpoint, all is not supported - removing every page would leave an empty document.Encrypted PDF Provided error. Remove the password first - the Unlock PDF API returns an unprotected copy - then send that file's file_id to the remove-pages endpoint.taskId immediately. Poll the task-status endpoint until the status is completed, then download the output through the file-download endpoint using the returned outputFileId - or skip polling entirely by passing webhook_url and receiving the same payload when the task finishes.destroy=true and the input file is wiped immediately after the output is generated; the response then contains only the taskId, with no stored file IDs. Without it, files are retained for up to 30 days depending on your plan.Pricing
To use this API, API credits are required. Charges apply only for successful queries, defined by a 2xx status code. If a request results in a 4xx or 5xx status code, no credits will be deducted, and any credits already charged will be refunded. In the event of a Task Processing Error, a maximum of 200 credits will be refunded. Surcharges for additional file sizes are non-refundable.
For each successful request, 200 credits will be charged. 1 extra credit will be charged per MB beyond 50 MB.
Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.