Loading
Loading
Our PDF Split and Extract Pages API enables you to divide PDF files into multiple documents or pull specific pages through simple REST endpoints. Whether you're splitting a hundred-page report into chapters, extracting key pages from contracts, or separating invoices into individual pages, our API handles it all while maintaining the original quality. Define custom page ranges, use special keywords like “even” or “odd”, or extract exactly the pages you need in a single request. The API preserves all fonts, images, formatting, and document structure without compression or quality loss.
Perfect for document management systems, invoice processing platforms, legal document automation, and content management solutions. Separate bulk scanned documents into individual files, extract signature pages from contracts, divide multi-page invoices for accounting systems, or pull specific chapters from reports. With asynchronous request processing and webhook support, you can seamlessly integrate PDF operations into your automation pipelines.
If you don't want to poll for task status, you can simply provide the webhook data in your request. Instead of manually checking status, we will automatically notify your endpoint the moment the task processing is completed.
destroy parameter, your files are permanently wiped from our servers immediately after processing finishes, ensuring complete data security. If destroy is not set, files are retained up to 30 days based on user's plan.Split documents exactly where you need. Define multiple custom page ranges (e.g., "1-5", "10-15") in a single request to generate specific sub-documents instantly. Each range creates its own PDF file from your source document.
Extract only the pages you need from any PDF. Pull specific pages or ranges from a master file and save them as a new, clean PDF document. Perfect for creating subsets of large documents or isolating important sections.
Split PDFs or extract pages using individual numbers, ranges, or special keywords. Use "even" for even pages, "odd" for odd pages, "all" to split every page, or "last" to reference the final page. Mix page numbers and ranges in any order like "1-5,10,15-last" for complete control.
Break PDF files into single pages effortlessly. Use the "all" keyword to split PDF into individual pages or extract custom page ranges as separate files. Perfect for processing bulk scanned documents or separating multi-page files.
Extract multiple non-consecutive pages or different sections in a single API call. Process complex patterns like "1,5,10-15,20,25-last" efficiently without making multiple requests. Perfect for automated document workflows.
We keep your original document's quality. All things like fonts, pictures, and vector graphics, and the look do not change from original file. No compressing, downgrading, and you do not lose quality.
Handle heavy documents and high-resolution assets with ease. Our API supports a massive 1GB payload size per request, allowing you to process even the largest PDF files without worrying about size restrictions.
Extract specific pages or Split your PDF into separate files instantly.
$ pip install requestsimport requests
url = "https://api.apifreaks.com/v1.0/pdf/split?pages=1-5&output=split_document"
payload = {}
files=[
('file',('file.pdf',open('/path/to/file.pdf','rb'),'application/pdf'))
]
headers = {
'X-apiKey': 'API-KEY'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
$ pip install requestsimport requests
url = "https://api.apifreaks.com/v1.0/pdf/extract-pages?pages=1%2C5%2C10-15&output=extracted_pages"
payload = {}
files=[
('file',('file.pdf',open('/path/to/file.pdf','rb'),'application/pdf'))
]
headers = {
'X-apiKey': 'API-KEY'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Use these endpoints to manage files and check task status.
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_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.multipart/form-data request. Each file receives a unique file_id that can be used with the PDF APIs.file_id for uses with the PDF APIs.Follow these steps to split PDF files using the API. The process involves uploading files, checking the task status, and downloading the result.
Split PDFs into multiple documents by providing a file directly or referencing a file_id of a stored file. Define custom page ranges to break the PDF exactly where you need.
# 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/split?pages=1-5&pages=10-15&pages=20-last&output=split_document" \ -H "X-apikey: YOUR_API_KEY" \ -F "file=@/path/to/document.pdf"
Notes:
pages parameters create multiple output filespages=all to split PDF into individual pagesdestroy=true parameter to delete input file after split completes (returns only taskId)After submitting a split task, check its progress using the Task Status API with your taskId. The task goes through these statuses: queued, processing, completed, and failed.
# 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" } # 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"
Once the task status shows “completed”, download your split PDFs using the File Download API with the outputFileId from the task status response. When multiple outputs are generated, the response includes multiple file IDs in the outputFileId array. Download each file separately using its respective ID.
curl -X GET "true?resource_id=9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f" \ -H "X-apikey: YOUR_API_KEY" \ --output split_document.pdf
Extract specific pages from a PDF by providing a file directly or referencing a file_id of a stored file. Specify custom page ranges, individual page numbers, or special keywords for flexible extraction.
Upload your PDF and specify the pages to extract. After submitting, follow the same Step 2: Check Task Status and Step 3: Download Split PDFs described above to check task status and download your extracted pages.
# 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/extract-pages?pages=1,5,10-15,20&output=extracted_pages" \ -H "X-apikey: YOUR_API_KEY" \ -F "file=@/path/to/document.pdf"
Notes:
pages parameter is required and defines which pages to extract.separated=false (default), all extracted pages are combined into one PDF and for separated=true, each page is saved as an individual PDF in a ZIP file.destroy=true parameter to delete input file after extraction completes (returns only taskId).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_urlto 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 will be attempted up to 3 times. If all retries fail and webhook_failure_notificationis enabled, we'll send an email notification to the requesting user or their organization admin.
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.
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/split?webhook_url=https://yourdomain.com/webhook/pdf-split&webhook_failure_notification=true' \ -H 'X-apiKey: YOUR_API_KEY' \ -H 'X-Webhook-Authorization: Authorization:Bearer token123' \ -F 'file=@/path/to/document.pdf'
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 |
The webhook payload contains the same response structure as the Task Status API endpoint when checked for the task ID.
Use the X-Signatureheader to verify webhook requests actually came from API Freaks and weren't tampered with.
How the signature works:
X-Signature header valueTo verify the webhook:
X-Signature header valueImportant:Don't transform or process the raw request body before verification. Adding whitespace or other formatting creates a different signature and verification will fail.
To use this PDF Split & Extract Pages APIs, 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.