Handles `POST /v1/verifications/sessions`.
Runs the checks the tenant’s policy requires and returns the outcome. A provider outage is not an error here: it produces a review-required session, because an unreachable model says nothing about the person.
Which answer a request gets
Supplying selfie_ref or document_ref runs the session now and answers
[VerificationSessionOutcomeBody::Decided] - a decision, its reasons, and
the per-check results. Supplying neither opens a hosted capture link and
answers [VerificationSessionOutcomeBody::Opened], where nothing has been
decided and status is always AWAITING_CAPTURE; the decision arrives
later, by webhook.
Errors
Returns 401 without usable credentials, 403 when the caller may not
submit verifications, 422 when the body cannot be acted on - an unknown
intent; a subject_id that is empty, over 200 characters or carries a
control character (SUBJECT_INVALID / SUBJECT_TOO_LONG); a state over
256 characters or with a control character (STATE_TOO_LONG /
STATE_INVALID); an unusable capture - 404 / 409 for a flow that
cannot open sessions, and 503 when a store the decision depends on
cannot be reached.
Authorizations
Body
Request to run a verification session.
Person being verified, as the customer identifies them: non-empty, at
most 200 characters, no control characters (422 SUBJECT_TOO_LONG /
SUBJECT_INVALID otherwise). Under a flow with a return URL it is
sent back as kyc_id in the redirect - but only when made of ASCII
letters, digits, -, _, . and ~ and not a run of eight or more
digits alone; any other value is kept out of the URL and the
RESULT_CODE_ISSUED audit event says so (kyc_id_omitted). The URL
reaches browser history and access logs, so use an opaque reference,
never something that identifies the person on its own.
FIRST_TIME (the default) or REVERIFICATION.
A first-time verification is proven against the document; a reverification against the face proven when the customer first passed. Defaulting to first-time is the safe direction: it never lets a stored face stand in as identity proof by omission.
Response
A decision when captures were supplied, or a capture link when they were not
- Option 1
- Option 2
What POST /v1/verifications/sessions answers with.
The route has two answers because it has two jobs. Supplying captures runs the session now and returns what was decided; supplying none opens a hosted capture link and returns where to send the person, with nothing decided yet. Untagged, so the body is the shape itself rather than the shape wrapped in a discriminator - which is what callers already parse.
Naming the two removes a serde_json::to_value(..).unwrap_or_default()
from each path. That turned a serialisation failure into 200 with a body
of null: a success status carrying nothing, which a caller has no way to
tell from a session that legitimately answered nothing.

