API v3

HTTP contract, extraction profiles, and reading lifecycle.

On this page
https://ocr.ecostudios.dev/api/v3

Endpoints

MethodPathOperation
POST/ineReading reservation and extraction. multipart/form-data body.
GET/ine/{request_id}Stored status and result. No body; no inference.

The public contract uses English JSON properties, enum values, and error codes. Routes and schemas are independent of documentation language.

HTTP contract

ElementSpecification
TransportHTTPS.
AuthenticationX-API-Key, required on both endpoints. Scope and revocation.
IdempotencyIdempotency-Key, required on POST: ^[A-Za-z0-9._:-]{8,128}$.
POST bodymultipart/form-data; boundary=…. Binary file parts in front and/or back; options mode and profile.
Response representationapplication/json.
CachingCache-Control: no-store.
CorrelationX-Request-Id and request_id. An error identifier does not imply that a reading was reserved.
Pending stateHTTP 202, status: "processing", Location, status_url, and Retry-After: 2.

JSON uploads, image URLs, base64, PDF, and batches within a single request are unsupported. Accepted files are static JPG, PNG, WEBP, and HEIC, limited to 10 MiB per file; phone photos up to 50 megapixels are scaled before reading. Dimension, multipart body, and side-combination constraints are defined in the extraction request.

Extraction profiles

ParameterValueStructure
modeboth — defaultRequires front and back.
modefront or backRequires only the selected side's file.
profilestandard — defaultdata: eight nullable scalars and mrz.
profileextendeddata: twenty scalars, mrz, and address_parts; metadata in sources, checks, and quality.

Scalar fields have type string | null. mrz is an array of three strings or null. The twelve address_parts components are derived from address OCR fields; they are not twelve additional fields read directly from the credential.

The field reference defines types, printed sources, and nullability. The extended profile defines sources, checks, and image observations. profile: "extended" is present in the extended response; the standard response omits profile.

Reading lifecycle

The initial POST remains open during extraction. A completed reading returns HTTP 200 with status: "succeeded". A retrieval or idempotent replay while processing returns HTTP 202; this state does not represent a durable inference queue.

ResultSemantics
200 succeededExtraction completed; data contains available values and warnings their associated warnings.
202 processingPending reading. request_id identifies the resource available through GET.
Pre-reservation errorCreates no new reading and consumes no additional units. The error may include a correlation request_id.
Recorded technical failureTerminal job state. Its GET or replay returns HTTP 422, even if the original POST returned 502 or 504.
410 result_expiredThe result is outside its availability window.

Current results expire 23 hours after reservation. GET and idempotent replay do not extend expires_at, rerun OCR, or consume another unit. Compatible historical results may contain expires_at: null.

Idempotency

The key is associated with the account, exact image bytes, mode, and profile. An equivalent replay returns the existing job. Reusing a key with different content or options produces 409 idempotency_conflict. The scope is shared across API versions.

A client timeout or disconnect leaves the POST outcome unconfirmed; it does not establish that reservation failed. A new key permits a new reservation and may duplicate processing. Error codes and recovery actions are defined in errors and idempotency.

Result semantics

null represents an absent, unreadable, ambiguous, or conflicting value according to the field and its warnings. It is distinct from an empty string or zero. needs_review is always true; 200 describes completed extraction, not the accuracy of each value or credential authenticity.

Extended-profile format, check-digit, and consistency checks are separate from transcription. They do not modify extracted text or query INE or RENAPO registries.

Admission and usage

An account supports up to two active jobs and ten new reservations within a rolling 60-second window, in addition to its monthly quota. A reservation occupies one unit regardless of mode or profile. Completed readings and no_fields retain that unit; recorded technical failures credit it back. A credit does not remove the reservation from the per-minute count.

429 states, quotas, and accounting rules are specified in limits and usage. Terminal-state notification is specified in webhooks.