CropPath cho nhà phát triển

Tài liệu API

auth

29 thao tác

POST /v1/auth/login

Sign in with email and password

Không cần xác thực · 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.

Nội dung yêu cầu

LoginRequest (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "email": "alice@coop.example",
  "password": "correct horse battery"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200AuthSession
application/json

Signed in. Send csrf_token as X-CSRF-Token on unsafe methods.

202SecondFactorChallenge
application/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.

400Error
application/json

email or password missing or not a string, or the body is not a JSON object.

401Error
application/json

Credentials refused.

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/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 Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

Too many password hashes are running; retry after the delay.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

Cache-Control200string

no-store on session responses.

X-Request-Id202string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control202string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 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"
}
Phản hồi 202 · application/json
{
  "second_factor": "required",
  "ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
  "expires_at": 1790086700
}
Phản hồi 400 · application/json
{
  "error": "email and password are required",
  "code": "email_and_password_are_required"
}
Phản hồi 401 · application/json
{
  "error": "invalid credentials",
  "code": "invalid_credentials"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/login/second-factor

Finish a two-step sign-in with a code

Không cần xác thực · 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.

Nội dung yêu cầu

SecondFactorLogin (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
  "code": "492039"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200SecondFactorSession
application/json

Signed in. Send csrf_token as X-CSRF-Token on unsafe methods.

400Error
application/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.

401Error
application/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).

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/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 Retry-After seconds.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 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
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · code_required
{
  "error": "code is required: the 6-digit code from the app, or a backup code",
  "code": "code_is_required"
}
Phản hồi 400 · application/json · both
{
  "error": "send code or backup_code, not both",
  "code": "send_code_or_backup_code_not_both"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · expired
{
  "error": "sign-in expired: enter your password again",
  "code": "sign_in_expired"
}
Phản hồi 401 · application/json · invalid_code
{
  "error": "invalid code",
  "code": "invalid_code"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json · kek
{
  "error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
  "code": "issuer_keys_unavailable"
}
Phản hồi 503 · application/json · busy
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/logout

End the current session

Xác thực: cookie · logout

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

Revokes the session and clears the cookie. Unsafe method: needs X-CSRF-Token and an allowed Origin.

Phản hồi

Mã trạng tháiKiểuMô tả
204

Signed out. No body; the Set-Cookie header clears the cookie.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id204string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Set-Cookie204string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

Cache-Control204string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/auth/me

Who am I

Xác thực: cookie · getCurrentSession

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Phản hồi

Mã trạng tháiKiểuMô tả
200Me
application/json

The current session.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/json

The caller is refused: tenant not allowed (X-Tenant). Session routes are open to every role, so there is no role check.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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"
  ]
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/auth/password

Change the signed-in user's password

Xác thực: cookie · changePassword

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Nội dung yêu cầu

PasswordChangeRequest (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "current_password": "correct horse battery",
  "new_password": "another long passphrase"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200PasswordChanged
application/json

Password changed; continue on the fresh session.

400Error
application/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.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "csrf_token": "Zk1pQ8w2Ls"
}
Phản hồi 400 · application/json · missing
{
  "error": "current_password and new_password are required",
  "code": "current_password_and_new_password_are_required"
}
Phản hồi 400 · application/json · weak
{
  "error": "password must be at least 12 characters",
  "code": "password_must_be_at_least_12_characters"
}
Phản hồi 400 · application/json · wrong_current
{
  "error": "current password is incorrect",
  "code": "current_password_is_incorrect"
}
Phản hồi 400 · application/json · code_required
{
  "error": "code is required: the 6-digit code from the app, or a backup code",
  "code": "code_is_required"
}
Phản hồi 400 · application/json · wrong_code
{
  "error": "current password or code is incorrect",
  "code": "current_password_or_code_is_incorrect"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/reauth

Prove the signed-in user's password again

Xác thực: cookie · reauthenticate

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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).

Nội dung yêu cầu

ReauthRequest (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "password": "correct horse battery"
}

Phản hồi

Mã trạng tháiKiểuMô tả
204

Password confirmed for this session. No body.

400Error
application/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.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

Too many password hashes are running; retry after the delay.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id204string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control204string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 400 · application/json · missing
{
  "error": "password is required",
  "code": "password_is_required"
}
Phản hồi 400 · application/json · wrong
{
  "error": "password is incorrect",
  "code": "password_is_incorrect"
}
Phản hồi 400 · application/json · code_required
{
  "error": "code is required: the 6-digit code from the app, or a backup code",
  "code": "code_is_required"
}
Phản hồi 400 · application/json · wrong_code
{
  "error": "password or code is incorrect",
  "code": "password_or_code_is_incorrect"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "busy, retry",
  "code": "busy_retry"
}

GET /v1/auth/sessions

The signed-in user's devices (live sessions)

Xác thực: cookie · listMySessions

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Phản hồi

Mã trạng tháiKiểuMô tả
200SignedInSessionList
application/json

The live sessions.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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
    }
  ]
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/auth/sessions/revoke-others

