Send a PDF to OCR with a direct public URL
To send a PDF to OCR by URL, upload the PDF bytes, confirm the returned URL serves `application/pdf`, pass `url` to the OCR API, then keep `file_id`, `expires_at`, and `delete_url` for cleanup.
- Reviewed by
- GetFileURL technical team
- Updated
- Input
- PDF invoice, contract, report, Drive export, or webhook attachment
- Action
- Upload PDF bytes and verify application/pdf delivery
- Output
- OCR-ready PDF URL plus file_id, expires_at, and delete_url
- Header proof
- 200 OK with Content-Type: application/pdf
- OCR fields
- url, file_id, content_type, expires_at, delete_url
- Failure signal
- Drive preview links, HTML pages, or wrong MIME type
What this page answers
It turns a PDF invoice, contract, report, Drive export, or webhook attachment into an OCR-ready URL that serves application/pdf.
- Reviewed by
- GetFileURL technical team
- Last updated
One request in, a URL and JSON out
Drive export or invoice.pdf
-> POST /v1/files
-> curl -I response.url
-> Content-Type: application/pdf
-> OCR API document_url
-> delete after OCR completesMake the file handoff visible.
A useful PDF OCR recipe shows the source PDF, upload request, `application/pdf` header proof, OCR URL mapping, and cleanup handle.
Capture the file
Start from the actual PDF bytes, such as a Drive export, invoice upload, contract, report, email attachment, or webhook PDF.
Upload and parse JSON
Upload the PDF with `POST /v1/files`, then confirm the returned URL serves `application/pdf` before mapping it into OCR.
Send onward
Pass `url` to the OCR API, keep `file_id`, `content_type`, `expires_at`, and `delete_url`, then delete after OCR completes.
Validate the URL before the destination retries.
Most PDF OCR URL issues come from one of four places: Drive preview links, expired attachment URLs, HTML responses instead of PDF bytes, or the wrong MIME type.
Direct response
The URL should return file bytes, not an app preview, permission page, or redirect loop.
Useful headers
Content type, size, and disposition should match what the destination expects.
Enough retention
Expiry should account for queue delays, async processing, and retry branches.
Match the URL shape OCR tools ask for.
PDF OCR tools usually fetch the PDF from their own servers. The URL must be public, reachable, and clearly a PDF response.
Mistral OCR
Use a public PDF URL or Base64 PDF input when the OCR provider accepts those document shapes.
Adobe OCR
Keep the PDF served as `application/pdf` so the OCR job receives the expected input type.
PDF.co and similar tools
Pass a direct file URL to a single PDF, not a Drive folder, viewer page, or permissioned app link.
Prove the returned URL serves PDF bytes before OCR runs.
The fastest preflight is the same check the OCR provider effectively performs: fetch headers from the returned URL and confirm a PDF response.
Run curl -I
Run `curl -I https://cdn.getfileurl.com/f/file_8ks41p/invoice.pdf` before mapping the URL into the OCR request.
Check status
Confirm `200 OK`, not a redirect loop, sign-in page, or expired link.
Check type
Confirm `Content-Type: application/pdf`, then keep `content_type` beside the OCR job.
Treat OCR URLs as job-scoped access.
Invoices, contracts, and reports can be sensitive. Keep the PDF reachable through OCR retries, then remove public access after the job finishes.
Expiry
Compare `expires_at` with OCR queue time, retries, and manual replay windows.
Delete after OCR
Use `delete_url` or `DELETE /v1/files/{file_id}` when the OCR result is saved.
Log the run
Store `url`, `file_id`, `content_type`, `expires_at`, destination job ID, and OCR response status.
Copy the same upload shape into code
curl -I 'https://cdn.getfileurl.com/f/file_8ks41p/invoice.pdf'
HTTP/2 200
content-type: application/pdf
Response fields to keep:
url, file_id, content_type, expires_at, delete_urlCommon questions
What does this recipe solve?
It turns a PDF invoice, contract, report, Drive export, or webhook attachment into an OCR-ready URL that serves `application/pdf`.
Should the URL be permanent?
Not by default. Keep it alive through OCR fetches and retries, then delete after the OCR result is saved.
What should I log?
Log `url`, `file_id`, `content_type`, `expires_at`, `delete_url`, the OCR job ID, and the OCR response status.