Async Mode
Async mode lets the API return immediately with a job_id instead of holding the HTTP connection open for the full inference run. Your client polls a status endpoint until the job completes. All inference endpoints — /v1/parse, /v1/extract, /v1/classify, /v1/split and /v1/redact — support it.
When to use async
Processing a multi-page document can take several minutes. A synchronous call holds the connection open for that whole time, and many clients, proxies and serverless runtimes close idle connections after 60 seconds. With async mode every HTTP request completes in under a second, so the result is never lost to a timeout.
Use async from browsers, mobile apps and functions with execution limits, or for any document that may take more than a few seconds. Synchronous calls are fine for short documents from a server you control.
How to enable
Add the header X-Async: true to any inference request. The request body and query parameters are unchanged from the synchronous call.
curl -X POST "https://apis.hyperbots.com/v1/parse" \
-H "X-API-Key: hk_live_your_key_here" \
-H "X-Async: true" \
-F "document_key=02b95e79-bc17-4e71-be99-fd4338ba00bf"curl -X POST "https://apis.hyperbots.com/v1/parse" \
-H "X-API-Key: hk_live_your_key_here" \
-H "X-Async: true" \
-F "document_key=02b95e79-bc17-4e71-be99-fd4338ba00bf"The response is a small job receipt, returned within ~100 ms:
{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending",
"poll_url": "/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02"
}{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending",
"poll_url": "/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02"
}Polling the job
GET the poll_url from the submit response (or build it yourself from the job_id: /v1/jobs/{job_id}). Poll every 3 seconds or longer.
curl "https://apis.hyperbots.com/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02" \
-H "X-API-Key: hk_live_your_key_here"curl "https://apis.hyperbots.com/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02" \
-H "X-API-Key: hk_live_your_key_here"Any active API key in your organization can poll any of your organization's jobs (see Key scope). Jobs are retained for 24 hours; after that, and for jobs that belong to another organization, the endpoint returns 404.
Job status values
| Status | Meaning |
|---|---|
pending | The job has been accepted and is queued or running on a worker. Continue polling. |
completed | The job finished successfully. The inference response is wrapped inside result (see shape below). |
failed | The job ran but raised an error. error is a plain string carrying the HTTP-style status code and human-readable reason. result is null. |
cancelled | The job was cancelled with DELETE /v1/jobs/{job_id}. Reported by GET /v1/jobs/recent; GET /v1/jobs/{job_id} reports a cancelled job as failed. |
A typical pending poll response:
{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending"
}{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending"
}On completed the response wraps the synchronous inference response inside its own result field. Job-level metadata ( created_at, completed_at, org_id, filename, endpoint) is at the top level. The OCR/extraction payload is at result.result (the outer field is the job envelope; the inner field is what a synchronous call would have returned directly):
{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "completed",
"request_id": "b91eaa9b-c75d-402d-a8dc-cb3af247c267",
"endpoint": "/v1/parse",
"filename": "contract.pdf",
"document_key": "02b95e79-bc17-4e71-be99-fd4338ba00bf",
"created_at": 1779447738.16,
"completed_at": 1779447738.85,
"error": null,
"result": {
"status": "success",
"request_id": "b91eaa9b-c75d-402d-a8dc-cb3af247c267",
"task": "parse",
"model_used": "HyperLM",
"result": {
"ocr": "INVOICE\nAcme Corp ...",
"pages": [{ "page_number": 1, "text": "INVOICE\nAcme Corp ..." }]
},
"duration_ms": 1000,
"metadata": {
"pages": 1,
"source": "document_key",
"filename": "contract.pdf",
"file_size": 5821
}
}
}{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "completed",
"request_id": "b91eaa9b-c75d-402d-a8dc-cb3af247c267",
"endpoint": "/v1/parse",
"filename": "contract.pdf",
"document_key": "02b95e79-bc17-4e71-be99-fd4338ba00bf",
"created_at": 1779447738.16,
"completed_at": 1779447738.85,
"error": null,
"result": {
"status": "success",
"request_id": "b91eaa9b-c75d-402d-a8dc-cb3af247c267",
"task": "parse",
"model_used": "HyperLM",
"result": {
"ocr": "INVOICE\nAcme Corp ...",
"pages": [{ "page_number": 1, "text": "INVOICE\nAcme Corp ..." }]
},
"duration_ms": 1000,
"metadata": {
"pages": 1,
"source": "document_key",
"filename": "contract.pdf",
"file_size": 5821
}
}
}On failed the result field is null and error is a string carrying the HTTP-style status code and a human-readable reason:
{
"job_id": "b891d13b-e068-4210-a1d3-3ca013f5a715",
"status": "failed",
"request_id": "a7f215b8-3339-4a83-9f79-03372b9e9eb4",
"org_id": "f9030855-340d-4cfd-b7e7-1f7b39f4ba42",
"endpoint": "/v1/parse",
"filename": "notpdf.txt",
"created_at": 1779447744.92,
"completed_at": 1779447744.96,
"result": null,
"error": "415: Unsupported file type: text/plain. Supported: PDF, images."
}{
"job_id": "b891d13b-e068-4210-a1d3-3ca013f5a715",
"status": "failed",
"request_id": "a7f215b8-3339-4a83-9f79-03372b9e9eb4",
"org_id": "f9030855-340d-4cfd-b7e7-1f7b39f4ba42",
"endpoint": "/v1/parse",
"filename": "notpdf.txt",
"created_at": 1779447744.92,
"completed_at": 1779447744.96,
"result": null,
"error": "415: Unsupported file type: text/plain. Supported: PDF, images."
}The same conditions that would have raised a typed error on a synchronous call (415 for unsupported file types, 402 for insufficient credits, etc.) surface here as the leading numeric code in the error string. See Error Codes for the full set.
Large documents
Organizations on the Custom plan can submit documents up to 512 MiB and 500 pages through the API or an SDK with X-Async: true. See Size limits for the standard limits. A large document is processed in page ranges and can take tens of minutes, so poll at a longer interval.
While a segmented job runs, the poll response carries progress counters alongside the usual status:
{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending",
"segments_total": 10,
"segments_done": 4,
"segments_failed": 0
}{
"job_id": "9b330094-505d-480c-812c-86a698a3ff02",
"status": "pending",
"segments_total": 10,
"segments_done": 4,
"segments_failed": 0
}segments_total is the number of page ranges the document was split into, segments_done how many have finished, and segments_failed how many gave up after retries.
A non-zero segments_failed does not fail the job. The job completes, and the result lists the missing page ranges in a gaps field. You are billed only for pages that were processed.
Cancelling a job
Cancel a running job with DELETE /v1/jobs/{job_id}. The job then appears as cancelled in GET /v1/jobs/recent and as failed in GET /v1/jobs/{job_id}.
curl -X DELETE "https://apis.hyperbots.com/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02" \
-H "X-API-Key: hk_live_your_key_here"curl -X DELETE "https://apis.hyperbots.com/v1/jobs/9b330094-505d-480c-812c-86a698a3ff02" \
-H "X-API-Key: hk_live_your_key_here"Cancellation is best-effort: a job that is already processing may complete before the request takes effect. You are not billed for a job that was cancelled before processing started.
End-to-end example
Upload, submit asynchronously, and poll to completion:
# Save as quickstart.sh and run: bash quickstart.sh
# (needs curl 7.76+ and jq)
(
API=https://apis.hyperbots.com
FILE='contract.pdf'
CT='application/pdf'
# 1. Get an upload URL (content_length = file size in bytes)
SIZE=$(wc -c < "$FILE" | tr -d ' ')
UPLOAD=$(curl -sS --fail-with-body \
-X POST "$API/v1/documents/upload" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg f "$FILE" --arg ct "$CT" \
--argjson n "$SIZE" \
'{filename: $f, content_type: $ct, content_length: $n}')") \
|| { echo "$UPLOAD" >&2; exit 1; }
DOC_KEY=$(echo "$UPLOAD" | jq -er .document_key) || exit 1
UPLOAD_URL=$(echo "$UPLOAD" | jq -er .upload_url) || exit 1
# 2. PUT the file there (no API key on this request)
curl -sS --fail-with-body -X PUT "$UPLOAD_URL" \
-H "Content-Type: $CT" \
-H "x-amz-server-side-encryption: AES256" \
--data-binary @"$FILE" || exit 1
# 3. Submit /v1/parse asynchronously → a job_id
URL="$API/v1/parse"
JOB=$(curl -sS --fail-with-body -X POST "$URL" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Async: true" \
-F "document_key=$DOC_KEY") \
|| { echo "$JOB" >&2; exit 1; }
JOB_ID=$(echo "$JOB" | jq -er .job_id) || exit 1
# 4. Poll every 3 seconds until the job is no longer pending
while true; do
RESP=$(curl -sS "$API/v1/jobs/$JOB_ID" \
-H "X-API-Key: YOUR_API_KEY")
STATUS=$(echo "$RESP" | jq -r .status)
if [ "$STATUS" != "pending" ]; then
echo "$RESP" | jq
break
fi
sleep 3
done
)# Save as quickstart.sh and run: bash quickstart.sh
# (needs curl 7.76+ and jq)
(
API=https://apis.hyperbots.com
FILE='contract.pdf'
CT='application/pdf'
# 1. Get an upload URL (content_length = file size in bytes)
SIZE=$(wc -c < "$FILE" | tr -d ' ')
UPLOAD=$(curl -sS --fail-with-body \
-X POST "$API/v1/documents/upload" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg f "$FILE" --arg ct "$CT" \
--argjson n "$SIZE" \
'{filename: $f, content_type: $ct, content_length: $n}')") \
|| { echo "$UPLOAD" >&2; exit 1; }
DOC_KEY=$(echo "$UPLOAD" | jq -er .document_key) || exit 1
UPLOAD_URL=$(echo "$UPLOAD" | jq -er .upload_url) || exit 1
# 2. PUT the file there (no API key on this request)
curl -sS --fail-with-body -X PUT "$UPLOAD_URL" \
-H "Content-Type: $CT" \
-H "x-amz-server-side-encryption: AES256" \
--data-binary @"$FILE" || exit 1
# 3. Submit /v1/parse asynchronously → a job_id
URL="$API/v1/parse"
JOB=$(curl -sS --fail-with-body -X POST "$URL" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Async: true" \
-F "document_key=$DOC_KEY") \
|| { echo "$JOB" >&2; exit 1; }
JOB_ID=$(echo "$JOB" | jq -er .job_id) || exit 1
# 4. Poll every 3 seconds until the job is no longer pending
while true; do
RESP=$(curl -sS "$API/v1/jobs/$JOB_ID" \
-H "X-API-Key: YOUR_API_KEY")
STATUS=$(echo "$RESP" | jq -r .status)
if [ "$STATUS" != "pending" ]; then
echo "$RESP" | jq
break
fi
sleep 3
done
)The Python SDK submits and polls for you: client.parse(file) returns when the result is ready. Use submit_* and wait_for_job to submit now and collect later. See SDKs.
Job retention
Jobs are retained for 24 hours, after which GET /v1/jobs/{job_id} returns 404. The result remains available for 30 days by request_id; page image links in a poll response expire sooner. See Retrieving Results.
Recent jobs
GET /v1/jobs/recent lists your organization's jobs from the last 24 hours, newest first. limit accepts 1–100 (default 20; other values use the default). Filter with ?source=api or ?source=playground.
curl "https://apis.hyperbots.com/v1/jobs/recent?limit=100" \
-H "X-API-Key: hk_live_your_key_here"curl "https://apis.hyperbots.com/v1/jobs/recent?limit=100" \
-H "X-API-Key: hk_live_your_key_here"Rows are summaries — they carry no result. Fetch the full envelope for a single job with GET /v1/jobs/{job_id}.
Each row carries the document_key the job was submitted with. To map jobs back to documents, match on document_key, not filename, which is not unique. Recording the job_id from each submit response avoids the lookup entirely.