Create an authentication attempt
Creates an authentication attempt, one sign-in round that expires 15 minutes after creation.
An authentication attempt collects the proofs for one sign-in and ends in a handoff token. A handoff token is the short-lived, single-use credential that a completed attempt hands to the session exchange. A client makes these calls in order:
createAuthAttempt(POST /auth_attempts) creates the attempt.createAuthAttemptChallenge(POST /auth_attempts/{attempt_id}/challenges) issues a challenge, a request to prove one factor such asidentifier,passwordorpasskey.verifyAuthAttemptChallenge(POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify) submits the proof for that challenge: the credential, code or assertion. Repeat steps 2 and 3 untilgetAuthAttempt(GET /auth_attempts/{attempt_id}) reports statecompleted, which means every factor inrequired_factorsis verified.createAuthAttemptHandoff(POST /auth_attempts/{attempt_id}/handoff) completes the attempt and returns thehandoff_token.exchangeHandoff(POST /sessions/exchange) exchanges the handoff token for the session and itssession_token.
The body takes a project_id and a challenge_nonce (from
POST /bootstrap/challenge). For step-up authentication, which adds factors
to an existing session, also send that session's session_id and its
session_token, as createSession (POST /sessions) or exchangeHandoff returned them.
The attempt's attempt_id in the response is the ID every later call takes.
The project comes from the project secret. A body project_id that names
another project answers 403 with proj.mismatch: send the credential's own
project. The attempt seals the project's newest primary deployment, whatever
the caller's Origin. With none it answers 409 with rel.no_default, and a
revoked release answers 409 with rel.revoked.
oauth2 auth_attempt.writeAuthorizationBearer <token>Scope: auth_attempt.write
application/json- body
Request to create an authentication attempt.
project_id*project-id^[a-zA-Z0-9_-]+$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?|Optional. If provided, this attempt adds factors to an existing session (step-up authentication).
If omitted, a new session is created implicitly when the handoff is exchanged.
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.
passwordThe created authentication attempt.
application/json- response
The current state of an authentication attempt.
An authentication attempt is one sign-in round, and it expires 15 minutes after creation. It accepts factor challenges, verifies proofs and completes into a handoff token. Clients drive the attempt by:
- Issuing challenges:
POST /auth_attempts/{attempt_id}/challenges - Verifying proofs:
POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify - Completing:
POST /auth_attempts/{attempt_id}/handoff
attempt_id*attempt-idThe unique identifier of this authentication attempt, an opaque string with an att_ prefix.
^att_[a-zA-Z0-9_-]+$project_id*project-id^[a-zA-Z0-9_-]+$state*stringOverall state of the authentication attempt:
in_progress: factors are still being collected; continue issuing challenges.completed: all required factors have been verified; the attempt is ready for handoff.failed: the attempt has failed, for example after too many failed proofs, and cannot be continued.expired: the attempt's 15-minute lifetime has passed.
"in_progress""completed""failed""expired"session_id?|The session being authenticated into. Either newly created or passed in on POST.
For step-up authentication, this is the existing session_id provided on creation.
user_id?|The user ID, if known at this point in the flow. Null until an identifier challenge has been verified.
required_factors?array<>The authentication factor methods that the project policy requires to complete this attempt. The server computes them from the project's authentication policy. Use them to decide which challenges still need to be issued.
completed_factors?array<>The factors verified in this attempt so far.
Each item includes method-specific metadata in the payload field.
The server uses the verified_at timestamps to enforce time-based policies.
One example is requiring a password verified within the last 5 minutes for
step-up authentication to reach sensitive operations.
A factor appears here once its challenge reaches verified state.
challenges?array<>All challenges issued within this attempt, in creation order. Use them to track the state of each factor challenge: pending, verified, failed or expired.
expires_at?stringWhen this attempt expires, 15 minutes after creation.
date-timecreated_at*stringWhen this attempt was created.
date-timeimport { createZitadelApi, ZitadelClient } from "@zitadel/api/client";const api = createZitadelApi( new ZitadelClient({ baseUrl: process.env.ZITADEL_URL ?? "http://localhost:8080", token: process.env.ZITADEL_PROJECT_SECRET!, // server-side only }),);const authAttempt = await api.createAuthAttempt({ project_id: "string" });{ "attempt_id": "string", "project_id": "string", "state": "in_progress", "session_id": "string", "user_id": "string", "required_factors": [ "identifier" ], "completed_factors": [ { "method": "identifier", "verified_at": "2019-08-24T14:15:22Z", "payload": { "method": "identifier", "user_id": "string" } } ], "challenges": [ { "challenge_id": "string", "method": "identifier", "state": "pending", "created_at": "2019-08-24T14:15:22Z", "expires_at": "2019-08-24T14:15:22Z", "payload": {} } ], "expires_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z"}Was this helpful?