vision API
HTTP API of the vision service (FastAPI, no OpenAPI file in the repository: the
interactive docs are disabled). It is internal only: the gateway has no /v1/extract or /v1/detect route,
so callers are other services on the internal network (http://vision:8090 in docker-compose.yml, bound to
127.0.0.1:8090 on the host).
Conventions
| Topic | Rule |
|---|---|
| Authentication | X-Atl-Principal header: EdDSA token signed with the gateway key, iss=atl-gateway, aud=atl-internal, exp required, kind in user, api_key, service, non-empty sub. Services forward the caller principal or sign a service principal with PRINCIPAL_SIGNING_KEY. No permission check. |
| Request body | multipart/form-data; total body at most MAX_UPLOAD_BYTES × MAX_QR_IMAGES + 64 KiB (default about 100 MiB), checked on Content-Length and while streaming |
| Images | jpeg, png, webp, heic (detected by Pillow, not by the client content type), at most MAX_UPLOAD_BYTES (10 MiB) and MAX_IMAGE_PIXELS (40 M pixels) each; EXIF orientation is applied |
| Concurrency | CPU work limited to MAX_CONCURRENCY (2) jobs per process; extra requests wait |
| Errors | RFC 9457 application/problem+json: title, status, code, optional detail (never PII) |
| Privacy | images and results are neither stored nor logged |
POST /v1/extract/identity
Extracts first name, last name and birth date from a photo of a French CNI (2021+ model, TD1 MRZ) or an EPITA student card.
Request (multipart):
| Field | Type | Required | Description |
|---|---|---|---|
image | file | yes | Document photo |
kind | string | no | auto (default), fr_id_card, epita_card |
With auto, the CNI pipeline runs first, then the EPITA card heuristics if no valid CNI was found. With fr_id_card
the card pipeline never runs. With epita_card the CNI pipeline is skipped.
Response 200:
| Field | Type | Description |
|---|---|---|
document_type | string | fr_id_card, epita_card or unknown |
first_name | string or null | Given names (MRZ: space separated) |
last_name | string or null | Surname |
birth_date | string or null | YYYY-MM-DD |
confidence | number | Overall confidence in [0, 1] |
fields_confidence | object | first_name, last_name, birth_date confidences in [0, 1] |
warnings | string array | Codes below |
An unrecognised document is still a 200 with document_type: unknown. An MRZ that is not a French CNI also
returns unknown, but with the fields read from the MRZ.
| Warning | Meaning |
|---|---|
names_not_checksummed | Always set for a CNI: TD1 check digits do not cover names, the user must review them |
mrz_check_digit_mismatch | At least one check digit failed (at least half passed) |
document_expired | MRZ expiry date in the past |
mrz_not_found | No usable TD1 MRZ |
mrz_not_fr_id_card | MRZ found but issuer is not FRA or code is not ID |
fr_id_card_pre_2021_not_supported | Old two-line CNI MRZ detected |
document_not_recognized | Neither a CNI nor an EPITA card |
epita_keywords_not_found | kind=epita_card but no card keyword found |
name_not_found, birth_date_not_found | EPITA card field missing |
When the EPITA card pipeline runs, earlier CNI warnings are cleared.
{
"document_type": "fr_id_card",
"first_name": "MARIE ANNE",
"last_name": "DUPONT",
"birth_date": "2001-04-12",
"confidence": 0.968,
"fields_confidence": {"first_name": 0.91, "last_name": 0.91, "birth_date": 0.94},
"warnings": ["names_not_checksummed"]
}
POST /v1/detect/qr
Detects QR codes (QR, Micro QR, rMQR) and Data Matrix codes in one or several photos.
Request (multipart): images, one file per part, repeated, 1 to MAX_QR_IMAGES (10).
Response 200: {"codes": [...]}, one entry per distinct (text, format) per image, in request order:
| Field | Type | Description |
|---|---|---|
image_index | integer | Position of the image in the request (from 0) |
text | string | Decoded content |
format | string | zxing format name: QRCode, MicroQRCode, RMQRCode, DataMatrix |
An image without code simply adds nothing; an invalid image fails the whole request.
Errors
| Status | code | When |
|---|---|---|
| 400 | empty_image | Empty file |
| 400 | invalid_image | Image cannot be decoded |
| 400 | too_many_images | More than MAX_QR_IMAGES images |
| 401 | unauthenticated | Missing or invalid principal token (WWW-Authenticate: Bearer) |
| 404, 405 | not_found, method_not_allowed | Unknown route or method |
| 413 | payload_too_large | Body, image size or pixel count above the limits |
| 415 | unsupported_media_type | Not jpeg, png, webp or heic |
| 422 | validation_failed | Missing image / images, invalid kind (detail lists the fields) |
| 500 | internal | Unexpected error |
| 503 | ocr_unavailable | Tesseract failed or timed out (/v1/extract/identity) |
Probes and metrics
No authentication, not logged:
| Method | Path | Response |
|---|---|---|
| GET | /healthz | {"status": "ok"} |
| GET | /readyz | {"status": "ready"}, or 503 unavailable when Tesseract cannot run |
| GET | /metrics | Prometheus text format |