Start converting and processing PDFs in minutes with our simple API. This guide walks you through your first API call.
The PDFen API allows you to convert documents to PDF, merge PDFs, add OCR, compress files, and more. This guide will walk you through making your first API call in just 5 minutes.
Which API version should I use?
Use API v2 for all new projects. It's simpler, faster, and has better features. API v1 will be deprecated on June 1, 2026.
First, you need an API token for authentication. Tokens are more secure than passwords and can be easily revoked.
Security Warning
Never share your API token or commit it to version control. Store it in environment variables.
Every conversion requires a workflow_id. This is an integer that tells the API what type of conversion to perform.
Use the workflows endpoint to see all available workflows:
curl https://pdfen.com/api/v2/user/workflows \
-H "Authorization: Bearer YOUR_API_TOKEN"
The response includes system_workflows (available to all users) and user_workflows (your custom workflows). Each workflow has an id field โ use that as workflow_id in your convert requests.
| Workflow name | Description |
|---|---|
| Word to PDF | Convert DOCX/DOC files to PDF |
| Excel to PDF | Convert XLSX/XLS files to PDF |
| PowerPoint to PDF | Convert PPTX/PPT files to PDF |
| Merge PDFs | Merge multiple PDF files into one |
| Compress PDF | Reduce PDF file size |
| OCR PDF | Add text layer to scanned PDFs |
| Convert Email to PDF | Convert EML/MSG files to PDF |
| PDF to Word | Convert PDF to DOCX |
Workflow IDs are dynamic
Workflow IDs may differ between environments. Always use GET /api/v2/user/workflows to discover the correct ID instead of hardcoding.
Let's convert a Word document to PDF. We'll use the /api/v2/convert endpoint with a workflow_id from the previous step.
curl -X POST https://pdfen.com/api/v2/convert \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "files[]=@document.docx" \
-F "workflow_id=1" \
-F "async=true"
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://pdfen.com/api/v2/convert',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN'
],
CURLOPT_POSTFIELDS => [
'files[]' => new CURLFile('document.docx'),
'workflow_id' => 1,
'async' => 'true'
]
]);
$response = curl_exec($curl);
$result = json_decode($response, true);
echo "Execution ID: " . $result['execution_id'] . "\n";
echo "Status: " . $result['status'] . "\n";
echo "Download URL: " . $result['download_url'] . "\n";
import requests
url = 'https://pdfen.com/api/v2/convert'
headers = {'Authorization': 'Bearer YOUR_API_TOKEN'}
files = {'files[]': open('document.docx', 'rb')}
data = {
'workflow_id': 1,
'async': 'true'
}
response = requests.post(url, headers=headers, files=files, data=data)
result = response.json()
print(f"Execution ID: {result['execution_id']}")
print(f"Status: {result['status']}")
print(f"Download URL: {result['download_url']}")
{
"execution_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"credits_charged": 1,
"credits_remaining": 99,
"estimated_completion": "2025-01-15T10:30:00Z",
"status_url": "https://pdfen.com/api/v2/executions/550e8400-e29b-41d4-a716-446655440000",
"download_url": "https://pdfen.com/api/v2/executions/550e8400-e29b-41d4-a716-446655440000/download"
}
If you chose async processing, you need to poll the status endpoint to check when it's done.
curl https://pdfen.com/api/v2/executions/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_API_TOKEN"
{
"execution_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"progress": 75,
"current_step": "Converting page 3 of 4"
}
{
"execution_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "done",
"output_file_type": "pdf",
"output_file_size": 245678,
"total_pages": 4,
"completed_at": "2025-01-15T10:30:15Z",
"download_url": "https://pdfen.com/api/v2/executions/550e8400-e29b-41d4-a716-446655440000/download"
}
Once the status is done, you can download the converted PDF.
curl https://pdfen.com/api/v2/executions/550e8400-e29b-41d4-a716-446655440000/download \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-o converted.pdf
<?php
$downloadUrl = $result['download_url'];
$token = 'YOUR_API_TOKEN';
$ch = curl_init($downloadUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $token"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$pdfContent = curl_exec($ch);
file_put_contents('converted.pdf', $pdfContent);
echo "PDF saved to converted.pdf";
Learn about token management, security best practices, and rate limits.
Explore common scenarios like bulk conversion, OCR, compression, and more.
Tips for error handling, performance optimization, and production deployment.
Complete API documentation with all endpoints, parameters, and responses.