Reference For: developers

API: auth

Operations of the auth tag of the native REST API.

Browser login (decision L-113): access token in the body, rotating refresh token in the HttpOnly cookie kyv_refresh (Path=/v1/auth), CSRF double submit with the kyv_csrf cookie and the X-Kyvernon-CSRF header, Origin checks, forced password change and TOTP enrolment, API tokens. See docs/control-plane/SECURITY.md

GET /v1/auth/api-tokens

The caller's API tokens.

CLI
kyvernon auth api-tokens list

Responses

StatusDescriptionSchema
200OKarray of ApiTokenView

POST /v1/auth/api-tokens

Creates an API token for the caller (shown once).

CLI
kyvernon auth api-tokens create <name>

Request body

application/json: CreateApiTokenRequest

NameTypeRequiredDescription
namestringyesLabel (1..=64 characters).
ttlSecondsinteger (int64) or nullLifetime in seconds, 1 up to the controller maximum ([identity.policy] api_token_max_ttl, 365 days unless configured otherwise). Absent: the maximum. Every token expires; a longer lifetime is refused (error.api_token.ttl).

Responses

StatusDescriptionSchema
201CreatedCreateApiTokenResponse

DELETE /v1/auth/api-tokens/{id}

Revokes one of the caller's API tokens.

CLI
kyvernon auth api-tokens delete <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the API token

Responses

StatusDescriptionSchema
204Done; no body
404Not found (or not visible to the caller)ErrorBody

GET /v1/auth/config

What the sign-in page needs before anyone is signed in (no authentication).

CLI
kyvernon auth config

Responses

StatusDescriptionSchema
200OKAuthConfigView

POST /v1/auth/login

Browser password login.

Request body

application/json: AuthLoginRequest

NameTypeRequiredDescription
passwordstringyesPassword.
usernamestringyesAccount name.

Responses

StatusDescriptionSchema
200Session (possibly restricted) or MFA challenge; token responses set the kyv_refresh and kyvernon_csrf cookiesAuthResponse
401error.auth.invalid_credentials (same answer for every reason)ErrorBody
403error.auth.originErrorBody
429error.auth.rate_limited, with Retry-AfterErrorBody

POST /v1/auth/logout

Ends the browser session (the whole token family) and clears the cookies.

Parameters

NameInTypeRequiredDescription
X-Kyvernon-CSRFheaderstringyesValue of the kyvernon_csrf cookie

Responses

StatusDescriptionSchema
204Logged out; cookies cleared
403error.auth.csrf or error.auth.originErrorBody

POST /v1/auth/mfa

Second factor for a pending browser login.

Request body

application/json: AuthMfaRequest

NameTypeRequiredDescription
codestring or nullSix-digit TOTP code.
pendingTokenstringyespendingToken from the login response (mfaToken is accepted as an alias).
recoveryCodestring or nullA recovery code.

Responses

StatusDescriptionSchema
200OKAuthResponse
400neither or both of code and recoveryCodeErrorBody
401error.auth.invalid_code or error.auth.mfa_expiredErrorBody
429Rate limited; Retry-After says when to retryErrorBody

POST /v1/auth/password

Changes the caller's password: every session of the account ends and the caller gets a new one (next stage: TOTP enrolment when still required).

CLI
kyvernon auth password

Request body

application/json: AuthPasswordRequest

NameTypeRequiredDescription
currentPasswordstringyesCurrent password.
newPasswordstringyesNew password (12..=256 characters, not common, not containing the username).

Responses

StatusDescriptionSchema
200New session; new cookiesAuthResponse
400error.password.* (too_short, too_long, common, repetitive, sequential, contains_username, unchanged, current_incorrect)ErrorBody
401Not authenticated, or the session is restricted (error.mfa_required, error.password_rotation_required)ErrorBody

POST /v1/auth/refresh

Rotates the refresh token and issues a new access token.

Parameters

NameInTypeRequiredDescription
X-Kyvernon-CSRFheaderstringyesValue of the kyvernon_csrf cookie

Responses

StatusDescriptionSchema
200New tokens; new kyv_refresh cookieAuthResponse
401error.auth.session_expired or error.auth.refresh_reuse (cookies cleared)ErrorBody
403error.auth.csrf or error.auth.originErrorBody
409error.auth.refresh_race: another tab refreshed; retry onceErrorBody

GET /v1/auth/session

The caller's session and stage (works for restricted sessions).

CLI
kyvernon auth session

Responses

StatusDescriptionSchema
200OKAuthSessionView
401Not authenticated, or the session is restricted (error.mfa_required, error.password_rotation_required)ErrorBody

POST /v1/auth/totp/confirm

Confirms TOTP enrolment with a current code; the session is re-keyed (new tokens and cookies) and the recovery codes are returned once.

CLI
kyvernon auth totp confirm <code>

Request body

application/json: TotpCodeRequest

NameTypeRequiredDescription
codestringyesSix-digit code.

Responses

StatusDescriptionSchema
200Authenticated; recoveryCodes presentAuthResponse
401error.auth.invalid_codeErrorBody

POST /v1/auth/totp/enrol

Starts TOTP enrolment (after the password change, when TOTP is not enrolled yet).

CLI
kyvernon auth totp enrol

Responses

StatusDescriptionSchema
200OKTotpEnrolResponse
412error.password_rotation_required or error.mfa.already_enrolledErrorBody

POST /v1/auth/totp/recovery-codes

Replaces the caller's recovery codes (needs a current TOTP code).

CLI
kyvernon auth totp recovery-codes <code>

Request body

application/json: TotpCodeRequest

NameTypeRequiredDescription
codestringyesSix-digit code.

Responses

StatusDescriptionSchema
200OKRecoveryCodesResponse
401Not authenticated, or the session is restricted (error.mfa_required, error.password_rotation_required)ErrorBody

Version 0.1.