API Documentation
WebPDF API provides you the tools to manipulate PDF files. Each API endpoint costs a fixed amount of credits regardless of how many files or how big are the files you send. For more details about the cost please check this section. The latest stable version is V1. Let's get started and see how you can consume the API!
# Authentication
To get starter you need to create an API token. This is a Bearer token and you will have to provide it to any API request you are executing via the Authorization
header.
curl -X GET https://webpdf.xyz/api/v1/credits \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}"
# Responses
Here is a list of the different categories of status codes returned by the WebPDF API. Use these to understand if a request was successful or not.
-
- 200
-
A 200 status code indicates a successful response.
-
- 401
-
A 401 status code indicates the request is unauthorized. This is most likely because the token is invalid or it is missing.
-
- 422
-
A 422 status code indicates the request validation fails. The response contains all the necesary information on why this is happening.
-
- 404
-
A 404 status code indicates the route you are calling doesn't exist.
-
- 500
-
A 5xx status code indicates a server error — you won't be seeing these hopefully.
Please note that the server will return a 200 response even if a file or a multiple files were not processed at all or if there are other issue related to your account.
When the HTTP response is 200, you can also check for the status
param in the response. It can have one of the following values:
-
- 2000
-
Everything is fine.
-
- 4010
-
One or multiple files couldn't be be processed.
-
- 4030
-
Insufficient credit balance. No files will be processed.
-
- 4050
-
Outstanding payment. Make sure all of your outstanding invoices are paid. No files will be processed.
{
"status": 2000,
"message": "",
"data": {
"files": [],
"job_id": null
}
}
{
"status": 4030,
"message": "Not enought credits to perform this request. Please top up!",
"data": {}
}
# Async
Sometimes you don't want to wait for a response from our servers. This will happen most likely when you are sending large files and you are performing heavy tasks. To overcome that, any endpoint that accepts a POST
request also accepts the async
body parameter, which can be a boolean true
/ 1
or false
/ 0
.
If you decide to set async
to true
or 1
the initial server response will contain a job_id
. You can use this ID to interogate our system and get the job results via the Get Job API call.
-
- async
- boolean
-
Determines if the client should wait for the server response or not.
{
"status": 2000,
"message": "",
"data": {
"files": [],
"job_id": "3e191379-e740-4907-9abc-95695fdc0511"
}
}
# Callback URL
We ping you back whenever a job is done. You can still poll our Job Get endpoint, but that's not ideal because you are limitted on how many requests you can send per minute based on you subscription plan. So it is better to wait for us to ping you back. You can also use the Callback URL in conjuction with Async.
Your callback URL must accept POST requests. For security reasons you can also add an unique query string to your callback URL (not mandatory). We'll use that whenever we ping you back.
Once you process the request sent by us, you can use the Job Get endpoint to fetch the results of the job.
Parameters sent by our system
-
- job_id
- string
-
The job ID.
Credit Balance
Get your credit balance, credit renew date and subscription status.
{
"status": 2000,
"message": "",
"data": {
"credit": 100,
"credit_renew_date": "2024-02-01 10:20:00",
"subscription": {
"active": true,
"plan": "Pro Plan"
}
}
}
Credit Usage
Get details usage of your credits.
Query parameters
-
- page
- integer
-
Determines what page should pe retrieved.
{
"status": 2000,
"message": "",
"data": {
"current_page": 1,
"total_pages": 5,
"total_result": 100,
"usage": [
{
"amount": -1,
"reason": "[API] Performed 'change-version' request",
"timestamp": "2023-12-25 09:10:00"
},
{
"amount": -5,
"reason": "[Web] OCR PDF",
"timestamp": "2023-12-25 09:11:00"
},
// ...
]
}
}
Job Status
Get the status of a job.
Query parameters
-
- job_id
- string (UUID)
-
The job's UUID that you want to fetch the data for. You receive a job ID whenever you create an async task. More info here here.
Job statuses
-
- pending
-
The job is still waiting to be picked up by our workers.
-
- processing
-
The job is being worked on.
-
- fail
-
The job failed. Used credits will be refunded.
-
- success
-
The job finished successfully.
Job types
-
- change-version
-
- compress
-
- convert-to-image
-
- copy-paste-protect
-
- extract-images
-
- extract-metadata
-
- extract-text
-
- flatten-annotations
-
- flatten-forms
-
- grayscale
-
- images-dpi
-
- ocr
-
- merge
-
- protect
-
- remove-pages
-
- rescale
-
- rotate
-
- split
-
- unlock
-
- watermark
-
- web-optimize
{
"status": 2000,
"message": "",
"data": {
"job_id": "ed21f485-ed30-4ac5-96e1-22f59a1668b2",
"job_status": "success",
"job_type": "compress",
}
}
Job Results
Get the results of a job.
Query parameters
-
- job_id
- string (UUID)
-
The job's UUID that you want to fetch the data for. You receive a job ID whenever you create an async task. More info here here.
{
"status": 2000,
"message": "",
"data": {
"job_id": "ed21f485-ed30-4ac5-96e1-22f59a1668b2",
"job_status": "success",
"job_type": "compress",
"job_response": {
files: [
{
filename: "example-2.pdf",
content: "" // base64 encoded file content
}
// ..
],
// This will be empty
output: ""
}
}
}
{
"status": 2000,
"message": "",
"data": {
"job_id": "ed21f485-ed30-4ac5-96e1-22f59a1668b2",
"job_status": "success",
"job_type": "compress",
"job_response": {
files: [
{
filename: "example-1.pdf",
files: [
{
filename: 'example.png',
content: "" // base64 encoded file content
}
],
},
// ...
],
// This will be empty
output: ""
}
}
}
{
"status": 2000,
"message": "",
"data": {
"job_id": "ed21f485-ed30-4ac5-96e1-22f59a1668b2",
"job_status": "success",
"job_type": "compress",
"job_response": {
// This will be empty
files: [],
// Output can be object when `extract-metadata`
output: "some text"
}
}
}
Change images DPI
multipart/form-data
Change images DPI inside a PDF file.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- dpi
- integer
-
Min
1
. Max1200
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/change-images-dpi \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "dpi=250"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Change version
multipart/form-data
Changes PDF file version.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- version
- string
-
Accepted values:
1.0
,1.1
,1.2
,1.3
,1.4
,1.5
,1.6
,1.7
,2.0
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/change-version \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "version=2.0"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Compress
multipart/form-data
Compress PDF files to reduce their size.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- quality
- integer
-
Accepted values:
1
,2
,3
,4
where 1 = highest quality.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/compress \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "quality=2" \
-F "grayscale=1"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Convert to image
multipart/form-data
Convert PDF image to image.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- format
- string
-
Accepted values:
jpg
,png
,bmp
,tiff
.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/convert-to-image \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "format=png" \
-F "horizontal=0"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Copy & paste protect
multipart/form-data
Protect a PDF file against copy & paste by turning text pages into images.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/copy-paste-protect \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Extract images
multipart/form-data
Extract images from any PDF file.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/extract-images \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"files": [
{
"filename": "001.png",
"content": "" // base64 encoded image
},
{
"filename": "002.png",
"content": "" // base64 encoded image
},
]
}
// ...
],
"job_id": null
}
}
Extract metadata
multipart/form-data
Extract metadata from any PDF file.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/extract-metadata \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"metadata": {
"creationdate": "",
"creator": "",
"keywords": "",
"producer": "",
"title": "",
"pages": "",
"version": "",
"author": "",
"moddate": "",
// other metadata
}
}
// ...
],
"job_id": null
}
}
Extract text
multipart/form-data
Extract text from any PDF file.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/extract-text \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"text": "here is the content"
}
// ...
],
"job_id": null
}
}
Flatten Forms
multipart/form-data
Flatten PDF forms. Turn PDFs with editable forms into readonly.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/flatten-forms \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Flatten Forms
multipart/form-data
Flatten PDF annotations. Turn PDFs with editable annotations into readonly.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/flatten-annotations \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Grayscale
multipart/form-data
Turn PDF into grayscale.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/grayscale \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
OCR
multipart/form-data
Image based PDF to text.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
-
- languages
- string
-
Makes it easier for our OCR system to detect the language. Accepts a single language or groups. For example if you know the document is written in English you can pass
eng
or if you know the document is written in English and French you can passend+fra
-
- async
- boolean
-
Determines if the files should be processed async. More info here.
-
- callback_url
- string
-
Must start with
https://
and resolve to a valid URL. More info here.
curl -X POST https://webpdf.xyz/api/v1/pdf/ocr \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Merge
multipart/form-data
Merge multiple PDFs into one.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/merge \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "merged.pdf",
"content": "" // base64 encoded file content
}
],
"job_id": null
}
}
Protect
multipart/form-data
Protect PDF by adding a owner and user password.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- owner_password
- string
-
- user_password
- string
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/protect \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "owner_password=secretpass" \
-F "user_password=helloworld"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Remove pages
multipart/form-data
Remove pages from PDFs.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- pages
- string
-
You can pass multiple pages separated by comma and also page ranges separate by a dash. Example
1,3,5-8,10
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/remove-pages \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "pages=1,3,5-8,10"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Rescale
multipart/form-data
Change PDF's page size.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- width
- integer
-
- height
- integer
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/rescale \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "width=1000" \
-F "height=500"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Rotate
multipart/form-data
Fix page orientation. If the PDF is image based, it will pass through the OCR filter.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/rotate \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Split
multipart/form-data
Split PDF into multiple PDFs.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- pages_per_file
- integer
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/split \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "pages_per_file=2"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"files": [
[
"filename": "pages-1-3-example.pdf",
"content": "" // base64 encoded file content
],
[
"filename": "pages-4-6-example.pdf",
"content": "" // base64 encoded file content
]
// other files
]
},
// other files
],
"job_id": null
}
}
Unlock
multipart/form-data
Unlock password protect PDF. Must not have a user password.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- owner_password
- string
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/unlock \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "owner_password=mysecretpassword"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Watermark
multipart/form-data
Add text watermark on all PDF pages.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
-
- text
- string
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/watermark \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf" \
-F "text=WebPDF"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}
Web optimize
multipart/form-data
Optimize PDF for faster web browser rendering.
Required parameters
-
- files
- array
-
Can contain multiple PDF files content. Minimum 1 file. The maximum number of files and the maximum size for each file is determined by your subscription plan.
Optional parameters
curl -X POST https://webpdf.xyz/api/v1/pdf/web-optimize \
-H "Accept: application/json" \
-H "Authorization: Bearer your_api_token" \
-F "files[]=@path/to/example1.pdf" \
-F "files[]=@path/to/example2.pdf"
{
"status": 2000,
"message": "",
"data": {
"files": [
{
"filename": "example.pdf",
"content": "" // base64 encoded file content
},
// other files
],
"job_id": null
}
}