SPB Git

Repository Public

API_REFERENCE.md 32.2 KB 604 lines markdown

1# MacLustr Identity — API reference23API version `2026-12-01`, service version `1.0.0`. This document is built from the OpenAPI description served by the application (`services/mlid/app.py`) and from the code. Where the two differ, the code is the reference.45- Base URL: `https://identity.spboucher.ai/v1` (an alias exists under `/api/v1`).6- OpenAPI 3.1 description: `GET /api/v1/openapi.json` (public, no authentication). Request and response bodies are free-form objects in that description; the shapes below come from the code.7- Rendered reference: `https://identity.spboucher.ai/docs`.8- Official SDKs: [SDK_WEB.md](SDK_WEB.md), [SDK_PYTHON.md](SDK_PYTHON.md), [SDK_IOS.md](SDK_IOS.md), [SDK_ANDROID.md](SDK_ANDROID.md). Integration guide: [../integrations/README.md](../integrations/README.md).910> Production status on 2026-12-01: live mode is locked by the compliance gates. Every `mlid_sk_live_…` call that creates a session returns `403 compliance_gate_closed`. Only sandbox works.1112## Conventions1314- JSON in, JSON out, UTF-8. Uploads use `multipart/form-data`.15- Successful calls return `200`.16- Every response carries a `Request-Id` header (`req_…`), including the early `403`, `411` and `413` answers described under "Request size". API responses carry `Cache-Control: no-store`.17- In production the API only accepts connections coming through the public gateway. A direct connection from another network path is answered `403 forbidden_network`.18- Timestamps are ISO 8601 with offset, except `created` in webhook events (Unix seconds).19- Identifiers are prefixed: `vs_` session, `ver_` verification, `we_` webhook endpoint, `evt_` event, `whd_` delivery, `key_` API key, `app_` application, `chl_` challenge, `dsp_` dispute.2021## Authentication2223Two kinds of credentials, never interchangeable.2425| Credential | Format | Used by | Endpoints |26|---|---|---|---|27| Secret API key | `mlid_sk_test_…` (sandbox), `mlid_sk_live_…` (live) | Your server only | `/v1/verification-sessions`, `/v1/verifications`, `/v1/webhooks` |28| Session client secret | `vsc_…` | The person's browser or native app, for one session | `/v1/sessions/{id}/…` |2930Both are sent as `Authorization: Bearer <credential>`.3132A secret key belongs to one application and one mode. Keys are stored hashed (SHA-256); the secret is shown once at creation. A key may have an expiry date and may be revoked or rolled from the console; rolling keeps the old key valid for a grace period (24 hours by default, 0 to 168).3334### Scopes3536| Scope | Allows |37|---|---|38| `sessions:write` | Create and cancel verification sessions |39| `sessions:read` | Retrieve and list verification sessions |40| `verifications:read` | Retrieve and list verifications, read their status |41| `verifications:write` | Revoke a verification, destroy its personal data |42| `webhooks:manage` | Create, list, delete webhook endpoints, rotate their secret |4344A key created without an explicit list receives all five. A call outside the key's scopes returns `403 insufficient_scope`.4546### Isolation4748Every object belongs to one application and one mode. A key never sees objects of another application or of the other mode: such a request returns `404 resource_missing`.4950This also holds for webhook management: a sandbox key cannot delete or rotate a live endpoint of the same application, and the reverse (`404`).5152## Errors5354```json55{56  "error": {57    "type": "invalid_request_error",58    "code": "purpose_required",59    "message": "purpose is required (the reason for this verification, 120 characters at most).",60    "param": "purpose",61    "request_id": "req_0f3k…"62  }63}64```6566`param` is present when the error concerns one field. Branch on `code`, never on `message`.6768| HTTP | `type` |69|---|---|70| 400, 411, 413, 422 | `invalid_request_error` |71| 401 | `authentication_error` |72| 403 | `permission_error` |73| 404 | `not_found_error` |74| 409 | `conflict_error` |75| 429, code `rate_limited` | `rate_limit_error`, with a `Retry-After` header: retry after that delay |76| 429, any other code | `quota_error`: a usage ceiling (per day or per session) was reached; retrying sooner is useless |77| 503 | `service_unavailable_error`, with `Retry-After: 5` |78| 500 and others | `api_error` |7980Retry guidance: retry `429 rate_limited`, `503` and `409 idempotency_in_progress` after the `Retry-After` delay, with the same `Idempotency-Key`. Do not retry a `quota_error` automatically. The official SDKs follow these rules.8182### Error codes8384General:8586| Code | HTTP | Meaning |87|---|---|---|88| `invalid_request` | 400 | Malformed request or missing required field |89| `missing_api_key` | 401 | No `Authorization: Bearer` header |90| `invalid_api_key` | 401 | Unknown, expired or revoked key |91| `insufficient_scope` | 403 | The key lacks the required scope |92| `resource_missing` | 404 | No such object for this application and mode |93| `not_found` | 404 | Unknown endpoint |94| `method_not_allowed` | 405 | Wrong HTTP method |95| `rate_limited` | 429 | Too many requests; see `Retry-After` |96| `forbidden_network` | 403 | The connection did not come through the public gateway |97| `length_required` | 411 | Request body sent without a `Content-Length` (chunked transfer) |98| `payload_too_large` | 413 | Declared body size above the limit for this endpoint; the body is not read |99| `service_unavailable` | 503 | The database is saturated or unreachable; retry after `Retry-After` |100| `internal_error` | 500 | Unexpected failure; no detail is returned |101| `invalid_idempotency_key` | 400 | `Idempotency-Key` longer than 200 characters |102| `idempotency_key_reused` | 409 | Same key, different request body |103| `idempotency_in_progress` | 409 | The first request with this key has not finished (`Retry-After: 1`) |104| `invalid_cursor` | 400 | `starting_after` does not reference an existing object |105106Verification sessions:107108| Code | HTTP | Meaning |109|---|---|---|110| `purpose_required` | 400 | `purpose` missing or longer than 120 characters |111| `unknown_policy` | 400 | Unknown `verification_policy` |112| `invalid_return_url` | 400 | `return_url` malformed, too long, or not https |113| `return_url_not_allowed` | 400 | `return_url` not in the application's allowed redirect URLs |114| `invalid_external_user_id` | 400 | Not a string, or longer than 200 characters |115| `invalid_metadata` | 400 | Not an object, or larger than 2000 bytes once serialised |116| `application_suspended` | 403 | The application is suspended |117| `compliance_gate_closed` | 403 | Live mode is not enabled (gate `live_document` closed) |118| `no_method_available` | 403 | No method of the policy is enabled for this application and mode |119| `daily_session_limit` | 429 | Daily session limit of the application reached (`quota_error`, `Retry-After: 3600`) |120| `session_not_cancellable` | 409 | The session is final, or in manual review (the application cannot cancel during review; the person can still withdraw consent) |121| `not_revocable` | 409 | Only a `verified` verification can be revoked |122123Session flow:124125| Code | HTTP | Meaning |126|---|---|---|127| `missing_client_secret` | 401 | No `Authorization: Bearer vsc_…` header |128| `invalid_client_secret` | 401 | Unknown session or wrong secret |129| `invalid_session_state` | 409 | The step is not available in the current status |130| `method_not_available` | 400 | Method not offered by this session |131| `consent_required` | 400 | `accepted` is not `true`, or `text_version` is not the current one |132| `biometric_consent_required` | 400 | `biometric_consent` is not `true` for a biometric method |133| `sandbox_no_real_documents` | 403 | Upload attempted on a sandbox session |134| `sandbox_only` | 403 | Scenario requested on a live session |135| `unknown_scenario` | 400 | Unknown sandbox scenario |136| `invalid_side` | 400 | `side` is not `front` or `back` |137| `file_too_large` | 413 | Document over 12 MB, or a selfie frame over 3 MB |138| `unsupported_file_type` | 400 | Not a JPEG, PNG or WebP image, or an animated image |139| `invalid_image` | 400 | The file could not be decoded |140| `image_too_small` | 400 | Short side under 480 px (document) or 320 px (selfie frame) |141| `too_many_uploads` | 429 | More than 30 document uploads in an hour for this session (`quota_error`, `Retry-After: 3600`) |142| `selfie_not_required` | 409 | The chosen method does not use a selfie |143| `too_many_challenges` | 429 | More than 8 challenges requested for this session (`quota_error`) |144| `invalid_challenge` | 409 | Unknown or already used challenge |145| `challenge_expired` | 409 | Challenge older than 120 seconds |146| `invalid_frame_count` | 400 | Frame count outside the permitted range |147| `document_missing` | 409 | Submit without the front of the document |148| `selfie_missing` | 409 | Submit without the selfie for a biometric method |149| `invalid_message` | 400 | Dispute message outside 5 to 2000 characters |150| `no_decision` | 409 | Dispute before any decision |151| `dispute_exists` | 409 | A dispute is already open |152153Webhooks:154155| Code | HTTP | Meaning |156|---|---|---|157| `url_required` | 400 | `url` missing |158| `invalid_webhook_url` | 400 | Not https, contains credentials, does not resolve, or resolves to a private or local address |159| `invalid_event_type` | 400 | Unknown event type |160| `too_many_endpoints` | 400 | More than 16 endpoints for this application and mode |161162## Idempotency163164Send an `Idempotency-Key` header (200 characters at most) on these calls:165166- `POST /v1/verification-sessions`167- `POST /v1/verification-sessions/{id}/cancel`168- `POST /v1/verifications/{id}/revoke`169- `DELETE /v1/verifications/{id}/personal-data`170- `POST /v1/webhooks`171- `DELETE /v1/webhooks/{id}`172- `POST /v1/webhooks/{id}/rotate-secret`173174Behaviour:175176- Same key and same body: the stored response is returned with the header `Idempotent-Replayed: true`.177- Same key and a different body, or the same key on a different operation: `409 idempotency_key_reused`.178- Same key while the first request is still running: `409 idempotency_in_progress`, with `Retry-After: 1`.179- If the first request fails, the key is released and may be reused.180- Keys are scoped to the application and the mode and are kept 24 hours. The stored response is encrypted at rest, because it may contain a session client secret or a webhook secret.181182Without the header, a repeated `POST /v1/verification-sessions` creates a second session.183184## Pagination185186List endpoints return the newest objects first.187188| Parameter | Meaning |189|---|---|190| `limit` | 1 to 100, default 20 |191| `starting_after` | Identifier of the last object of the previous page |192193```json194{ "object": "list", "data": [ … ], "has_more": true }195```196197`GET /v1/webhooks` returns every endpoint at once (`has_more` is always `false`).198199## Rate limits200201| Limit | Value | Scope | Result when exceeded |202|---|---|---|---|203| Authenticated calls | 1200 per minute | Client IP address | `429 rate_limited` |204| Calls with an invalid key | 30 per minute | Client IP address | `429 rate_limited` |205| Calls per API key | 600 per minute (application setting `rate_per_min`) | Key | `429 rate_limited` |206| Session flow calls | 900 per minute (`MLID_FLOW_IP_RATE`) | Client IP address | `429 rate_limited` |207| Session flow calls | 120 per minute | Session | `429 rate_limited` |208| Sessions created | 5000 per day (application setting `sessions_per_day`) | Application and mode | `429 daily_session_limit` (`quota_error`) |209| Sessions for one `external_user_id` | 5 per day (`sessions_per_user_per_day`) | Application and user | Not blocked: recorded as a technical-risk signal |210| Sessions started from one person's IP address | 10 per day | Application and address, counted at the first consent | Not blocked: recorded as a technical-risk signal |211| Document uploads | 30 per hour | Session | `429 too_many_uploads` (`quota_error`) |212| Liveness challenges | 8 | Session | `429 too_many_challenges` (`quota_error`) |213214All limits are stored in the database and shared by every API process: the stated value is the real ceiling. The per-minute limits use fixed one-minute windows, so a burst straddling two windows can reach twice the value; `Retry-After` gives the number of seconds until the current window ends.215216## Request size217218The declared size of a request body is checked before the body is read.219220| Endpoint | Maximum body |221|---|---|222| `POST /v1/sessions/{id}/document` | 12 MB for the file, plus 512 KB for the multipart envelope |223| `POST /v1/sessions/{id}/selfie` | 24 frames of 3 MB, plus 512 KB |224| Any other `POST`, `PUT` or `PATCH` | 256 KB |225226A larger body is answered `413 payload_too_large` and the connection is closed. A body sent with `Transfer-Encoding` and no `Content-Length` is answered `411 length_required`.227228## Sandbox and live mode229230| | Sandbox (`mlid_sk_test_…`) | Live (`mlid_sk_live_…`) |231|---|---|---|232| Documents and selfies | Never accepted (`sandbox_no_real_documents`) | Uploaded by the person |233| Result | Chosen scenario, flagged `simulated: true` | Computed by the engines |234| Assurance level when verified | `sandbox_simulated` | See below |235| Compliance gates | Not required | `live_document` must be open; biometric methods also need `live_biometric` |236| Webhooks | Delivered to sandbox endpoints only | Delivered to live endpoints only |237238Sandbox scenarios (`POST /v1/sessions/{id}/sandbox`):239240| `scenario` | Resulting status | Reasons |241|---|---|---|242| `verified` | `verified` | `simulated` |243| `manual_review` | `manual_review` | `simulated`, `authenticity_indicators` |244| `inconclusive` | `inconclusive` | `simulated`, `capture_quality_insufficient` |245| `rejected` | `rejected` | `simulated`, `document_expired` |246247A sandbox result must never unlock anything in a production system: check `livemode` and `simulated`.248249## Objects250251### Verification session252253```json254{255  "id": "vs_…",256  "object": "verification_session",257  "status": "created",258  "livemode": false,259  "external_user_id": "user_42",260  "purpose": "Publish listings",261  "verification_policy": "identity_document_face_v1",262  "policy_version": "1.0",263  "locale": "fr-CA",264  "return_url": "https://app.example/verify/return",265  "method": null,266  "metadata": {},267  "verification_id": null,268  "created_at": "2026-12-01T14:00:00+00:00",269  "expires_at": "2026-12-01T15:00:00+00:00",270  "completed_at": null271}272```273274Statuses:275276| Status | Meaning |277|---|---|278| `created` | Waiting for the person to choose a method and consent |279| `awaiting_document` | Consent recorded; waiting for the document |280| `awaiting_selfie` | Front of the document received; waiting for the selfie (biometric method) |281| `processing` | Submitted; analysis in progress |282| `manual_review` | A person must review the case |283| `verified`, `inconclusive`, `rejected` | Decision made |284| `expired` | Not completed before `expires_at` |285| `cancelled` | Cancelled by the application, or consent withdrawn by the person |286| `revoked` | The verification was revoked after being verified |287288### Verification289290```json291{292  "verification_id": "ver_…",293  "object": "verification",294  "session_id": "vs_…",295  "status": "verified",296  "assurance_level": "document_check",297  "method": "document_only",298  "verification_policy": "identity_document_v1",299  "policy_version": "1.0",300  "livemode": true,301  "simulated": false,302  "external_user_id": "user_42",303  "reasons": [],304  "dimensions": {305    "document_quality": { "status": "pass" },306    "document_consistency": { "status": "pass" },307    "authenticity_indicators": { "status": "pass" },308    "face_match": { "status": "not_applicable" },309    "liveness": { "status": "not_applicable" },310    "session_integrity": { "status": "pass" },311    "technical_risk": { "status": "pass" }312  },313  "decision_engine": "risk-1.0",314  "created_at": "…",315  "verified_at": "…",316  "expires_at": "…",317  "revoked_at": null,318  "personal_data_deleted_at": null319}320```321322- `status`: `verified`, `inconclusive`, `rejected`, `manual_review`, `revoked`.323- `assurance_level` (only when `verified`): `document_check`, `document_face_liveness_check`, `document_manual_review`, `document_face_manual_review`, `sandbox_simulated`.324- `dimensions[*].status`: `pass`, `review`, `fail`, `not_assessed`, `not_applicable`. Scores are never returned.325- `expires_at`: a verification is valid for the policy's `validity_days` (365 by default).326- The object never contains a name, a document number, a date of birth, an image or any biometric data.327328Reason objects are `{ "code": "…", "message": { "fr": "…", "en": "…" } }`. Codes:329330`document_type_not_permitted`, `unknown_document_type`, `document_type_not_accepted`, `capture_quality_insufficient`, `machine_zone_unreadable`, `document_expired`, `document_inconsistent`, `authenticity_indicators`, `face_not_usable`, `face_uncertain`, `face_mismatch`, `liveness_uncertain`, `liveness_failed`, `accessible_path`, `human_review_method`, `technical_risk`, `face_thresholds_not_calibrated`, `decision_overturned`, `review_not_completed`, `engine_unavailable`, `simulated`, `reviewer_decision`.331332Treat the list as open: new codes may be added. Two of them describe a decision that changed after the fact:333334- `review_not_completed`: the case was sent to a reviewer and was not handled before its deadline (72 hours by default). The images are destroyed, the verification becomes `inconclusive`, and the person may start again with a new session.335- `decision_overturned`: the person contested a `rejected` or `inconclusive` decision and a reviewer set it aside. The verification becomes (or stays) `inconclusive`, a `verification.inconclusive` event is emitted, and the person may verify again with a new session. A contested decision is never turned into `verified`.336337## Server-to-server endpoints338339### Create a verification session340341`POST /v1/verification-sessions` — scope `sessions:write`.342343| Field | Type | Required | Notes |344|---|---|---|---|345| `purpose` | string | yes | Shown to the person; 120 characters at most |346| `verification_policy` | string | no | Default `identity_document_face_v1`. Built-in: `identity_document_v1` (document only), `identity_document_face_v1` (document and selfie, or document reviewed by a person) |347| `external_user_id` | string | no | Your opaque identifier, 200 characters at most. Never an e-mail address, a name or a phone number |348| `return_url` | string | no | In live mode it must match an allowed redirect URL of the application (exact match, or that URL followed by `/` or `?`). In sandbox, the same rule applies when the application has allowed redirect URLs; otherwise any https URL, `http://localhost` or `http://127.0.0.1` is accepted |349| `locale` | string | no | Default `fr-CA`. A value starting with `en` selects English |350| `metadata` | object | no | 2000 bytes at most once serialised. Do not put personal information in it |351| `expires_in_minutes` | integer | no | 10 to 1440, default 60 |352353```bash354curl https://identity.spboucher.ai/v1/verification-sessions \355  -H "Authorization: Bearer $MLID_SECRET_KEY" \356  -H "Idempotency-Key: 5c1f0d3e-publish-user-42" \357  -H "Content-Type: application/json" \358  -d '{"purpose": "Publish listings", "external_user_id": "user_42", "return_url": "https://app.example/verify/return"}'359```360361The response is the session object plus two fields returned only here:362363| Field | Use |364|---|---|365| `client_secret` | `vsc_…`, for the session flow |366| `url` | Hosted page: `https://identity.spboucher.ai/verify/{id}#{client_secret}`. Send it to that user's browser |367368The secret is in the URL fragment, which browsers do not send to the server when loading the page.369370### Retrieve, list, cancel371372| Call | Scope | Notes |373|---|---|---|374| `GET /v1/verification-sessions/{id}` | `sessions:read` | |375| `GET /v1/verification-sessions` | `sessions:read` | Filters: `status`, `external_user_id`; pagination |376| `POST /v1/verification-sessions/{id}/cancel` | `sessions:write` | Destroys every uploaded image, fails any queued analysis, emits `verification.cancelled`. Refused (`409 session_not_cancellable`) once the session is final or in manual review |377378### Verifications379380| Call | Scope | Notes |381|---|---|---|382| `GET /v1/verifications/{id}` | `verifications:read` | |383| `GET /v1/verifications` | `verifications:read` | Filters: `status`, `external_user_id`; pagination. Use `external_user_id` to know whether a user is verified |384| `GET /v1/verifications/{id}/status` | `verifications:read` | Minimal answer, see below |385| `POST /v1/verifications/{id}/revoke` | `verifications:write` | Body `{ "reason": "…" }` (optional, 200 characters kept). Only from `verified`; revoking twice returns the same object |386| `DELETE /v1/verifications/{id}/personal-data` | `verifications:write` | Destroys the images, the extracted fields and the dispute message that still exist. The minimal result remains. Accepts `Idempotency-Key` |387388Status answer:389390```json391{ "verification_id": "ver_…", "status": "verified", "valid": true, "assurance_level": "document_check", "expires_at": "…" }392```393394`valid` is `true` only when the status is `verified` and `expires_at` is in the future. Gate sensitive actions on `valid`, and treat any error or timeout as not verified.395396Deletion answer:397398```json399{ "verification_id": "ver_…", "deleted": true, "artifacts_destroyed": 0, "extracted_destroyed": 0 }400```401402If the verification was in manual review, the open review case is closed, the verification becomes `inconclusive` and its session `cancelled`. A `verification.inconclusive` event is emitted for that change.403404### Webhook endpoints405406| Call | Notes |407|---|---|408| `POST /v1/webhooks` | Body `{ "url": "https://…", "events": ["*"], "description": "…" }`. Returns the endpoint and its `secret` (`whsec_…`), shown once |409| `GET /v1/webhooks` | Endpoints of the key's application and mode |410| `DELETE /v1/webhooks/{id}` | Accepts `Idempotency-Key`. Returns `{ "id": "we_…", "deleted": true }` |411| `POST /v1/webhooks/{id}/rotate-secret` | Returns the new `secret`. For 24 hours each delivery is signed with both secrets |412413All require the scope `webhooks:manage` and act only on endpoints of the key's own mode. The URL must be https and resolve to a public address. At most 16 endpoints per application and mode.414415Endpoint object:416417```json418{ "id": "we_…", "object": "webhook_endpoint", "url": "https://app.example/webhooks/identity", "events": ["*"], "status": "enabled", "livemode": false, "description": "", "created_at": "…" }419```420421## Session flow endpoints422423Used by the hosted page and by the native SDKs, authenticated with the session client secret. An application integrating through the hosted page never calls them. They are the same in sandbox and live mode, except where stated.424425| Call | Purpose |426|---|---|427| `GET /v1/sessions/{id}` | Flow state |428| `POST /v1/sessions/{id}/consent` | Choose a method and consent |429| `POST /v1/sessions/{id}/document` | Upload one side of the document (live only) |430| `POST /v1/sessions/{id}/selfie/challenge` | Get a liveness challenge (live only) |431| `POST /v1/sessions/{id}/selfie` | Upload the selfie frames (live only) |432| `POST /v1/sessions/{id}/submit` | Submit for analysis (live only) |433| `POST /v1/sessions/{id}/sandbox` | Complete with a simulated scenario (sandbox only) |434| `POST /v1/sessions/{id}/withdraw` | Withdraw consent; everything is destroyed |435| `POST /v1/sessions/{id}/dispute` | Contest a decision |436437### Flow state438439`GET /v1/sessions/{id}` returns:440441| Field | Content |442|---|---|443| `id`, `status`, `livemode`, `locale`, `purpose`, `return_url`, `method`, `expires_at` | Session fields |444| `application` | `name`, `logo_url`, `accent` (branding set by the application) |445| `methods` | Each offered method: `id`, `biometric`, `label`, and `consent` texts in `fr` and `en` (`version`, `title`, `body`, `checkbox`, `points`, `controller`). The `points` state the application's actual retention settings |446| `controller` | Name, contact and privacy page of the service operator |447| `sandbox` | `null` in live mode; otherwise the list of scenarios |448| `uploaded`, `selfie_done` | What has been received |449| `attempts_left`, `max_attempts` | Remaining and total submissions |450| `last_issue` | Reasons of the last capture that had to be retaken |451| `document` | `front: "required"`, `back: "required_for_cards"`, `accepted` (document template identifiers accepted by the policy: `passport_td3`, `id_card_td1`, `ca_driver_licence`), `back_required_for` (the subset of `accepted` that needs the back side, with the same identifiers) |452| `result` | Present after a decision: `status`, `reasons`, `verified_at`. Absent once the session is `cancelled` |453454### Consent455456```json457{ "method": "document_selfie", "accepted": true, "text_version": "2026-12-01.2", "biometric_consent": true, "locale": "fr-CA" }458```459460- `text_version` must equal the `version` of the consent text that was displayed. Read it from the flow state; never hard-code it. The current value is also exposed as `consent_version` by `GET /health`.461- `biometric_consent: true` is mandatory for `document_selfie`.462- The method can be changed until submission: images already uploaded are destroyed and the previous consent is marked withdrawn.463464### Document465466`multipart/form-data` with `side` (`front` or `back`) and `file` (JPEG, PNG or WebP, 12 MB at most).467468```json469{ "accepted": true, "side": "front", "issues": [], "status": "awaiting_selfie" }470```471472A capture of insufficient quality is answered with `200` and `accepted: false`; nothing is stored. Issues: `resolution_too_low`, `image_blurry`, `image_too_dark`, `image_overexposed`, `low_contrast`. Uploading a side again replaces the previous image.473474Send the photograph at full resolution, not a frame of the video preview: the short side must be at least 600 px to be accepted, and a dense PDF417 barcode on a driver's licence needs much more to be read (the hosted page and the native SDKs warn under 1000 px). Images are scaled down to 3600 px on their long side.475476### Liveness challenge and selfie477478`POST /v1/sessions/{id}/selfie/challenge` with `{}` or `{ "accessible": true }`:479480```json481{ "challenge_id": "chl_…", "steps": ["turn_left", "turn_right"], "accessible": false, "expires_in": 120, "frames": { "min": 8, "max": 24, "interval_ms": 250 } }482```483484- A challenge is single-use and expires after 120 seconds.485- The accessible path has no step, needs 3 to 24 frames, and always leads to review by a person.486487`POST /v1/sessions/{id}/selfie` is `multipart/form-data` with `challenge_id` and `frames` repeated (8 to 24 images in capture order, 3 MB each at most, short side of 320 px or more). Answer: `{ "accepted": true, "frames": 12 }`.488489### Submit, withdraw, dispute490491- `POST …/submit` moves the session to `processing` and returns the flow state. Poll `GET /v1/sessions/{id}` until `result` appears. When the capture must be retaken, the session returns to `awaiting_document` with `last_issue` filled.492- `POST …/withdraw` returns `{ "id": "vs_…", "status": "cancelled", "destroyed": true }`. It is allowed until a decision is made, including while the session is in manual review: the review case is then closed without a decision, the images and extracted fields are destroyed, the verification becomes `inconclusive`, and two events are emitted, `verification.inconclusive` (verification object) and `verification.cancelled` (session object). It is refused (`409 session_not_cancellable`) once the session is final.493- `POST …/dispute` with `{ "message": "…" }` (5 to 2000 characters) returns `{ "id": "dsp_…", "status": "open" }`. The message is stored encrypted and destroyed when a reviewer closes the dispute. The reviewer either maintains the decision or sets it aside (see `decision_overturned`).494495## Webhooks496497### Event498499```json500{501  "id": "evt_…",502  "object": "event",503  "type": "verification.verified",504  "api_version": "2026-12-01",505  "created": 1796133600,506  "livemode": false,507  "data": { "object": { "verification_id": "ver_…", "object": "verification", "status": "verified", "…": "…" } }508}509```510511### Event types512513| Type | `data.object` | Emitted when |514|---|---|---|515| `verification.created` | session | A session is created |516| `verification.processing` | session | The session is submitted |517| `verification.completed` | verification | Any decision other than manual review is recorded |518| `verification.verified` | verification | Decision `verified` (automatic or by a reviewer) |519| `verification.inconclusive` | verification | Decision `inconclusive`, including an engine failure, a review case that reached its deadline, a contested decision set aside, and a withdrawal or a personal-data deletion during manual review |520| `verification.rejected` | verification | Decision `rejected` |521| `verification.manual_review` | verification | The case is sent to a reviewer |522| `verification.expired` | session | The session expired before submission |523| `verification.cancelled` | session | Cancelled by the application, or consent withdrawn (including during manual review) |524| `verification.revoked` | verification | A verification is revoked |525526A final decision therefore produces two events: `verification.completed` and the event of its status. The `verification.inconclusive` events caused by a withdrawal, a deletion or a set-aside decision come alone, without `verification.completed`. Subscribe with a list of types or `["*"]`, and ignore types you do not know.527528Events are kept 90 days on the service side.529530### Delivery531532- `POST` to your URL with the JSON body, `Content-Type: application/json`, `User-Agent: MacLustr-Identity-Webhooks/1.0`.533- Headers: `MLID-Event-Id`, `MLID-Delivery-Id`, `MLID-Event-Type`, `MLID-Signature`.534- Success is any `2xx` answer within 10 seconds (5 seconds to connect). Redirects are not followed.535- On failure, the delivery is retried after 30 s, 2 min, 10 min, 30 min, 2 h, 6 h, 12 h and 24 h (nine attempts in all), then marked `failed`. An operator can retry it from the console.536- Delivery is at-least-once and unordered: deduplicate on the event `id`, and do not let an older event overwrite a newer state.537- The destination is checked again before each delivery; a URL that now resolves to a private or local address is not called.538539### Signature540541```542MLID-Signature: t=1796133600,v1=5257a8…[,v1=…]543```544545- `t`: Unix time of the delivery attempt.546- `v1`: hexadecimal HMAC-SHA-256 of the bytes `"{t}." + raw request body`, keyed with the endpoint secret (the whole `whsec_…` string, UTF-8).547- During the 24 hours after a secret rotation there are two `v1` values, one per secret. Accept the delivery if any `v1` matches.548- Reject a delivery whose `t` is more than 300 seconds away from your clock.549550Always compute the signature on the raw body, before any JSON parsing, and compare in constant time. The SDKs implement this (`constructEvent`); the samples below show the scheme without them.551552Python:553554```python555import hashlib, hmac, time556557def verify(secret: str, header: str, raw_body: bytes, tolerance_s: int = 300) -> bool:558    try:559        parts = [p.split("=", 1) for p in header.split(",") if "=" in p]560        ts = int(next(v for k, v in parts if k == "t"))561    except (StopIteration, ValueError):562        return False563    if abs(time.time() - ts) > tolerance_s:564        return False565    expected = hmac.new(secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest()566    return any(hmac.compare_digest(expected, v) for k, v in parts if k == "v1")567```568569Node.js:570571```js572import { createHmac, timingSafeEqual } from "node:crypto";573574export function verify(secret, header, rawBody, toleranceSec = 300) {575  const parts = String(header || "").split(",").map((p) => p.split(/=(.*)/s).slice(0, 2));576  const ts = Number((parts.find(([k]) => k === "t") || [])[1]);577  if (!Number.isInteger(ts) || Math.abs(Date.now() / 1000 - ts) > toleranceSec) return false;578  const expected = createHmac("sha256", secret).update(`${ts}.`).update(rawBody).digest();579  return parts.some(([k, v]) => {580    if (k !== "v1") return false;581    const got = Buffer.from(v || "", "hex");582    return got.length === expected.length && timingSafeEqual(got, expected);583  });584}585```586587`rawBody` is a `Buffer` holding the request body exactly as received.588589## Health590591| Call | Answer |592|---|---|593| `GET /health` | `{ "status": "ok", "service": "maclustr-identity", "version": "1.0.0", "consent_version": "2026-12-01.2" }` |594| `GET /health/ready` | `status`, `environment`, `workers_online`, `jobs_queued`, `live_document`, `live_biometric`; `503` when the database is unreachable |595596Both are public. `/health/ready` therefore discloses whether live mode is open and how many workers are online.597598## Not in this API599600- No endpoint returns extracted document fields, images or scores to an application.601- No endpoint lists events; events are available through webhooks only.602- There is no CORS support: the API is meant to be called from servers, and the session flow from the hosted page or the native SDKs.603- The console API (`/api/console/…`) is for the operator interface and is not a public contract.604
Files main
Menu

Theme