Endpoint reference
POST /scan/scan_pdf
One photo in, one PDF out, with a text layer so the file can be searched, selected and archived. Several photos produce one multi-page PDF.
Request contract
POST https://api.scankit.io/scan/scan_pdf takes multipart/form-data. Send file for a single page or files repeated for a multi-page document.
| Parameter | Default | What it does |
|---|---|---|
| file or files | required | One image, or several images for a multi-page PDF. |
| ocr_lang | eng | Language of the text layer, for example eng, deu or fra. |
- The response is the PDF itself: Content-Type application/pdf, filename scan.pdf, or multipage_scan.pdf for several pages.
- Straighten first when quality matters: POST /scan/crop output as the input to this endpoint gives the cleanest text layer.
Examples
cURL, single page:
bash
curl -X POST "https://api.scankit.io/scan/scan_pdf" \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.jpg" \
-F "ocr_lang=eng" \
-o scan.pdfPython, the same call with error handling:
python
import requests
with open("document.jpg", "rb") as fh:
response = requests.post(
"https://api.scankit.io/scan/scan_pdf",
headers={"X-API-Key": "YOUR_API_KEY"},
files={"file": ("document.jpg", fh, "image/jpeg")},
data={"ocr_lang": "eng"},
timeout=120,
)
response.raise_for_status()
with open("scan.pdf", "wb") as out:
out.write(response.content)Errors
| Status | Meaning | What to do |
|---|---|---|
| 400 | No file | Send file for one page or files for several pages. |
| 401 | Missing API Key or Invalid API Key | Send the X-API-Key header with a key from an active account. |
| 402 | Insufficient credits | Top up credits in the dashboard. |
| 429 | Rate limit | Wait for the seconds given in Retry-After, then retry. |
| 500 | PDF generation failed | The PDF step did not return a document for this input. Retry once, then send the image to support. |