Get Conversion Status
Retrieve the status and result of a PDF conversion.
Request
The conversion ID returned from the create PDF endpoint
Response
Unique conversion identifier
Conversion status:
pending - Queued for processing
processing - Currently rendering
completed - PDF ready for download
failed - Conversion failed
URL to download the PDF (only present when status is completed)
Error details (only present when status is failed)
ISO 8601 timestamp of when the conversion was created
ISO 8601 timestamp of when the conversion completed
Examples
curl https://api.pdflet.dev/api/v1/conversions/conv_abc123/ \
-H "X-API-Key: pk_live_your_api_key"
Pending Response
{
"id": "conv_abc123",
"status": "pending",
"created_at": "2024-01-15T10:30:00Z"
}
Completed Response
{
"id": "conv_abc123",
"status": "completed",
"file_url": "https://api.pdflet.dev/media/pdfs/conv_abc123.pdf",
"created_at": "2024-01-15T10:30:00Z",
"completed_at": "2024-01-15T10:30:02Z"
}
Failed Response
{
"id": "conv_abc123",
"status": "failed",
"error_message": "Failed to render HTML: Invalid CSS syntax",
"created_at": "2024-01-15T10:30:00Z"
}
Polling Pattern
Since conversions are asynchronous, implement polling to wait for completion:
import time
import requests
def wait_for_pdf(conversion_id, api_key, timeout=30):
"""Poll until PDF is ready or timeout."""
start = time.time()
while time.time() - start < timeout:
response = requests.get(
f"https://api.pdflet.dev/api/v1/conversions/{conversion_id}/",
headers={"X-API-Key": api_key}
)
data = response.json()
if data['status'] == 'completed':
return data['file_url']
elif data['status'] == 'failed':
raise Exception(data['error_message'])
time.sleep(1) # Poll every second
raise TimeoutError("PDF generation timed out")
Most conversions complete within 2-5 seconds. Start with a 1-second polling interval.