PDF2Extract API
Run every PDF2Extract tool from your own code. API jobs are paid from the same credit wallet as the website, use your daily free pages first, and keep files for 24 hours.
Create a key on the developers page. Machine-readable spec: /api/v1/openapi.json (OpenAPI 3.1).
Authentication
Send your key in every request: Authorization: Bearer p2e_live_…. The full key is shown once, when you create it; we only store a hash. Revoke a leaked key on the developers page and create a new one. Keys start with p2e_live_ so secret scanners can recognise them.
By default each key can make 60 requests per minute. Over the limit you get 429 with a Retry-After header; X-RateLimit-Limit and X-RateLimit-Remaining are on every response.
Endpoints
| GET | /api/v1/tools | Tools, their inputs and output formats, credits per page and the JSON Schema of their data. |
| POST | /api/v1/uploads | A 10-minute URL to PUT a file to, and the file_key for the job. |
| POST | /api/v1/jobs | Create a job from file_key or file_url. Optional: outputs, webhook_url, Idempotency-Key header. |
| GET | /api/v1/jobs/{id} | Status, extracted data and 15-minute download links. |
| GET | /api/v1/credits | Your credit balance (the same wallet as the website). |
A job moves from queued to processing to succeeded or failed. Failed jobs are not charged. After 24 hours files and data are deleted and the job becomes expired.
Examples
curl
# 1. Ask for an upload URL
curl -s https://pdf2extract.com/api/v1/uploads \
-H "Authorization: Bearer $P2E_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_name":"statement.pdf","size":184320,"content_type":"application/pdf"}'
# 2. Upload the file to upload_url
curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/pdf" --data-binary @statement.pdf
# 3. Create the job (or send "file_url" instead of "file_key")
curl -s https://pdf2extract.com/api/v1/jobs \
-H "Authorization: Bearer $P2E_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: statement-2026-10" \
-d '{"tool":"bank-statement-to-excel","file_key":"'"$FILE_KEY"'","webhook_url":"https://example.com/hooks/p2e"}'
# 4. Poll until status is "succeeded" or "failed"
curl -s https://pdf2extract.com/api/v1/jobs/$JOB_ID -H "Authorization: Bearer $P2E_API_KEY"Python
import os, time, requests
API = "https://pdf2extract.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['P2E_API_KEY']}"}
# Create a job straight from a public URL
job = requests.post(f"{API}/jobs", headers=HEADERS, json={
"tool": "invoice-to-excel",
"file_url": "https://example.com/invoices/inv-1042.pdf",
}).json()
while job["status"] in ("queued", "processing"):
time.sleep(3)
job = requests.get(f"{API}/jobs/{job['id']}", headers=HEADERS).json()
if job["status"] == "succeeded":
print(job["data"]) # structured data
for d in job["downloads"]: # links valid for 15 minutes
print(d["format"], d["url"])
else:
print("Failed:", job["error"])Node.js
import { readFile } from "node:fs/promises";
const API = "https://pdf2extract.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.P2E_API_KEY}`, "Content-Type": "application/json" };
const file = await readFile("scan.pdf");
const upload = await fetch(`${API}/uploads`, {
method: "POST", headers,
body: JSON.stringify({ file_name: "scan.pdf", size: file.length, content_type: "application/pdf" }),
}).then((r) => r.json());
await fetch(upload.upload_url, { method: "PUT", headers: upload.headers, body: file });
let job = await fetch(`${API}/jobs`, {
method: "POST", headers,
body: JSON.stringify({ tool: "pdf-to-markdown", file_key: upload.file_key, outputs: ["md"] }),
}).then((r) => r.json());
while (job.status === "queued" || job.status === "processing") {
await new Promise((resolve) => setTimeout(resolve, 3000));
job = await fetch(`${API}/jobs/${job.id}`, { headers }).then((r) => r.json());
}
console.log(job.status, job.downloads);Idempotency
Send an Idempotency-Key header (up to 255 characters) when creating a job. Repeating the request with the same key returns the first job with status 200 and the header Idempotent-Replayed: true, and charges nothing, so retries after a timeout are safe.
Webhooks
With webhook_url (https only), we POST { id, type, created_at, data } when the job finishes; type is job.succeeded or job.failed and data is the job without download links (fetch the job for fresh links). Answer with any 2xx status. Failed deliveries are retried with backoff, up to 6 attempts over about an hour; every attempt is listed on the developers page.
Each request is signed with the webhook secret shown when you created the key (whsec_…), following Standard Webhooks: headers webhook-id, webhook-timestamp and webhook-signature = v1,base64(HMAC-SHA256(secret, id + "." + timestamp + "." + body)). Verify it against the raw body before trusting the payload:
Node.js
import crypto from "node:crypto";
function verifyWebhook(secret, headers, rawBody) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
const signatures = headers["webhook-signature"] ?? "";
// Reject old deliveries to prevent replays (5 minutes).
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const expected = "v1," + crypto
.createHmac("sha256", secret)
.update(`${id}.${timestamp}.${rawBody}`)
.digest("base64");
return signatures.split(" ").some((s) =>
s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}Python
import base64, hashlib, hmac, time
def verify_webhook(secret: str, headers, raw_body: bytes) -> bool:
msg_id = headers["webhook-id"]
timestamp = headers["webhook-timestamp"]
if abs(time.time() - int(timestamp)) > 300: # reject replays older than 5 minutes
return False
signed = f"{msg_id}.{timestamp}.".encode() + raw_body
expected = "v1," + base64.b64encode(
hmac.new(secret.encode(), signed, hashlib.sha256).digest()).decode()
return any(hmac.compare_digest(s, expected) for s in headers["webhook-signature"].split(" "))file_url
Instead of uploading, pass a public https:// URL. We download it (up to 25 MB, 30 seconds, 3 redirects). URLs that point to private networks, localhost or cloud metadata addresses are refused.
Errors
Every error has the same shape: { "error": { "code": "…", "message": "…" } }.
| 400 | invalid_request, invalid_outputs, invalid_file_url, invalid_webhook_url, file_url_unreachable, upload_missing |
| 401 | unauthorized: missing, wrong or revoked key |
| 402 | insufficient_credits, free_limit_reached |
| 404 | unknown_tool, not_found |
| 413 | too_large (25 MB), too_many_pages (50 pages) |
| 415 | unsupported_type: the tool does not accept this file type |
| 429 | rate_limited: wait for the Retry-After header (seconds) |
| 503 | disabled: the API or processing is paused |