Sign out everywhere else

Xác thực: cookie · revokeMyOtherSessions

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Phản hồi

Mã trạng tháiKiểuMô tả
200SessionsRevoked
application/json

Every other session ended.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "sessions_revoked": 2
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 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

Xác thực: cookie · revokeMySession

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The session's id (from listMySessions).

Phản hồi

Mã trạng tháiKiểuMô tả
200SignedInSessionRevoked
application/json

The session ended.

400Error
application/json

The session making the request (sign out instead), or a bad X-Request-Id.

401Error
application/json

No valid session cookie.

403Error
application/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.

404Error
application/json

No live session of the signed-in user with that id (another user's session answers the same).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "id": 37,
  "revoked": true
}
Phản hồi 400 · application/json · current_session
{
  "error": "current session: sign out to end the session you are using",
  "code": "current_session"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: 37",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/auth/email-settings

The signed-in person's email setting

Xác thực: cookie · getMyEmailSettings

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Phản hồi

Mã trạng tháiKiểuMô tả
200EmailSettings
application/json

The setting.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "notifications": true,
  "language": "vi",
  "delivery": false
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 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

Xác thực: cookie · updateMyEmailSettings

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Nội dung yêu cầu

EmailSettingsUpdate (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "notifications": false,
  "language": "en"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200EmailSettings
application/json

Saved; the new setting.

400Error
application/json

Invalid JSON, an unknown field, notifications missing or not a boolean, an unknown language, or a bad X-Request-Id.

401Error
application/json

No valid session cookie.

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "notifications": false,
  "language": "en",
  "delivery": false
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · notifications
{
  "error": "notifications must be true or false",
  "code": "notifications_must_be_true_or_false"
}
Phản hồi 400 · application/json · language
{
  "error": "language must be one of: vi, en, zh-Hans",
  "code": "language_must_be_one_of"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 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

Không cần xác thực · 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.

Nội dung yêu cầu

PasswordRecoveryRequest (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "email": "alice@coop.example",
  "backup_code": "abcd-efgh-ijkl-mnop",
  "new_password": "another long passphrase"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200PasswordRecovered
application/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.

400Error
application/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.

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many attempts from this client address (the login bucket), or for this email (5 an hour). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

Busy (no password hashing slot free in time). Nothing changed; retry after Retry-After seconds.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "backup_codes_left": 9,
  "second_factor": "required"
}
Phản hồi 400 · application/json · refused
{
  "error": "email or backup code is incorrect",
  "code": "email_or_backup_code_is_incorrect"
}
Phản hồi 400 · application/json · missing
{
  "error": "email, backup_code and new_password are required",
  "code": "email_backup_code_and_new_password_are_required"
}
Phản hồi 400 · application/json · weak
{
  "error": "password must be at least 12 characters",
  "code": "password_must_be_at_least_12_characters"
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/two-factor/setup

Start setting up the authenticator app

Xác thực: cookie · setUpTwoFactor

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Phản hồi

Mã trạng tháiKiểuMô tả
200TwoFactorSetup
application/json

The secret, shown this once.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

Two-step sign-in is already on: turn it off (POST /v1/auth/two-factor/disable, with set_up_again for a new phone) first.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/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 Retry-After seconds once it is configured.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 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
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json
{
  "error": "already on: turn two-step sign-in off before setting it up again",
  "code": "already_on"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 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

Xác thực: cookie · confirmTwoFactor

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Nội dung yêu cầu

TwoFactorCode (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "code": "492039"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200BackupCodes
application/json

On. The backup codes, shown this once.

400Error
application/json

The code is missing or wrong, or the body is not a JSON object; or a bad X-Request-Id.

401Error
application/json

No valid session cookie.

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

No setup to confirm: start with POST /v1/auth/two-factor/setup.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/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 Retry-After seconds.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 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"
  ]
}
Phản hồi 400 · application/json · missing
{
  "error": "code is required",
  "code": "code_is_required"
}
Phản hồi 400 · application/json · invalid
{
  "error": "invalid code",
  "code": "invalid_code"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json
{
  "error": "nothing to confirm: start the setup again",
  "code": "nothing_to_confirm"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json · kek
{
  "error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
  "code": "issuer_keys_unavailable"
}
Phản hồi 503 · application/json · busy
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/two-factor/disable

Turn the authenticator app off

Xác thực: cookie · disableTwoFactor

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Nội dung yêu cầu

TwoFactorDisable (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "password": "correct horse battery",
  "code": "492039"
}

Phản hồi

Mã trạng tháiKiểuMô tả
204

Off. No body.

400Error
application/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.

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

Two-step sign-in is not on, or this account must use it.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/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 Retry-After seconds.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id204string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control204string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 400 · application/json · password
{
  "error": "password is required",
  "code": "password_is_required"
}
Phản hồi 400 · application/json · code
{
  "error": "code is required: the 6-digit code from the app, or a backup code",
  "code": "code_is_required"
}
Phản hồi 400 · application/json · wrong
{
  "error": "password or code is incorrect",
  "code": "password_or_code_is_incorrect"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · not_on
{
  "error": "not on: two-step sign-in is not set up for this account",
  "code": "not_on"
}
Phản hồi 409 · application/json · required
{
  "error": "two-step sign-in required: it cannot be turned off for this account",
  "code": "two_step_sign_in_required"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json · kek
{
  "error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
  "code": "issuer_keys_unavailable"
}
Phản hồi 503 · application/json · busy
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/auth/backup-codes

Get 10 new backup codes

Xác thực: cookie · regenerateBackupCodes

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

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.

Phản hồi

Mã trạng tháiKiểuMô tả
200BackupCodes
application/json

The new backup codes, shown this once.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

Two-step sign-in is not on.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

Busy (no password hashing slot free in time): retry after Retry-After seconds; nothing changed.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 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"
  ]
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json
{
  "error": "not on: two-step sign-in is not set up for this account",
  "code": "not_on"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "busy, retry",
  "code": "busy_retry"
}

POST /v1/oauth/token

Get an access token (OAuth2 client credentials)

Không cần xác thực · 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.

Nội dung yêu cầu

OAuthTokenRequest (bắt buộc)

Kiểu nội dung: application/x-www-form-urlencoded

Ví dụ yêu cầu · application/x-www-form-urlencoded
{
  "grant_type": "client_credentials",
  "scope": "lot_read"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200OAuthToken
application/json

The access token.

400OAuthError
application/json

RFC 6749 §5.2: invalid_request (not a form body, a parameter given twice, no grant_type, two authentication methods), unsupported_grant_type (anything but client_credentials) or invalid_scope (a malformed scope or one the client was not granted); or a bad X-Request-Id; or an Idempotency-Key header (idempotency_key_not_supported, the API's usual body).

401OAuthError
application/json

Client authentication failed (RFC 6749 §5.2 invalid_client): no credentials, a malformed Basic header, an unknown or revoked client or a wrong secret, all answered the same.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429OAuthError
application/json

Too many requests from this client address (see the 429 of the bucket, too_many_requests), or the client already holds 20 live tokens (invalid_request, Retry-After until its oldest expires).

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store (RFC 6749 §5.1).

Pragma200string

no-cache.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control400string

no-store (RFC 6749 §5.1).

Pragma400string

no-cache.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control401string

no-store (RFC 6749 §5.1).

Pragma401string

no-cache.

WWW-Authenticate401string

Basic realm="agritrace".

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control429string

no-store (RFC 6749 §5.1).

Pragma429string

no-cache.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "access_token": "ago_VGhpcyBpcyBhbiBleGFtcGxlIGFjY2VzcyB0b2tlbiE",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "lot_read lot_write"
}
Phản hồi 400 · application/json · invalid_request
{
  "error": "invalid_request",
  "error_description": "grant_type is required",
  "code": "invalid_request"
}
Phản hồi 400 · application/json · unsupported_grant_type
{
  "error": "unsupported_grant_type",
  "error_description": "only client_credentials is supported",
  "code": "unsupported_grant_type"
}
Phản hồi 400 · application/json · invalid_scope
{
  "error": "invalid_scope",
  "error_description": "scope: a permission the client was not granted",
  "code": "invalid_scope"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "invalid_client",
  "error_description": "client authentication failed",
  "code": "invalid_client"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json · throttled
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 429 · application/json · live_tokens
{
  "error": "invalid_request",
  "error_description": "too many live tokens: at most 20 per client",
  "code": "invalid_request"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/oauth/revoke

Revoke an access token (RFC 7009)

Không cần xác thực · 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.

Nội dung yêu cầu

OAuthRevokeRequest (bắt buộc)

Kiểu nội dung: application/x-www-form-urlencoded

Ví dụ yêu cầu · application/x-www-form-urlencoded
{
  "token": "ago_VGhpcyBpcyBhbiBleGFtcGxlIGFjY2VzcyB0b2tlbiE",
  "token_type_hint": "access_token"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200object
application/json

Done (or nothing to do).

400OAuthError
application/json

RFC 6749 §5.2 invalid_request: not a form body, a parameter given twice, no token, two authentication methods; or a bad X-Request-Id; or an Idempotency-Key header (idempotency_key_not_supported, the API's usual body).

401OAuthError
application/json

Client authentication failed (RFC 6749 §5.2 invalid_client): no credentials, a malformed Basic header, an unknown or revoked client or a wrong secret, all answered the same.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429OAuthError
application/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 Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store (RFC 6749 §5.1).

Pragma200string

no-cache.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control400string

no-store (RFC 6749 §5.1).

Pragma400string

no-cache.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control401string

no-store (RFC 6749 §5.1).

Pragma401string

no-cache.

WWW-Authenticate401string

Basic realm="agritrace".

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control429string

no-store (RFC 6749 §5.1).

Pragma429string

no-cache.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{}
Phản hồi 400 · application/json · invalid_request
{
  "error": "invalid_request",
  "error_description": "token is required",
  "code": "invalid_request"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "invalid_client",
  "error_description": "client authentication failed",
  "code": "invalid_client"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/auth/passkeys

The signed-in user's passkeys

Xác thực: cookie · listMyPasskeys

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Phản hồi

Mã trạng tháiKiểuMô tả
200PasskeyList
application/json

The passkeys.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie.

403Error
application/json

The caller is refused: tenant not allowed (X-Tenant). Session routes are open to every role, so there is no role check.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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
    }
  ]
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/auth/passkeys

Add a passkey to the signed-in user's account

Xác thực: cookie · registerPasskey

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Nội dung yêu cầu

PasskeyRegistration (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "client_data_json": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0",
  "attestation_object": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YUA",
  "transports": [
    "internal"
  ],
  "nickname": "Work phone"
}

Phản hồi

Mã trạng tháiKiểuMô tả
201Passkey
application/json

The passkey was added.

400Error
application/json

Invalid JSON, an unknown field, a malformed nickname or transports, a bad X-Request-Id; or the passkey does not verify (invalid_passkey: its challenge is unknown, used, expired or another account's, or a check failed).

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The account has 10 passkeys already, or this passkey is registered already.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control201string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · nickname
{
  "error": "nickname too long: at most 64 characters",
  "code": "nickname_too_long"
}
Phản hồi 400 · application/json · invalid_passkey
{
  "error": "invalid passkey: challenge unknown or used",
  "code": "invalid_passkey"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · too_many
{
  "error": "too many passkeys: an account has at most 10",
  "code": "too_many_passkeys"
}
Phản hồi 409 · application/json · registered
{
  "error": "passkey already registered",
  "code": "passkey_already_registered"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 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

Xác thực: cookie · startPasskeyRegistration

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Phản hồi

Mã trạng tháiKiểuMô tả
200PasskeyCreationOptions
application/json

The options.

400Error
application/json

Invalid JSON, a field (the body takes none) or a bad X-Request-Id.

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The account has 10 passkeys already.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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"
        ]
      }
    ]
  }
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json
{
  "error": "too many passkeys: an account has at most 10",
  "code": "too_many_passkeys"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 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

Xác thực: cookie · renamePasskey

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The passkey's id (from listMyPasskeys).

Nội dung yêu cầu

PasskeyRename (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "nickname": "Work phone"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200Passkey
application/json

Renamed.

400Error
application/json

Invalid JSON, an unknown field, no or a malformed nickname, or a bad X-Request-Id.

401Error
application/json

No valid session cookie.

403Error
application/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.

404Error
application/json

No passkey of the signed-in user with that id (another user's passkey answers the same).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · required
{
  "error": "nickname is required",
  "code": "nickname_is_required"
}
Phản hồi 400 · application/json · too_long
{
  "error": "nickname too long: at most 64 characters",
  "code": "nickname_too_long"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

DELETE /v1/auth/passkeys/{id}

Remove one of the signed-in user's passkeys

Xác thực: cookie · removePasskey

Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được

#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.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The passkey's id (from listMyPasskeys).

Phản hồi

Mã trạng tháiKiểuMô tả
204

Removed.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session cookie; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required); or, for an account with two-step sign-in, a session whose code (or passkey sign-in) was last confirmed more than 5 minutes ago (mfa_step_up_required): confirm with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written.

403Error
application/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.

404Error
application/json

No passkey of the signed-in user with that id (another user's passkey answers the same).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id204string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control204string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json · session
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 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"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/auth/passkeys/authentication-options

Options for signing in with a passkey

Không cần xác thực · 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.

Phản hồi

Mã trạng tháiKiểuMô tả
200PasskeyRequestOptions
application/json

The options.

400Error
application/json

Invalid JSON, a field (the body takes none) or a bad X-Request-Id.

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "public_key": {
    "challenge": "q83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJA",
    "rpId": "txng.theio.vn",
    "timeout": 300000,
    "userVerification": "required",
    "allowCredentials": []
  }
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 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

Không cần xác thực · 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.

Nội dung yêu cầu

PasskeyLogin (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "credential_id": "AAECAwQFBgcICQoLDA0ODw",
  "client_data_json": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0In0",
  "authenticator_data": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2MFAAAAAQ",
  "signature": "MEUCIQDf8bWWy-8Y5H0SsX0vT6g",
  "user_handle": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGk"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200AuthSession
application/json

Signed in. Send csrf_token as X-CSRF-Token on unsafe methods.

400Error
application/json

Invalid JSON, an unknown field, a field missing or not text, or a bad X-Request-Id.

401Error
application/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.

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

The server has no public origin (AGRITRACE_PUBLIC_ORIGIN), the passkeys' Relying Party: passkeys cannot be used.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

Cache-Control200string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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"
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 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"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "invalid passkey",
  "code": "invalid_passkey"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 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

Không cần xác thực · 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.

Nội dung yêu cầu

OidcStart (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "company": "coop-dl"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200OidcStarted
application/json

Send the browser to authorization_url.

400Error
application/json

Invalid JSON, an unknown field, company missing or not text, or a bad X-Request-Id.

403Error
application/json

The Origin header is present and not allowed.

404Error
application/json

The company has no enabled identity provider, or there is no such company.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

502Error
application/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.

503Error
application/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).

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id502string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · required
{
  "error": "company is required",
  "code": "company_is_required"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: identity provider",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 502 · application/json
{
  "error": "identity provider unreachable",
  "code": "identity_provider_unreachable"
}
Phản hồi 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

Không cần xác thực · 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.

Nội dung yêu cầu

OidcCallback (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "state": "q3Vb0mXl2sQ",
  "code": "SplxlOBeZQQYbYS6WxSbIA",
  "company": "coop-dl",
  "iss": "https://login.coop.example"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200AuthSession
application/json

Signed in. Send csrf_token as X-CSRF-Token on unsafe methods.

202SecondFactorChallenge
application/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.

400Error
application/json

Invalid JSON, an unknown field, state, code or company missing or not text, iss not text, or a bad X-Request-Id.

401Error
application/json

The sign-in was refused: a state this browser did not start, a used or expired state, another company's redirect URI, an iss that is not the provider's (or missing when the provider sends it), a provider removed, turned off or changed since the start, a code the provider refused, an ID token that does not verify (malformed text included), no linked account and no verified, well-formed email of an existing account, or an account that is disabled, has no active membership, holds a membership of another company (a turned-off one too) or is a platform admin or lab account.

403Error
application/json

The Origin header is present and not allowed.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sign-in attempts from this client address (the login bucket). Nothing was checked; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

502Error
application/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.

503Error
application/json

This deployment does not allow sign-in with an identity provider, or the client secret cannot be read (no AGRITRACE_ISSUER_KEK).

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

no-store on session responses.

Set-Cookie200string

The session cookie (__Host-agt_sid; agt_sid in insecure dev mode): Path=/, HttpOnly, SameSite=Lax, Max-Age, and Secure unless insecure cookies are on. Logout sends Max-Age=0 with an empty value.

X-Request-Id202string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control202string

no-store on session responses.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id502string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 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"
}
Phản hồi 202 · application/json
{
  "second_factor": "required",
  "ticket": "3q2-7wAAAAAB8kY0T3QxZ2dQbW5oS2Q1cHJ0eWFjdGl2",
  "expires_at": 1790086700
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · required
{
  "error": "state, code and company are required",
  "code": "state_code_and_company_are_required"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "identity provider sign-in refused",
  "code": "identity_provider_sign_in_refused"
}
Phản hồi 403 · application/json
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 502 · application/json
{
  "error": "identity provider unreachable",
  "code": "identity_provider_unreachable"
}
Phản hồi 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"
}