How to Use the PDF.ai Upload API

Publish date
Oct 4, 2026
AI summary
The Upload API lets you add PDFs to your library via URL or file, returning a docId for later use in chat, history, tags, or OCR; it costs 2 credits per upload, supports up to 4.5 MB for file uploads (100 MB via URL), has a 300‑second timeout, and offers optional OCR and tagging, with detailed usage examples and guidance on when to choose this API versus other PDF.ai endpoints.
Language
People look up an Upload API when they need a reliable way to put a PDF into their product library and get back a docId — before Chat, history, tags, or a later OCR pass — not a browser-only upload box, and not the v2 Parse path that returns markdown/JSON in one shot.
This page is the URL or file → docId path on the PDF.ai API v1 Upload endpoints. It does not replace the API Hub (keys and plan live there). It does not re-rank the head term pdf api. It is not v2 Parse (POST /v2/parse), which is the getting-started path for structured page content. For the first Parse request, see How to Get Started with the PDF.ai API. For Q&A after upload, see How to Use the PDF.ai Chat API.

What Upload is for

After a clean Upload call on the PDF.ai API v1, three things should be true:
  • You sent a reachable PDF URL or a file with your X-API-Key
  • The response includes a docId string you can store
  • You know which size/timeout path you used (file vs URL) so retries stay inside the documented limits
Practical rule: Upload gives you a library docId. Chat, chat-all, history, tags, and post-upload OCR all expect that id. Parse/Extract/Ask on v2 use their own parse pipeline — do not assume a v1 upload docId is interchangeable with a v2 Parse docId without checking the endpoint you call next.

URL upload vs file upload

Path
Best when
Documented limits (Upload PDF)
POST /v1/upload/url
The file already has a public (or reachable) URL, or it is larger than the file-upload cap
Timeout 300 seconds; Upload docs: no separate size cap beyond finishing inside that timeout
POST /v1/upload/file
You have the bytes in the request (FormData)
Timeout 300 seconds; file size limit 4.5 MB
On the Dedicated API plan page (API limits), URL upload is also listed with a max 100 MB / PDF via URL and 4.5 MB via file, plus a 60-second timeout note for uploads with a very large page count (e.g. 1000+ pages). Prefer the Upload PDF page numbers for the request shape; check API limits when you size commercial traffic.

Credits before you scale uploads

From the live API limits Dedicated API plan credit model:
  • Upload: 2 credits per file upload
API plan examples on credit usage (key + plan live on the developer hub):
  • Free: $0/month for 200 credits/month, no credit card required
  • Paid examples: $49 / 3,000, $99 / 10,000, $249 / 30,000, $599 / 100,000 credits per month
Generate the key and manage the plan on https://pdf.ai/developer. The docs say the key is shown only once when generated.
Practical rule: count 2 credits once per successful upload on the Dedicated credit model. Turning on ocr=true at upload time can push large scans past the 300-second timeout (Upload docs warn a 500 is likely then) — that is a reliability issue, not a free extra credit line.

How to call Upload

1. Have an API key

Open https://pdf.ai/developer, generate a key, store it as a secret. Send it as the X-API-Key header on every call.

2. Choose URL or file

  • URL upload: POST https://pdf.ai/api/v1/upload/url with required url
  • File upload: POST https://pdf.ai/api/v1/upload/file with required file (FormData); use URL upload when the file is larger than 4.5 MB
Optional fields on both paths (from the docs):
  • isPrivate — whether the PDF is private
  • ocr — enable Optical Character Recognition so scanned text becomes searchable
  • tags — array of strings (e.g. ["Tag1", "Tag2"])
A successful upload returns a docId. Keep it for Chat, listing, single-doc fetch, tags, delete, or a later OCR pass.

3. Example: upload by URL

import requests

url = "https://pdf.ai/api/v1/upload/url"
headers = {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "url": "https://example.com/your-document.pdf",
    "isPrivate": False,
    "ocr": False,
    "tags": ["invoices", "2026"]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())  # {"docId": "..."}

4. Example: upload by file

import requests

url = "https://pdf.ai/api/v1/upload/file"
headers = {
    "X-API-Key": "YOUR_API_KEY"
}

files = {
    "file": open("your-document.pdf", "rb")
}
data = {
    "isPrivate": "false",
    "ocr": "false"
}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())  # {"docId": "..."}

5. Optional: OCR after upload, list, or fetch one doc

  • OCR later (no extra credits per the OCR docs): If you skipped ocr=true at upload, POST https://pdf.ai/api/v1/ocr with required docId and optional ocrLang (default "eng"). Timeout 300 seconds; file size limit 50 MB (OCR an uploaded PDF).
  • List library: GET https://pdf.ai/api/v1/documents returns id, name, size, isPublic, uploadedAt, url, importUrl (Get all documents).
  • One document: GET https://pdf.ai/api/v1/documents/{docId} adds tags among the same core fields (Get single document).

6. Check the output before you trust it

  • Confirm the JSON includes a non-empty docId
  • Spot-check GET /documents/{docId} (or the list endpoint) so name/size match what you sent
  • If you get Invalid API key / No API key present, fix the header before you change the file
  • If file upload fails near 4.5 MB, switch to URL upload
  • If OCR-on-upload returns 500, the Upload docs say the document is likely too large for the 300-second window — OCR the file yourself first, or use the post-upload OCR endpoint on a smaller/split file
Practical rule: a returned docId only means the library accepted the file. Open or chat against it before you treat the pipeline as production-ready.

When Upload is the wrong tool

  • You wanted a generic “pdf api” category hub. Stay on https://pdf.ai/developer. This page is the Upload how-to, not a replacement hub.

A short action plan

  1. Open https://pdf.ai/developer, create a key, store it once.
  1. Pick URL (/v1/upload/url) or file (/v1/upload/file) from the size rules above.
  1. Budget 2 credits per upload on the Dedicated credit model (API limits).
  1. POST the upload, store docId, then verify with GET /documents/{docId} before you wire Chat or other v1 calls.
If you want the rest of the PDF workflow after the docId is clean, start at PDF.ai. Use the Upload API when the next step is a v1 library id in your product, not a single browser upload box.