The PDFGate API provides a collection of simple HTTP endpoints for working with PDF files. You can generate PDFs from HTML or URLs, create fillable form fields, flatten or extract data from existing PDFs, and apply watermarks or security settings. Each endpoint is designed to be fast, reliable, and easy to integrate into your applications.
All API requests to PDFGate must be authenticated using an API key. Authentication is handled via the Authorization header in your HTTP requests.
To get started, log in to your PDFGate account and create an API key from the Settings page in the dashboard. Ensure the key is active before using it in your code.
Include the API key in your request headers like this:
Authorization: Bearer YOUR_API_KEYPDFGate supports two types of API keys:
Use sandbox keys for testing purposes and production keys in your live environment.
The PDFGate API uses different rate limits for each account type in the production environment. In the sandbox environment, the rate limits are the same for all account types.
| Endpoint | Production | Sandbox |
|---|---|---|
POST /v1/generate/pdf POST /forms/flatten POST /forms/extract-data POST /watermark/pdf POST /protect/pdf POST /compress/pdf | Per account type:
| Per account type:
|
GET /document | 40 concurrent requests | 10 concurrent requests |
GET /file | 40 concurrent requests | 10 concurrent requests |
| Code | Error |
|---|---|
| 400 | Bad request |
| 401 | Unauthorized |
| 404 | Not found |
| 422 | Unprocessable entity |
| 429 | Too many requests |
| 500 | Internal server error |
The Generate PDF endpoint converts HTML content into a PDF document. You can provide the content either as a publicly accessible URL or as raw HTML in the request body.
By default, the endpoint returns the generated PDF as a binary file. If you prefer a JSON response, you can include the jsonResponse field in your request.
Endpoint
Examples
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
--request POST \
--data '{"pageSizeType":"a4","url":"https://en.wikipedia.org/wiki/PDF"}' \
https://api.pdfgate.com/v1/generate/pdf \
-o output.pdf
Request body fields
"1-5" or "1,3,5". If not specified, all pages are included.Available responses
The Flatten PDF endpoint converts an interactive PDF (with fillable form fields or annotations) into a static, non-editable version.
documentId referencing an existing file already stored in our database.If a documentId is provided, the API will always create a new flattened file in the database, rather than overwriting the existing one.
In this case, the response includes a derivedFrom parameter (when jsonResponse is set to true), it indicates the original document ID from which the flattened file was created.
Endpoint
Examples
curl -X POST "https://api.pdfgate.com/forms/flatten" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@YOUR_FILE.pdf" \
-F "jsonResponse=false" \
-F "metadata={\"author\":\"John Doe\",\"documentType\":\"Contract\"}" \
--output flattened.pdf
Request body fields
.pdfAvailable responses
The Extract PDF Form Data endpoint lets you read data from a fillable PDF. It extracts all form fields in the document along with their current values and returns them as a JSON object.
You can either upload a new PDF file directly or provide the documentId of an existing file stored on the server.
Endpoint
Examples
curl -X POST "https://api.pdfgate.com/forms/extract-data" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@YOUR_FILE.pdf"
Request body fields
.pdfAvailable responses
The Watermark PDF endpoint adds a watermark to an existing PDF document. You can apply either a text watermark or an image watermark, depending on your needs.
Endpoint
Examples
curl -X POST "https://api.pdfgate.com/watermark/pdf" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@YOUR_FILE.pdf" \
-F "type=text" \
-F 'text=My watermark!' \
-F 'fontColor=rgb(156, 50, 168)' \
-F "rotate=30" \
-F "opacity=0.2" \
--output watermarked.pdf
Request body fields
.pdf.png .jpeg .jpg.ttf .otffontFile is provided, this parameter will be ignored.Available responses
The Protect PDF endpoint secures a PDF document by applying password protection and permission restrictions.
You can encrypt the PDF using AES-128 or AES-256, set user and owner passwords, and control which actions are allowed, such as printing, copying, or editing.
Endpoint
Examples
curl -X POST "https://api.pdfgate.com/protect/pdf" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@YOUR_FILE.pdf" \
-F "ownerPassword=ownerPassword" \
-F "userPassword=userPassword" \
-F "disablePrint=true" \
-F "disableCopy=true" \
-F "disableEditing=true" \
--output protected.pdf
Request body fields
.pdfAvailable responses
The Compress PDF endpoint reduces the file size of a PDF without changing its visual appearance. You can also enable linearization so the first page loads faster when the PDF is opened over a network.
Note:
In the sandbox environment, the compression result may be limited because our watermark image is automatically added to the document. As a result, the file size will be increased. We recommend testing this endpoint in the production environment.
Endpoint
Examples
curl -X POST "https://api.pdfgate.com/compress/pdf" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@YOUR_FILE.pdf" \
-F "linearize=true" \
--output compressed.pdf
Request body fields
.pdfAvailable responses
Retrieves a generated document object containing metadata and file details.
Endpoint
Examples
curl --header "Authorization: Bearer YOUR_API_KEY" \
--request GET \
https://api.pdfgate.com/document/{documentId}Request query fields
Response
Retrieves a raw PDF file previously generated.
Note: To access a generated file, the “Save files for one month” option must be enabled in your Dashboard's settings. This option is disabled by default.
Endpoint
Examples
curl -L -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.pdfgate.com/file/{documentId}" > output.pdf
Response