Home/Documentation/POST /scan/scan_pdf
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.

ParameterDefaultWhat it does
file or filesrequiredOne image, or several images for a multi-page PDF.
ocr_langengLanguage 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.pdf

Python, 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

StatusMeaningWhat to do
400No fileSend file for one page or files for several pages.
401Missing API Key or Invalid API KeySend the X-API-Key header with a key from an active account.
402Insufficient creditsTop up credits in the dashboard.
429Rate limitWait for the seconds given in Retry-After, then retry.
500PDF generation failedThe PDF step did not return a document for this input. Retry once, then send the image to support.