Start a flow
Starts a flow: resolves a flow definition from the request's purpose and audience, and returns the first step.
The flow endpoints are the runtime calls the login component
(<zitadel-login>) makes, step by step. It starts a flow here, renders the
step it gets back, and submits the user's input with submitFlowStep (POST /flows/{flow_id}/submit) to
get the next step. This call creates a new session implicitly, unless
session_id is provided together with that session's session_token
(for step-up or reauthentication on an existing session).
The browser Origin header selects which deployment serves this attempt.
The server checks the origin against the project's origin patterns and live
previews, and the deployment that origin serves is the target: the
project's newest primary deployment when it names a primary origin, or the
newest live deployment to a preview URL. A
deployment is a release, the immutable bundle of the project's
configuration, made live at an origin. The deployment's release supplies
flow definitions, user schemas and branding. The resolved deployment is
sealed into the flow's cookie so later steps keep the same
configuration.
- An origin that matches no pattern answers
403withproj.origin_not_allowed, including when the project lists no origins. Add the origin withzitadel origin add. - An origin that matches a preview pattern with no live preview answers
403withproj.preview_not_live. Runzitadel previewon the branch. - Nothing deployed to a listed origin or a live preview answers
409withrel.not_deployed. Runzitadel deploy: a primary origin added since the last deploy serves nothing until the next one. - A loopback origin the project does not list answers
409withrel.not_deployedtoo, as no deployment can name it. Add it withzitadel origin add <origin> --kind primary, then runzitadel deploy. - A revoked release answers
409withrel.revoked.
A request with no Origin passes the check, and so does the server's own
origin, from which its console previews a project's login. Both are served
the project's newest primary deployment unless the project lists that
origin; with no primary deployment they answer 409 with
rel.no_default. A loopback origin passes the check and is its own
target. A step submitted from the server's own origin is still refused
unless the project lists it.
The response contains an id field, the flow handle. Use it as the path
parameter for all subsequent /flows/{flow_id}/submit calls.
The response also sets an encrypted HttpOnly cookie, _zflow_{id},
containing the flow's orchestration state (current step, collected
data, history). The server is stateless between requests: all flow state
lives in this cookie. The browser sends it automatically on subsequent
requests. Each flow has a cookie of its own, so two sign-ins in one
browser do not end each other. A browser keeps at most three: starting
a flow deletes the oldest flow cookies the request carried beyond that,
and ends their flows.
A flow for an authorization request can end as it starts: the step is
terminal, with complete: redirect, and no cookie is set, since nothing
is left to continue. See auth_request_id.
Origin?stringStandard browser Origin header. Selects the deployment that serves
this attempt: matched against the project's origin patterns and live
previews, then against the deployment that origin serves.
Browsers send it automatically; no client action is required. Absent
when the caller is not a browser.
uriapplication/json- body
The request body for starting a flow.
project_id*project-id^[a-zA-Z0-9_-]+$purpose*stringWhat the user is doing. It selects the entry step the flow definition lists for this purpose.
"login""register""recovery""profiling""reauth""link_account"flow_definition_name?stringName of a specific flow definition to use. When omitted, the server selects the best-matching definition based on purpose + audience context.
^[a-z][a-z0-9-]*$dry_run?booleanSet to true to simulate the flow without actually creating any
user or session. Useful for testing and validation of flow definitions.
This requires setting the flow_definition_name property as well.
falseschema_version?stringSemver version of the flow definition JSON Schema to use. When omitted, the latest version is used.
^\d+\.\d+\.\d+$challenge_nonce?challenge-nonceOrigin-bound, single-use nonce obtained from POST /bootstrap/challenge.
Binds the request to the browser that initiated the flow, preventing
cross-origin replay.
session_id?stringExisting session to attach to, for step-up or reauthentication.
Omit to let the flow create a new session implicitly.
Requires session_token.
session_token?session-proof-tokenThe session_token of the session the request runs against, as
POST /sessions or POST /sessions/exchange returned it. It proves the
caller holds that session. Required with session_id, and must belong to the
same session and project; with session_token alone, the request runs
against the token's session. A missing, foreign, expired or revoked token is
refused with the same invalid-request error, whether or not the session
exists.
passwordauth_request_id?stringThe handle of the OAuth authorization request this flow answers: the
auth_request query parameter the authorization endpoint sent the
browser to the login page with. The login component sends it; page
code never needs to.
The handle alone opens nothing. The flow starts only from the browser
the authorization endpoint redirected, which holds the cookie that
endpoint set for the request, on the issuer's origin, and only while
the request is open: not expired, and not answered. Anything else
answers 400 with flow.auth_request_invalid, and the client starts
its sign-in again.
A request expires 15 minutes after the authorization endpoint
redirected the browser, however long its flow takes. The flow's own
cookie is renewed on every step, the request is not: a sign-in that
is still going at minute 15 fails on the step that would answer the
request, with the same 400.
The request shapes the flow. One that says prompt=create starts the
project's registration in place of purpose: in the definition
flow_definition_name names, else in the one the audience picks. It
signs the user in as purpose says when the project has no
registration. Its login_hint takes the place of hint.login_name.
A flow that signs the user in ends in a redirect to the client,
whatever its terminal step says: redirect_uri is the client's
registered redirect URI with code, state and iss. Exchange the
handoff_token before navigating there, because the code buys a
token only once the session it is bound to holds the sign-in. For a
client that is not the project's own, and for the project's own when
the request says prompt=consent, the server inserts a consent
step before that (step.consent).
A user already signed in needs no page to sign in. A flow of purpose
login ends at once in a redirect that carries the code, with no
handoff_token, when the browser's session cookie holds an active
session of the project and all of these hold:
- its user is active, of the flow definition's user schema, and the
one the request's
login_hintnames, when it names one; - the user last signed in within the request's
max_age; - the client holds a secret, or its answer goes to an
httpsaddress that is not a loopback one; - the client needs no consent, or the user already gave it for every scope the request asks.
prompt=login, prompt=select_account and prompt=create ask for a
page all the same. A request that says prompt=none and cannot be
answered so ends at once too, with error=login_required, or
error=consent_required when the client needs consent. So does one
no flow definition resolves for, with error=login_required. A
refusal spends the request: a later flow for it is refused with
400. A flow that ends at once runs against no session of its own:
session_id is the live session's, or empty for a refusal. It has
no handoff_token and sets no flow cookie, so navigate to
redirect_uri at once; for a refusal it carries error in place of
code.
redirect_uri?stringThe page a finished sign-in sends the browser to, when its terminal
step is redirect. It must be on the origin that sent the request,
as an absolute URL or a path such as /dashboard, so a request
without an Origin header cannot set it. A target a browser could
read as another host (a leading //, a backslash, an encoded dot or
slash, userinfo, a non-http(s) scheme) is refused with
req.invalid. Not allowed together with auth_request_id: an
authorization request already carries the client's registered
redirect URI.
length <= 2048hint?Optional hints that narrow how the server resolves and starts a flow.
The started flow, with its first step.
application/json- response
The state of a flow, with its handle, its session and the step to render.
id*stringFlow handle. Use this as the path parameter for subsequent
submit/event calls. May change between responses when a
flow pivot or pop occurs. Empty when a prompt=none request is
refused because no flow can start for it: nothing is left to submit.
session_id*stringUnderlying session ID. Stable across all stacked flows. Empty when a flow for an authorization request ends as it starts with a refusal, which no session is behind; the browser's live session when it ends with the code.
session_token?stringReserved for future rotation. The flow's sealed _zflow_{flow_id} cookie carries the flow state today.
step*The step the login component renders now. A step is one screen of a flow.
It holds ordered arrays of what to collect (fields), what the user can do
(actions), and which security checks must pass (gates). The LiquidJS template
in branding.liquid_template iterates these arrays in order and builds
name-keyed indexes locally for lookup.
branding?Resolved branding inherited from the app → team → project hierarchy. Determined at flow creation based on audience context. Does not change between steps.
client?The client whose authorization request the flow answers. Present on
every response of a flow started with auth_request_id, absent on
any other.
redirect_uri?stringPresent when step.complete is redirect.
urihandoff_token?stringShort-lived, audience-bound token produced on flow completion.
Exchange it for a session via POST /sessions/exchange.
Only present when step.complete is set.
handoff_token_expires_at?stringExpiry timestamp for handoff_token. Only present when
handoff_token is set.
date-timeimport { createZitadelApi, ZitadelClient } from "@zitadel/api/client";const api = createZitadelApi( new ZitadelClient({ baseUrl: process.env.ZITADEL_URL ?? "http://localhost:8080", }),);const flow = await api.createFlow({ project_id: "string", purpose: "login" });{ "id": "string", "session_id": "string", "session_token": "string", "step": { "name": "string", "texts": { "title_key": "string", "description_key": "string" }, "purpose": "login", "notice": "string", "error": "string", "complete": "redirect", "redirect_url": "http://example.com", "fields": [], "identifier": { "value": "string", "autocomplete": "string" }, "actions": [], "gates": {}, "sso_providers": [], "challenge": { "method": "passkey", "challenge_id": "string", "options": {} }, "consent": { "client": { "client_id": "string", "name": "string", "redirect_host": "string", "document_host": "string", "loopback": true }, "resource": "string", "scopes": [ { "name": "string", "group": "string", "access": "read", "selected": true, "text_key": "string" } ] } }, "branding": { "$schema": "string", "layout": "centered", "liquid_template": "string", "logo_url": "http://example.com", "hero_url": "http://example.com", "theme": { "mode": "light", "light": { "logo_url": "http://example.com", "palette": { "primary": "#4F46E5", "on_primary": "#4F46E5", "background": "#4F46E5", "surface": "#4F46E5", "muted": "#4F46E5", "border": "#4F46E5", "text": "#4F46E5", "text_muted": "#4F46E5", "link": "#4F46E5", "success": "#4F46E5", "warning": "#4F46E5", "error": "#4F46E5" } }, "dark": { "logo_url": "http://example.com", "palette": { "primary": "#4F46E5", "on_primary": "#4F46E5", "background": "#4F46E5", "surface": "#4F46E5", "muted": "#4F46E5", "border": "#4F46E5", "text": "#4F46E5", "text_muted": "#4F46E5", "link": "#4F46E5", "success": "#4F46E5", "warning": "#4F46E5", "error": "#4F46E5" } } }, "typography": { "font_family": "string", "font_url": "http://example.com", "scale": 0.75 }, "shape": { "radius": "none", "density": "compact", "logo_scale": 0.5 } }, "client": { "client_id": "string", "application_id": "string", "name": "string", "redirect_host": "string", "document_host": "string", "first_party": true }, "redirect_uri": "http://example.com", "handoff_token": "string", "handoff_token_expires_at": "2019-08-24T14:15:22Z"}Was this helpful?