Skip to content

Mint a throwaway preview session for the KYC policy editor

POST/v1/kyc/policy/draft/preview-session

Requires an API client bearer token.

Mints a short-lived (15 minute), throwaway preview session so the console's step-through preview pane can render the open editor draft — or, when no draft exists, the current active policy as-is — inside the real hosted capture widget. `source` reports which one was actually used. `capture_url` uses the SAME URL shape `POST .../capture-session` produces, but its `#token=preview` fragment is never redeemable: no `capture_sessions` row is ever created for a preview mint. No `Idempotency-Key` is required — every call mints a brand-new, independently expiring session. 400s `unknown_flow` for a `flow_key` naming no lineage. A draft carrying a `workflow` previews with the level snapshots publishing would take, and is refused exactly as publish refuses it: 409 `level_unavailable`, 400 `invalid_workflow`. 503s with problem code `preview_unavailable` when this environment has no console origin configured to frame a preview session. The LEVEL form (`level: { level_key, display_name, definition }`, optional `screen`) previews one level as the editor holds it — saved or not — as a one-level workflow, with `source: level`; `flow_key` then only picks the branding (default `default`), `screen` names the screen key to open on, and a definition that does not validate is a 400 `invalid_level` with `problems`. Requires the programme_admin role and shares `PUT .../draft`'s looser rate-limit class.

Request body

One of

Option 1

programme_idstring (uuid)required
flow_keystring

Option 2

programme_idstring (uuid)required
flow_keystring
levelobjectrequired
+ show properties
level_keystringrequired
display_namestringrequired
definitionunknown
screenstring

Example

curl -X POST https://api.rigid.fi/v1/kyc/policy/draft/preview-session \
  -H "Authorization: Bearer $RIGID_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "programme_id": "uuid"
}'

Responses

200

A minted, throwaway preview session and ready-made capture-widget URL.

session_idstring (uuid)required
capture_urlstring (uri)required
expires_atstring (date-time)required
source"draft" | "active" | "level"required
flow_keystringrequired
400

Validation error

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring
401

Authentication required

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring
403

Forbidden

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring
409

A level the draft workflow references is missing or archived (code `level_unavailable`, `levels`)

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring
500

Internal server error

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring
503

No console origin is configured to frame a preview session (`code: preview_unavailable`) — this environment has no `KYC_PREVIEW_FRAME_ORIGIN` set.

typestringrequired
titlestringrequired
statusintegerrequired
detailstring
instancestring