Getting Started with PDFen API

Start converting and processing PDFs in minutes with our simple API. This guide walks you through your first API call.

Overview

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.

Step 1: Get Your API Token

First, you need an API token for authentication. Tokens are more secure than passwords and can be easily revoked.

How to generate a token:

  1. Log in to your PDFen account
  2. Go to Profile โ†’ API Tokens
  3. Click "Create New Token"
  4. Give it a name (e.g., "Production API")
  5. Copy the token - it's only shown once!

Security Warning

Never share your API token or commit it to version control. Store it in environment variables.

Step 1b: Find Your Workflow ID

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.

Common system workflows

Workflow name Description
Word to PDFConvert DOCX/DOC files to PDF
Excel to PDFConvert XLSX/XLS files to PDF
PowerPoint to PDFConvert PPTX/PPT files to PDF
Merge PDFsMerge multiple PDF files into one
Compress PDFReduce PDF file size
OCR PDFAdd text layer to scanned PDFs
Convert Email to PDFConvert EML/MSG files to PDF
PDF to WordConvert 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.

Step 2: Make Your First API Call

Let's convert a Word document to PDF. We'll use the /api/v2/convert endpoint with a workflow_id from the previous step.

Using cURL (Command Line)

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"

Using PHP

<?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";

Using Python

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']}")

Expected Response

{
  "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"
}

Step 3: Check Conversion Status

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"

Response when processing:

{
  "execution_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "processing",
  "progress": 75,
  "current_step": "Converting page 3 of 4"
}

Response when completed:

{
  "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"
}

Step 4: Download Your PDF

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 Example:

<?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";