auth
29 operations
POST /v1/auth/loginSign in with email and passwordPOST /v1/auth/login/second-factorFinish a two-step sign-in with a codePOST /v1/auth/logoutEnd the current sessionGET /v1/auth/meWho am IPOST /v1/auth/passwordChange the signed-in user's passwordPOST /v1/auth/reauthProve the signed-in user's password againGET /v1/auth/sessionsThe signed-in user's devices (live sessions)POST /v1/auth/sessions/revoke-othersSign out everywhere elsePOST /v1/auth/sessions/{id}/revokeSign out one of the signed-in user's other devicesGET /v1/auth/email-settingsThe signed-in person's email settingPUT /v1/auth/email-settingsTurn the signed-in person's notification emails on or offPOST /v1/auth/password/recoverForgot password: set a new one with a two-step backup codePOST /v1/auth/two-factor/setupStart setting up the authenticator appPOST /v1/auth/two-factor/confirmTurn the authenticator app on with its first codePOST /v1/auth/two-factor/disableTurn the authenticator app offPOST /v1/auth/backup-codesGet 10 new backup codesPOST /v1/auth/links/inspectWhat a one-time link is forPOST /v1/auth/links/acceptAccept a one-time link and sign inPOST /v1/oauth/tokenGet an access token (OAuth2 client credentials)POST /v1/oauth/revokeRevoke an access token (RFC 7009)GET /v1/auth/passkeysThe signed-in user's passkeysPOST /v1/auth/passkeysAdd a passkey to the signed-in user's accountPOST /v1/auth/passkeys/registration-optionsOptions for adding a passkeyPATCH /v1/auth/passkeys/{id}Rename one of the signed-in user's passkeysDELETE /v1/auth/passkeys/{id}Remove one of the signed-in user's passkeysPOST /v1/auth/passkeys/authentication-optionsOptions for signing in with a passkeyPOST /v1/auth/passkeys/loginSign in with a passkeyPOST /v1/auth/oidc/startBegin a sign-in with the company's identity providerPOST /v1/auth/oidc/callbackFinish a sign-in with the company's identity provider
POST /v1/auth/login
Sign in with email and password
No authentication · login
Opens a server session and sets the session cookie. When an Origin header is sent it must be allowed. A previous session cookie presented on this request is revoked. Unknown user, wrong password, disabled and locked accounts all answer the same 401. SELF-1-6 (#187): for an account with two-step sign-in a correct password answers 202 with a login ticket instead (no session, no cookie, and the email's count of wrong attempts is not cleared); the code step opens the session.
Request body
LoginRequest (required)
Media type: application/json
Example request · application/json
{
"email": "alice@coop.example",
"password": "correct horse battery"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | AuthSessionapplication/json | Signed in. Send |
| 202 | SecondFactorChallengeapplication/json | SELF-1-6 (#187): the password is right and the account has two-step sign-in. No session and no cookie yet: send the ticket and a code to POST /v1/auth/login/second-factor. |
| 400 | Errorapplication/json | email or password missing or not a string, or the body is not a JSON object. |
| 401 | Errorapplication/json | Credentials refused. |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many login attempts from this client address (per-IP token bucket: bursts of 20, then 10 a minute). The Origin, the body and the credentials were not checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Too many password hashes are running; retry after the delay. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Set-Cookie | 200 | string | The session cookie ( |
Cache-Control | 200 | string |
|
X-Request-Id | 202 | string | Request id: the caller's |
Cache-Control | 202 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ"
}Response 202 · application/json
{
"second_factor": "required",
"ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
"expires_at": 1790086700
}Response 400 · application/json
{
"error": "email and password are required",
"code": "email_and_password_are_required"
}Response 401 · application/json
{
"error": "invalid credentials",
"code": "invalid_credentials"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/login/second-factor
Finish a two-step sign-in with a code
No authentication · completeSecondFactor
SELF-1-6 (#187). Anonymous, like login: the login ticket of POST /v1/auth/login (202) and the 6-digit code from the authenticator app, or one unused backup code, open the session (cookie, csrf_token), in one transaction with the audit row (auth.login; a refusal is auth.login.second_factor.failed; never the ticket or the code). A code is accepted for the current 30-second step or one either side, and never twice for an account. A wrong code counts on the ticket (5 end it) and towards the email's login lockout; a locked email is refused whatever the code. A backup code works once. Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed.
Request body
SecondFactorLogin (required)
Media type: application/json
Example request · application/json
{
"ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
"code": "492039"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | SecondFactorSessionapplication/json | Signed in. Send |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, no code and no backup code, both, or one that is not text; or a bad X-Request-Id. |
| 401 | Errorapplication/json | The ticket is unknown, expired, used or out of attempts (start again with the password), or the code is wrong, already used, or refused (locked email, disabled account, password changed since the ticket). |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | No key-encryption key is configured (AGRITRACE_ISSUER_KEK) or it does not decrypt the secret, so a code cannot be checked (a backup code still works); or busy (no password hashing slot free in time). Nothing changed and nothing is let through on the password alone; retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Set-Cookie | 200 | string | The session cookie ( |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ",
"second_factor": "code",
"backup_codes_left": 10
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · code_required
{
"error": "code is required: the 6-digit code from the app, or a backup code",
"code": "code_is_required"
}Response 400 · application/json · both
{
"error": "send code or backup_code, not both",
"code": "send_code_or_backup_code_not_both"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · expired
{
"error": "sign-in expired: enter your password again",
"code": "sign_in_expired"
}Response 401 · application/json · invalid_code
{
"error": "invalid code",
"code": "invalid_code"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json · kek
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}Response 503 · application/json · busy
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/logout
End the current session
Authentication: cookie · logout
Session only — not available to API tokens or OAuth clients
Revokes the session and clears the cookie. Unsafe method: needs X-CSRF-Token and an allowed Origin.
Responses
| Status | Type | Description |
|---|---|---|
| 204 | Signed out. No body; the Set-Cookie header clears the cookie. | |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 204 | string | Request id: the caller's |
Set-Cookie | 204 | string | The session cookie ( |
Cache-Control | 204 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/auth/me
Who am I
Authentication: cookie · getCurrentSession
Session only — not available to API tokens or OAuth clients
The signed-in user, all memberships, the CSRF token, and the tenant and roles the request acts for (X-Tenant selects among memberships). SELF-1-6 (#187): two_factor tells the console whether this user's two-step sign-in is on, and whether this session must set it up before acting for the selected company.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | Meapplication/json | The current session. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant). Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ",
"tenant": "coop-dl",
"roles": [
"tenant_admin"
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/password
Change the signed-in user's password
Authentication: cookie · changePassword
Session only — not available to API tokens or OAuth clients
Revokes every session of the user (this one included) and opens a fresh one: the response carries the new CSRF token and a new Set-Cookie. A wrong current password counts towards the login lockout. The fresh session keeps this session's last password proof: a password change never counts as a recent sign-in for the operations that need one (call POST /v1/auth/reauth). #187: an account with two-step sign-in also sends code (or backup_code); a wrong one counts towards the login lockout like a wrong password, and the code is used up.
Request body
PasswordChangeRequest (required)
Media type: application/json
Example request · application/json
{
"current_password": "correct horse battery",
"new_password": "another long passphrase"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | PasswordChangedapplication/json | Password changed; continue on the fresh session. |
| 400 | Errorapplication/json | Body fields missing or not strings, new password too short or too long, or the current password is wrong; for an account with two-step sign-in, the code is missing, or the current password or the code is wrong. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Too many password hashes are running; retry after the delay. Or (#187) a code was sent and the server's key-encryption key is missing: two-step sign-in is unavailable and the password is not changed. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Set-Cookie | 200 | string | The session cookie ( |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"csrf_token": "Zk1pQ8w2Ls"
}Response 400 · application/json · missing
{
"error": "current_password and new_password are required",
"code": "current_password_and_new_password_are_required"
}Response 400 · application/json · weak
{
"error": "password must be at least 12 characters",
"code": "password_must_be_at_least_12_characters"
}Response 400 · application/json · wrong_current
{
"error": "current password is incorrect",
"code": "current_password_is_incorrect"
}Response 400 · application/json · code_required
{
"error": "code is required: the 6-digit code from the app, or a backup code",
"code": "code_is_required"
}Response 400 · application/json · wrong_code
{
"error": "current password or code is incorrect",
"code": "current_password_or_code_is_incorrect"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/reauth
Prove the signed-in user's password again
Authentication: cookie · reauthenticate
Session only — not available to API tokens or OAuth clients
SELF-1-2 (#183). Records that this session proved its password now. Operations that create credentials (and, later, change who may act for the company) refuse a session whose last proof is more than 10 minutes old with 401 reauthentication_required; the browser then calls this operation and repeats the request. A wrong password counts towards the login lockout, and a locked account is refused whatever the password. Audited (auth.reauth, in the same transaction; never the password). Unsafe method: needs X-CSRF-Token and an allowed Origin. SELF-1-6 (#187): an account with two-step sign-in also sends code (or backup_code); a wrong one counts towards the lockout like a wrong password, and a right one also counts as this session's second factor proof. Step-up (#87): for such an account, a right code (or backup code) here also lets this session revoke signing, lab and issuer keys, recall or withdraw lots and add market limits for 5 minutes; those operations answer 401 mfa_step_up_required once it is older (or the password proof is older than 10 minutes).
Request body
ReauthRequest (required)
Media type: application/json
Example request · application/json
{
"password": "correct horse battery"
}Responses
| Status | Type | Description |
|---|---|---|
| 204 | Password confirmed for this session. No body. | |
| 400 | Errorapplication/json | The password is missing or not a string, or it is wrong (or the account is locked after too many wrong passwords); for an account with two-step sign-in, the code is missing, or the password or the code is wrong; or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Too many password hashes are running; retry after the delay. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 204 | string | Request id: the caller's |
Cache-Control | 204 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 400 · application/json · missing
{
"error": "password is required",
"code": "password_is_required"
}Response 400 · application/json · wrong
{
"error": "password is incorrect",
"code": "password_is_incorrect"
}Response 400 · application/json · code_required
{
"error": "code is required: the 6-digit code from the app, or a backup code",
"code": "code_is_required"
}Response 400 · application/json · wrong_code
{
"error": "password or code is incorrect",
"code": "password_or_code_is_incorrect"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}GET /v1/auth/sessions
The signed-in user's devices (live sessions)
Authentication: cookie · listMySessions
Session only — not available to API tokens or OAuth clients
SELF-2-1 (#190). Every live session of the signed-in user, in every company they work for (a session belongs to the person, not to a company): the browser and system, when it was opened and last used (to the minute), and which one is making the request. Never a token, its hash, an IP address or the raw user agent. Session routes are open to every signed-in user, whatever the role, and act on that user's own sessions only.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | SignedInSessionListapplication/json | The live sessions. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"items": [
{
"id": 42,
"browser": "Chrome",
"os": "Windows",
"mobile": false,
"created_at": 1790060400,
"last_seen_at": 1790086380,
"current": true
},
{
"id": 37,
"browser": "Safari",
"os": "iOS",
"mobile": true,
"created_at": 1789899960,
"last_seen_at": 1789999980,
"current": false
}
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/sessions/revoke-others
Sign out everywhere else
Authentication: cookie · revokeMyOtherSessions
Session only — not available to API tokens or OAuth clients
SELF-2-1 (#190). Ends every session of the signed-in user except the one making the request, in every company (a lost or shared device). The devices are signed out from their next request on. Audited (auth.session.revoke_others, in the same transaction, with how many were ended). Repeating it ends nothing more (200, sessions_revoked 0). Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own sessions only.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | SessionsRevokedapplication/json | Every other session ended. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"sessions_revoked": 2
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/sessions/{id}/revoke
Sign out one of the signed-in user's other devices
Authentication: cookie · revokeMySession
Session only — not available to API tokens or OAuth clients
SELF-2-1 (#190). Ends one live session of the signed-in user (from listMySessions); that device is signed out from its next request on. The session making the request is ended by signing out (logout), not here (400 current_session). Another user's session, or one already ended or expired, answers 404 like a missing one. Audited (auth.session.revoke, in the same transaction). Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own sessions only.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | The session's id (from listMySessions). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | SignedInSessionRevokedapplication/json | The session ended. |
| 400 | Errorapplication/json | The session making the request (sign out instead), or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 404 | Errorapplication/json | No live session of the signed-in user with that id (another user's session answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"id": 37,
"revoked": true
}Response 400 · application/json · current_session
{
"error": "current session: sign out to end the session you are using",
"code": "current_session"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "not found: 37",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/auth/email-settings
The signed-in person's email setting
Authentication: cookie · getMyEmailSettings
Session only — not available to API tokens or OAuth clients
#270. Whether the signed-in person gets the notification, alert and recall emails, the language of their emails, and whether this server sends email at all (delivery: SMTP configured; the console then says a new one-time link was emailed too, otherwise that it must be passed on by hand). Session routes are open to every signed-in user, whatever the role, and act on that user's own setting only. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | EmailSettingsapplication/json | The setting. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"notifications": true,
"language": "vi",
"delivery": false
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/auth/email-settings
Turn the signed-in person's notification emails on or off
Authentication: cookie · updateMyEmailSettings
Session only — not available to API tokens or OAuth clients
#270. Sets whether the signed-in person gets the notification, alert and recall emails, and their emails' language (the console sends its own). Invitation and password emails are always sent. Audited (auth.email_settings.update, in the same transaction: the prior setting's hash and the new one). Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own setting only. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Request body
EmailSettingsUpdate (required)
Media type: application/json
Example request · application/json
{
"notifications": false,
"language": "en"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | EmailSettingsapplication/json | Saved; the new setting. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"notifications": false,
"language": "en",
"delivery": false
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · notifications
{
"error": "notifications must be true or false",
"code": "notifications_must_be_true_or_false"
}Response 400 · application/json · language
{
"error": "language must be one of: vi, en, zh-Hans",
"code": "language_must_be_one_of"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/password/recover
Forgot password: set a new one with a two-step backup code
No authentication · recoverPassword
SELF-2-2 (#191). Anonymous, like login, and only for an account with two-step sign-in: the sign-in email, one unused backup code of the account and a new password set the password. In one transaction the backup code is used up, the password is stored, every session of the account is ended and its pending sign-ins are cancelled, with the audit row (auth.password.recover; a refusal is auth.password.recover.failed; never the code or a password). No session is opened and no cookie is set: the next sign-in asks for the new password and then the second step. An unknown email, an account without two-step sign-in, a disabled account, a wrong, used or malformed backup code and a locked email all get the same 400 answer after the same work, and every one but a locked email counts towards the email's login lockout. Takes a token from the login rate-limit bucket (per client address) before anything else, and one from a bucket keyed by the email named (5 an hour) before any password work. When an Origin header is sent it must be allowed.
Request body
PasswordRecoveryRequest (required)
Media type: application/json
Example request · application/json
{
"email": "alice@coop.example",
"backup_code": "abcd-efgh-ijkl-mnop",
"new_password": "another long passphrase"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | PasswordRecoveredapplication/json | The password is changed and every session of the account ended. No session is opened: sign in with the new password, then the second step. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or non-text email, backup_code or new_password, or a new password that breaks the policy (checked before anything else); or the email and backup code do not fit an account with two-step sign-in (one answer whatever the reason); or a bad X-Request-Id. |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many attempts from this client address (the login bucket), or for this email (5 an hour). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Busy (no password hashing slot free in time). Nothing changed; retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"backup_codes_left": 9,
"second_factor": "required"
}Response 400 · application/json · refused
{
"error": "email or backup code is incorrect",
"code": "email_or_backup_code_is_incorrect"
}Response 400 · application/json · missing
{
"error": "email, backup_code and new_password are required",
"code": "email_backup_code_and_new_password_are_required"
}Response 400 · application/json · weak
{
"error": "password must be at least 12 characters",
"code": "password_must_be_at_least_12_characters"
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/two-factor/setup
Start setting up the authenticator app
Authentication: cookie · setUpTwoFactor
Session only — not available to API tokens or OAuth clients
SELF-1-6 (#187). A new secret (160 bits) for the signed-in user's authenticator app, as text and as an otpauth URI for a QR code, in this response only; it is stored encrypted (AES-256-GCM under AGRITRACE_ISSUER_KEK, bound to the user) and is on only once POST /v1/auth/two-factor/confirm checks a code from it. Starting again replaces a setup that was not confirmed. Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (auth.two_factor.setup; never the secret). Unsafe method: needs X-CSRF-Token and an allowed Origin.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | TwoFactorSetupapplication/json | The secret, shown this once. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check, and to a session that has not proved a second factor yet (two_factor_required never answers here). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Two-step sign-in is already on: turn it off (POST /v1/auth/two-factor/disable, with |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | No key-encryption key is configured (AGRITRACE_ISSUER_KEK), or the stored secret does not decrypt with it: two-step sign-in cannot be checked or set up, and nothing is let through on the password alone. Retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"secret": "JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP",
"otpauth_uri": "otpauth://totp/CropPath:alice@coop.example?secret=JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP&issuer=CropPath",
"issuer": "CropPath",
"account": "alice@coop.example",
"digits": 6,
"period": 30
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json
{
"error": "already on: turn two-step sign-in off before setting it up again",
"code": "already_on"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}POST /v1/auth/two-factor/confirm
Turn the authenticator app on with its first code
Authentication: cookie · confirmTwoFactor
Session only — not available to API tokens or OAuth clients
SELF-1-6 (#187). Checks a code from the secret POST /v1/auth/two-factor/setup returned and turns two-step sign-in on: from the next sign-in a code is asked after the password. Returns 10 backup codes, in this response only. This session counts as having proved a second factor; every other session of the account ends. Audited (auth.two_factor.enable, in the same transaction; never a code). Unsafe method: needs X-CSRF-Token and an allowed Origin.
Request body
TwoFactorCode (required)
Media type: application/json
Example request · application/json
{
"code": "492039"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | BackupCodesapplication/json | On. The backup codes, shown this once. |
| 400 | Errorapplication/json | The code is missing or wrong, or the body is not a JSON object; or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check, and to a session that has not proved a second factor yet (two_factor_required never answers here). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | No setup to confirm: start with POST /v1/auth/two-factor/setup. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | No key-encryption key is configured (AGRITRACE_ISSUER_KEK) or it does not decrypt the secret, so a code cannot be checked (a backup code still works); or busy (no password hashing slot free in time). Nothing changed and nothing is let through on the password alone; retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"backup_codes": [
"k3xq-7mfa-2pzd-q4ve",
"a7hn-35sk-wqzr-t2bm",
"uj4c-6pde-mb3x-7fkr",
"q2wv-zyt5-4hna-kcpe",
"n6ft-rm3a-x7qd-s5bj",
"e4pk-2wvc-hy6m-zr3t",
"c5ad-kqmx-7nrj-w2ze",
"t3vy-hb6q-p4sm-x5ka",
"z7rm-e2nk-4bhp-dq6w",
"m5jd-ws3t-q7ac-2kyn"
]
}Response 400 · application/json · missing
{
"error": "code is required",
"code": "code_is_required"
}Response 400 · application/json · invalid
{
"error": "invalid code",
"code": "invalid_code"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json
{
"error": "nothing to confirm: start the setup again",
"code": "nothing_to_confirm"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json · kek
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}Response 503 · application/json · busy
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/two-factor/disable
Turn the authenticator app off
Authentication: cookie · disableTwoFactor
Session only — not available to API tokens or OAuth clients
SELF-1-6 (#187). Needs the password and a current code (or a backup code); a wrong one counts towards the login lockout. Refused (409) while the account must use two-step sign-in (a platform admin, a company admin after the deadline, a member of a company that requires it), unless set_up_again (a new phone: this session sets the app up again at once). Removes the secret and the backup codes, and every session of the account loses its proof of a second factor: where two-step sign-in is required, company routes answer 403 two_factor_required until the app is set up again. Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (auth.two_factor.disable; never the password or a code). Unsafe method: needs X-CSRF-Token and an allowed Origin.
Request body
TwoFactorDisable (required)
Media type: application/json
Example request · application/json
{
"password": "correct horse battery",
"code": "492039"
}Responses
| Status | Type | Description |
|---|---|---|
| 204 | Off. No body. | |
| 400 | Errorapplication/json | A missing password, no code and no backup code, an unknown field, or the password or code is wrong (or the email is locked); or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check, and to a session that has not proved a second factor yet (two_factor_required never answers here). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Two-step sign-in is not on, or this account must use it. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | No key-encryption key is configured (AGRITRACE_ISSUER_KEK) or it does not decrypt the secret, so a code cannot be checked (a backup code still works); or busy (no password hashing slot free in time). Nothing changed and nothing is let through on the password alone; retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 204 | string | Request id: the caller's |
Cache-Control | 204 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 400 · application/json · password
{
"error": "password is required",
"code": "password_is_required"
}Response 400 · application/json · code
{
"error": "code is required: the 6-digit code from the app, or a backup code",
"code": "code_is_required"
}Response 400 · application/json · wrong
{
"error": "password or code is incorrect",
"code": "password_or_code_is_incorrect"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · not_on
{
"error": "not on: two-step sign-in is not set up for this account",
"code": "not_on"
}Response 409 · application/json · required
{
"error": "two-step sign-in required: it cannot be turned off for this account",
"code": "two_step_sign_in_required"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json · kek
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}Response 503 · application/json · busy
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/backup-codes
Get 10 new backup codes
Authentication: cookie · regenerateBackupCodes
Session only — not available to API tokens or OAuth clients
SELF-1-6 (#187). Replaces every backup code of the signed-in user with 10 new ones, in this response only. Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (auth.backup_codes.regenerate, in the same transaction; never a code). Unsafe method: needs X-CSRF-Token and an allowed Origin.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | BackupCodesapplication/json | The new backup codes, shown this once. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check, and to a session that has not proved a second factor yet (two_factor_required never answers here). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Two-step sign-in is not on. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Busy (no password hashing slot free in time): retry after |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"backup_codes": [
"k3xq-7mfa-2pzd-q4ve",
"a7hn-35sk-wqzr-t2bm",
"uj4c-6pde-mb3x-7fkr",
"q2wv-zyt5-4hna-kcpe",
"n6ft-rm3a-x7qd-s5bj",
"e4pk-2wvc-hy6m-zr3t",
"c5ad-kqmx-7nrj-w2ze",
"t3vy-hb6q-p4sm-x5ka",
"z7rm-e2nk-4bhp-dq6w",
"m5jd-ws3t-q7ac-2kyn"
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json
{
"error": "not on: two-step sign-in is not set up for this account",
"code": "not_on"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/auth/links/inspect
What a one-time link is for
No authentication · inspectAccountLink
SELF-1-3 (#184). Anonymous: whoever holds the link's token learns the company, role, email and expiry, and whether the email already has an account. Every unusable token (malformed, unknown, expired, used or revoked) is the same 404 link_not_valid, after the same single lookup by the token's hash. Takes a token from the login rate-limit bucket before anything else. A read: not audited.
Request body
AccountLinkToken (required)
Media type: application/json
Example request · application/json
{
"token": "agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | AccountLinkInfoapplication/json | The link's purpose and who it is for. |
| 400 | Errorapplication/json | Invalid JSON, or a bad X-Request-Id. |
| 404 | Errorapplication/json | No usable link: it expired, was used or revoked, or never existed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many requests from this client address: these routes take from the login bucket (per-IP token bucket: bursts of 20, then 10 a minute). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"purpose": "invite",
"company": "New Coop",
"role": "tenant_admin",
"email": "first.admin@coop-new.example",
"expires_at": 1790259200.5,
"account_exists": false
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 404 · application/json
{
"error": "link not valid",
"code": "link_not_valid"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/links/accept
Accept a one-time link and sign in
No authentication · acceptAccountLink
SELF-1-3 (#184). Anonymous, like login. An invitation for an email without an account creates the account (the link's email, which cannot be changed; the password follows the login policy) and its membership; for an email with an account, password must be that account's password (a wrong one counts towards the login lockout, and 10 on one link revoke it) and only the membership is added. A reset link stores the new password and ends every other session of the account. The link is then used, and a session opens as with login (cookie, csrf_token), all in one transaction with the audit row (account_link.accept, in the company's log; never the token or the password). Every unusable token is the same 404 link_not_valid. Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed. SELF-1-6 (#187): for an account with two-step sign-in the link is used but no session opens: 202 with a login ticket for POST /v1/auth/login/second-factor, so a link never skips the code step.
Request body
AccountLinkAccept (required)
Media type: application/json
Example request · application/json
{
"token": "agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"password": "correct horse battery",
"display_name": "Chi Lan"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | AuthSessionapplication/json | Signed in. Send |
| 202 | SecondFactorChallengeapplication/json | SELF-1-6 (#187): the password is right and the account has two-step sign-in. No session and no cookie yet: send the ticket and a code to POST /v1/auth/login/second-factor. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field (the email cannot be changed), a missing password, a password outside 12 to 1,024 characters, a bad display name, or a bad X-Request-Id. |
| 401 | Errorapplication/json | The email already has an account and the password is wrong, the email is locked after too many wrong passwords, or the account is disabled. |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 404 | Errorapplication/json | No usable link: it expired, was used or revoked, or never existed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The email got an account while the link was being accepted: open the link again. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many requests from this client address: these routes take from the login bucket (per-IP token bucket: bursts of 20, then 10 a minute). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | Too many password hashes are running; retry after the delay. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Set-Cookie | 200 | string | The session cookie ( |
Cache-Control | 200 | string |
|
X-Request-Id | 202 | string | Request id: the caller's |
Cache-Control | 202 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ"
}Response 202 · application/json
{
"second_factor": "required",
"ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
"expires_at": 1790086700
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown
{
"error": "unknown fields: email",
"code": "unknown_fields"
}Response 400 · application/json · password_required
{
"error": "password is required",
"code": "password_is_required"
}Response 400 · application/json · weak
{
"error": "password must be at least 12 characters",
"code": "password_must_be_at_least_12_characters"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "invalid credentials",
"code": "invalid_credentials"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "link not valid",
"code": "link_not_valid"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json
{
"error": "account created meanwhile: open the link again",
"code": "account_created_meanwhile"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "busy, retry",
"code": "busy_retry"
}POST /v1/oauth/token
Get an access token (OAuth2 client credentials)
No authentication · oauthToken
RFC 6749 §4.4 client credentials grant. The client authenticates with HTTP Basic (client_id:client_secret, each form-urlencoded) or with client_id and client_secret in the body, never both. The response carries a bearer access token (ago_...) valid for 900 seconds with the client's scopes, or the subset asked for in scope (space separated); send it as Authorization: Bearer <access_token>. A token reaches only the routes whose permission is among its scopes, within the client's tenant and, for an operator client, its facilities. A client holds at most 20 live tokens (429 above it); ask for a new token when one expires rather than one per request. Errors are RFC 6749 §5.2 bodies (error, error_description) that also carry the API's code. Audited (oauth.token, in the same transaction: the client, the scopes granted and the expiry, never the token; a refused request writes oauth.token.failed). Rate limited per client address. An Idempotency-Key header is refused (400 idempotency_key_not_supported): the response would hold a secret. #205: an expired client, and a client called from a source address outside its allowed networks (the address the API sees: CF-Connecting-IP from a trusted proxy, else the connection's), is refused invalid_client exactly like a wrong secret; a token of such a client then answers 401 missing_or_invalid_token on every call.
Request body
OAuthTokenRequest (required)
Media type: application/x-www-form-urlencoded
Example request · application/x-www-form-urlencoded
{
"grant_type": "client_credentials",
"scope": "lot_read"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | OAuthTokenapplication/json | The access token. |
| 400 | OAuthErrorapplication/json | RFC 6749 §5.2: |
| 401 | OAuthErrorapplication/json | Client authentication failed (RFC 6749 §5.2 |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | OAuthErrorapplication/json | Too many requests from this client address (see the 429 of the bucket, |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
Pragma | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
Cache-Control | 400 | string |
|
Pragma | 400 | string |
|
X-Request-Id | 401 | string | Request id: the caller's |
Cache-Control | 401 | string |
|
Pragma | 401 | string |
|
WWW-Authenticate | 401 | string |
|
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Cache-Control | 429 | string |
|
Pragma | 429 | string |
|
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"access_token": "ago_VGhpcyBpcyBhbiBleGFtcGxlIGFjY2VzcyB0b2tlbiE",
"token_type": "Bearer",
"expires_in": 900,
"scope": "lot_read lot_write"
}Response 400 · application/json · invalid_request
{
"error": "invalid_request",
"error_description": "grant_type is required",
"code": "invalid_request"
}Response 400 · application/json · unsupported_grant_type
{
"error": "unsupported_grant_type",
"error_description": "only client_credentials is supported",
"code": "unsupported_grant_type"
}Response 400 · application/json · invalid_scope
{
"error": "invalid_scope",
"error_description": "scope: a permission the client was not granted",
"code": "invalid_scope"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "invalid_client",
"error_description": "client authentication failed",
"code": "invalid_client"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json · throttled
{
"error": "too many requests",
"code": "too_many_requests"
}Response 429 · application/json · live_tokens
{
"error": "invalid_request",
"error_description": "too many live tokens: at most 20 per client",
"code": "invalid_request"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/oauth/revoke
Revoke an access token (RFC 7009)
No authentication · oauthRevoke
The client that holds an access token revokes it; it stops authenticating at once. Client authentication as for the token endpoint. 200 whether or not token was a live token of this client: an unknown, expired or another client's token is left alone and answered the same (token_type_hint is accepted and ignored). Audited (oauth.revoke: the client and whether a token was revoked, never the token). Rate limited with the token endpoint. An Idempotency-Key header is refused (400 idempotency_key_not_supported): revocation is idempotent by itself.
Request body
OAuthRevokeRequest (required)
Media type: application/x-www-form-urlencoded
Example request · application/x-www-form-urlencoded
{
"token": "ago_VGhpcyBpcyBhbiBleGFtcGxlIGFjY2VzcyB0b2tlbiE",
"token_type_hint": "access_token"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | objectapplication/json | Done (or nothing to do). |
| 400 | OAuthErrorapplication/json | RFC 6749 §5.2 |
| 401 | OAuthErrorapplication/json | Client authentication failed (RFC 6749 §5.2 |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | OAuthErrorapplication/json | Too many requests to the OAuth2 endpoints from this client address (one per-IP token bucket for the token and revocation endpoints: bursts of 30, then 30 a minute). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
Pragma | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
Cache-Control | 400 | string |
|
Pragma | 400 | string |
|
X-Request-Id | 401 | string | Request id: the caller's |
Cache-Control | 401 | string |
|
Pragma | 401 | string |
|
WWW-Authenticate | 401 | string |
|
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Cache-Control | 429 | string |
|
Pragma | 429 | string |
|
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{}Response 400 · application/json · invalid_request
{
"error": "invalid_request",
"error_description": "token is required",
"code": "invalid_request"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "invalid_client",
"error_description": "client authentication failed",
"code": "invalid_client"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/auth/passkeys
The signed-in user's passkeys
Authentication: cookie · listMyPasskeys
Session only — not available to API tokens or OAuth clients
#87. Every passkey of the signed-in user, oldest first: its nickname, algorithm, transports, attestation format, when it was added and last used, and when a sign-in with it was refused because its signature counter did not move forward (a possibly copied authenticator). Never a credential id, a public key or a user handle. Session routes are open to every signed-in user, whatever the role, and act on that user's own passkeys only. no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | PasskeyListapplication/json | The passkeys. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant). Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"items": [
{
"id": 3,
"nickname": "Work phone",
"algorithm": "ES256",
"transports": [
"hybrid",
"internal"
],
"attestation_format": "none",
"created_at": 1790060400,
"last_used_at": 1790086380,
"clone_warning_at": null
}
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/passkeys
Add a passkey to the signed-in user's account
Authentication: cookie · registerPasskey
Session only — not available to API tokens or OAuth clients
#87. The answer of navigator.credentials.create() for the options of startPasskeyRegistration, verified as WebAuthn Level 2 section 7.1 asks: the client data is a webauthn.create for that single-use challenge (used up by this request whatever its outcome, valid 5 minutes) at the public origin, the authenticator data starts with the SHA-256 of the RP ID (the public origin's host) and has the user present and user verified flags, and the credential key is ES256, RS256 (2048 bits or more) or EdDSA. Attestation none is enough (packed self attestation is checked; another format is stored by name, never trusted). An account has at most 10 passkeys; a credential is registered once across all accounts (409). Audited (auth.passkey.register, in the same transaction: the passkey's id, algorithm and attestation format; never key material). A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done. Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own passkeys only. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Request body
PasskeyRegistration (required)
Media type: application/json
Example request · application/json
{
"client_data_json": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0",
"attestation_object": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YUA",
"transports": [
"internal"
],
"nickname": "Work phone"
}Responses
| Status | Type | Description |
|---|---|---|
| 201 | Passkeyapplication/json | The passkey was added. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a malformed nickname or transports, a bad X-Request-Id; or the passkey does not verify ( |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The account has 10 passkeys already, or this passkey is registered already. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 201 · application/json
{
"id": 3,
"nickname": "Work phone",
"algorithm": "ES256",
"transports": [
"hybrid",
"internal"
],
"attestation_format": "none",
"created_at": 1790060400,
"last_used_at": null,
"clone_warning_at": null
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · nickname
{
"error": "nickname too long: at most 64 characters",
"code": "nickname_too_long"
}Response 400 · application/json · invalid_passkey
{
"error": "invalid passkey: challenge unknown or used",
"code": "invalid_passkey"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · too_many
{
"error": "too many passkeys: an account has at most 10",
"code": "too_many_passkeys"
}Response 409 · application/json · registered
{
"error": "passkey already registered",
"code": "passkey_already_registered"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "passkeys unavailable: the server has no public origin (AGRITRACE_PUBLIC_ORIGIN)",
"code": "passkeys_unavailable"
}POST /v1/auth/passkeys/registration-options
Options for adding a passkey
Authentication: cookie · startPasskeyRegistration
Session only — not available to API tokens or OAuth clients
#87. The options for navigator.credentials.create(): a single-use challenge (32 random bytes, stored as their SHA-256 only, valid 5 minutes; a new one replaces the account's earlier one), the Relying Party (the public origin's host), the account's user handle (random, never the account id), ES256, EdDSA and RS256, attestation none, a discoverable credential with user verification required, and the account's passkeys to exclude. The body is empty or {}. Not audited (a challenge changes no record; the registration is audited). A session must have confirmed its password within the last 10 minutes, else 401 reauthentication_required. Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own passkeys only. no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | PasskeyCreationOptionsapplication/json | The options. |
| 400 | Errorapplication/json | Invalid JSON, a field (the body takes none) or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The account has 10 passkeys already. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"public_key": {
"challenge": "q83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJA",
"rp": {
"id": "txng.theio.vn",
"name": "CropPath"
},
"user": {
"id": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGk",
"name": "alice@coop.example",
"displayName": "Alice"
},
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -7
},
{
"type": "public-key",
"alg": -8
},
{
"type": "public-key",
"alg": -257
}
],
"timeout": 300000,
"attestation": "none",
"authenticatorSelection": {
"residentKey": "required",
"requireResidentKey": true,
"userVerification": "required"
},
"excludeCredentials": [
{
"type": "public-key",
"id": "AAECAwQFBgcICQoLDA0ODw",
"transports": [
"internal"
]
}
]
}
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json
{
"error": "too many passkeys: an account has at most 10",
"code": "too_many_passkeys"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "passkeys unavailable: the server has no public origin (AGRITRACE_PUBLIC_ORIGIN)",
"code": "passkeys_unavailable"
}PATCH /v1/auth/passkeys/{id}
Rename one of the signed-in user's passkeys
Authentication: cookie · renamePasskey
Session only — not available to API tokens or OAuth clients
#87. Sets the passkey's nickname (at most 64 characters, spaces trimmed, no control character; empty to clear it). Another user's passkey answers 404 like a missing one. Audited (auth.passkey.rename, in the same transaction; never the nickname). Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own passkeys only. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | The passkey's id (from listMyPasskeys). |
Request body
PasskeyRename (required)
Media type: application/json
Example request · application/json
{
"nickname": "Work phone"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | Passkeyapplication/json | Renamed. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, no or a malformed nickname, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session cookie. |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 404 | Errorapplication/json | No passkey of the signed-in user with that id (another user's passkey answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"id": 3,
"nickname": "Work phone",
"algorithm": "ES256",
"transports": [
"hybrid",
"internal"
],
"attestation_format": "none",
"created_at": 1790060400,
"last_used_at": 1790086380,
"clone_warning_at": null
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · required
{
"error": "nickname is required",
"code": "nickname_is_required"
}Response 400 · application/json · too_long
{
"error": "nickname too long: at most 64 characters",
"code": "nickname_too_long"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}DELETE /v1/auth/passkeys/{id}
Remove one of the signed-in user's passkeys
Authentication: cookie · removePasskey
Session only — not available to API tokens or OAuth clients
#87. Deletes the passkey: it cannot sign in from then on (sessions it opened stay open; end them with revokeMySession). Another user's passkey answers 404 like a missing one. Audited (auth.passkey.remove, in the same transaction). Step-up: a session must have confirmed its password within the last 10 minutes (reauthentication_required) and, for an account with two-step sign-in, a code (or a passkey sign-in) within the last 5 minutes (mfa_step_up_required, #87 part A), else 401 before anything is done (no audit row). Unsafe method: needs X-CSRF-Token and an allowed Origin. Session routes are open to every signed-in user, whatever the role, and act on that user's own passkeys only. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | The passkey's id (from listMyPasskeys). |
Responses
| Status | Type | Description |
|---|---|---|
| 204 | Removed. | |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is refused: tenant not allowed (X-Tenant), CSRF token missing or invalid, origin not allowed. Session routes are open to every role, so there is no role check. |
| 404 | Errorapplication/json | No passkey of the signed-in user with that id (another user's passkey answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 204 | string | Request id: the caller's |
Cache-Control | 204 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json · session
{
"error": "not authenticated",
"code": "not_authenticated"
}Response 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Response 401 · application/json · step_up
{
"error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
"code": "mfa_step_up_required"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/auth/passkeys/authentication-options
Options for signing in with a passkey
No authentication · startPasskeySignIn
#87. Anonymous, like login: the options for navigator.credentials.get(), with a single-use challenge (stored as its SHA-256 only, valid 5 minutes), the RP ID and user verification required; no allowed credentials, so the authenticator offers the person's passkeys for this site (no email first). The body is empty or {}. Not audited (a challenge changes no record; the sign-in is audited). Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed. no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Responses
| Status | Type | Description |
|---|---|---|
| 200 | PasskeyRequestOptionsapplication/json | The options. |
| 400 | Errorapplication/json | Invalid JSON, a field (the body takes none) or a bad X-Request-Id. |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"public_key": {
"challenge": "q83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJA",
"rpId": "txng.theio.vn",
"timeout": 300000,
"userVerification": "required",
"allowCredentials": []
}
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "passkeys unavailable: the server has no public origin (AGRITRACE_PUBLIC_ORIGIN)",
"code": "passkeys_unavailable"
}POST /v1/auth/passkeys/login
Sign in with a passkey
No authentication · signInWithPasskey
#87. Anonymous, like login: the answer of navigator.credentials.get() for the options of startPasskeySignIn opens a session (cookie, csrf_token), in one transaction with the audit row (auth.login, second_factor: passkey; a refusal is auth.login.passkey.failed, naming the account only when the passkey's signature verified). Verified as WebAuthn Level 2 section 7.2 asks: the single-use challenge (used up whatever the outcome), the webauthn.get client data at the public origin, the RP ID hash, the user present and user verified flags, the user handle and the signature with the stored key. A signature counter that does not move forward (unless the authenticator keeps none) is refused and marks the passkey (clone_warning_at). A disabled account is refused. User verification stands in for the password and the passkey is the second factor: the session counts as having proved both now, so it satisfies two-step sign-in (SELF-1-6, #187) and the step-up of the highest-impact writes (#87 part A) for as long as a code would. Every refusal is the same 401. Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Request body
PasskeyLogin (required)
Media type: application/json
Example request · application/json
{
"credential_id": "AAECAwQFBgcICQoLDA0ODw",
"client_data_json": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0In0",
"authenticator_data": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2MFAAAAAQ",
"signature": "MEUCIQDf8bWWy-8Y5H0SsX0vT6g",
"user_handle": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGk"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | AuthSessionapplication/json | Signed in. Send |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a field missing or not text, or a bad X-Request-Id. |
| 401 | Errorapplication/json | The passkey did not verify, is unknown, its challenge is unknown, used or expired, its counter did not move forward, or the account is disabled. |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Set-Cookie | 200 | string | The session cookie ( |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ"
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · required
{
"error": "credential_id, client_data_json, authenticator_data, signature and user_handle are required",
"code": "credential_id_client_data_json_authenticator_data_signature_and_user_handle_are_required"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "invalid passkey",
"code": "invalid_passkey"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "passkeys unavailable: the server has no public origin (AGRITRACE_PUBLIC_ORIGIN)",
"code": "passkeys_unavailable"
}POST /v1/auth/oidc/start
Begin a sign-in with the company's identity provider
No authentication · startOidcSignIn
#87 (OpenID Connect). Anonymous, like login: for a company whose admins set up an identity provider (PUT /v1/company/identity-provider), the provider's authorization URL to send the browser to (the authorization code flow with PKCE S256 and the company's own redirect URI, {origin}/login/oidc/{company}), and an HttpOnly cookie (__Host-agt_oidc) that holds the sign-in for 10 minutes and binds it to this browser: the state's SHA-256, the nonce and the code verifier, encrypted (AES-256-GCM under a key derived from AGRITRACE_ISSUER_KEK). Nothing is stored on the server, so starts never fill up. A company without an enabled provider and an unknown company answer the same 404. Not audited (it changes no account or record; finishing the sign-in is). Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Request body
OidcStart (required)
Media type: application/json
Example request · application/json
{
"company": "coop-dl"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | OidcStartedapplication/json | Send the browser to |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 404 | Errorapplication/json | The company has no enabled identity provider, or there is no such company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 502 | Errorapplication/json | The company's identity provider did not answer, or answered outside the rules (its discovery document or key set could not be read). Nothing was stored; try again later. |
| 503 | Errorapplication/json | This deployment does not allow sign-in with an identity provider (no AGRITRACE_PUBLIC_ORIGIN or no AGRITRACE_OIDC_ALLOWED_HOSTS), or the sign-in cannot be sealed (no AGRITRACE_ISSUER_KEK). |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
Set-Cookie | 200 | string | The session cookie ( |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 502 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"authorization_url": "https://login.coop.example/authorize?response_type=code&client_id=croppath-console&redirect_uri=https%3A%2F%2Ftxng.theio.vn%2Flogin%2Foidc%2Fcoop-dl&scope=openid+email&state=q3Vb0mXl2sQ&nonce=Zx9a&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256",
"expires_at": 1790087000
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · required
{
"error": "company is required",
"code": "company_is_required"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "not found: identity provider",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 502 · application/json
{
"error": "identity provider unreachable",
"code": "identity_provider_unreachable"
}Response 503 · application/json · unavailable
{
"error": "identity provider sign-in unavailable: no identity provider host is allowed (AGRITRACE_OIDC_ALLOWED_HOSTS)",
"code": "identity_provider_sign_in_unavailable"
}POST /v1/auth/oidc/callback
Finish a sign-in with the company's identity provider
No authentication · finishOidcSignIn
#87 (OpenID Connect). Anonymous, like login: the state and code the identity provider sent to the company's redirect URI ({origin}/login/oidc/{company}), with that company and the iss the provider added (RFC 9207, when it sends one), from the browser that started the sign-in (its __Host-agt_oidc cookie). The cookie must hold this state; the state is then used up first, whatever the outcome. The company must be the one the sign-in was started for, so a response from another company's provider is never redeemed with this one's (the mix-up attack). A sent iss must be the provider's issuer, and it is required when the provider's discovery document says authorization_response_iss_parameter_supported. The code is exchanged at the provider's token endpoint with the PKCE verifier and the client secret, and the ID token is verified: RS256 or ES256 only (none and HMAC are refused), a key of the provider's key set (fetched again when the key id is new, at most once a minute), the issuer, the audience (and azp), exp, iat and nbf with 60 seconds of tolerance, and the nonce of this sign-in. The provider's subject signs in the account linked to it; without a link, a verified email (email_verified true) of an existing account links that account. No account is ever created, and the account must be active and hold memberships of the provider's company only: a member of another company (a turned-off membership counts, since that company may turn it back on), a platform admin and a lab account are refused, and so is an account with no active membership. Two-step sign-in applies as after a password: an account with an authenticator app gets a login ticket (202) for POST /v1/auth/login/second-factor; otherwise the session opens (200) with no second factor proved. The audit row (auth.login, method: oidc, linked) commits with the link and the session or ticket; a refusal is auth.login.oidc.failed, naming the account only once the ID token verified. Every refusal is the same 401. Takes a token from the login rate-limit bucket before anything else. When an Origin header is sent it must be allowed. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.
Request body
OidcCallback (required)
Media type: application/json
Example request · application/json
{
"state": "q3Vb0mXl2sQ",
"code": "SplxlOBeZQQYbYS6WxSbIA",
"company": "coop-dl",
"iss": "https://login.coop.example"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | AuthSessionapplication/json | Signed in. Send |
| 202 | SecondFactorChallengeapplication/json | The account has two-step sign-in. No session and no cookie yet: send the ticket and a code to POST /v1/auth/login/second-factor. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, |
| 401 | Errorapplication/json | The sign-in was refused: a state this browser did not start, a used or expired state, another company's redirect URI, an |
| 403 | Errorapplication/json | The Origin header is present and not allowed. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 429 | Errorapplication/json | Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 502 | Errorapplication/json | The company's identity provider did not answer, or answered outside the rules (its discovery document or key set could not be read). The state is used up: a retry of the same callback is refused (401); start the sign-in again. |
| 503 | Errorapplication/json | This deployment does not allow sign-in with an identity provider, or the client secret cannot be read (no AGRITRACE_ISSUER_KEK). |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
Set-Cookie | 200 | string | The session cookie ( |
X-Request-Id | 202 | string | Request id: the caller's |
Cache-Control | 202 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 502 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"user": {
"id": 1,
"email": "alice@coop.example",
"display_name": "Alice"
},
"memberships": [
{
"tenant": "coop-dl",
"role": "tenant_admin",
"facilities": null,
"lab_id": null
}
],
"csrf_token": "q3Vb0mXl2sQ"
}Response 202 · application/json
{
"second_factor": "required",
"ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
"expires_at": 1790086700
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}Response 400 · application/json · required
{
"error": "state, code and company are required",
"code": "state_code_and_company_are_required"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "identity provider sign-in refused",
"code": "identity_provider_sign_in_refused"
}Response 403 · application/json
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 502 · application/json
{
"error": "identity provider unreachable",
"code": "identity_provider_unreachable"
}Response 503 · application/json · unavailable
{
"error": "identity provider sign-in unavailable: no identity provider host is allowed (AGRITRACE_OIDC_ALLOWED_HOSTS)",
"code": "identity_provider_sign_in_unavailable"
}