openapi: 3.1.0 info: title: account — module contract version: '0.1.0' # The tags this module's operations file themselves under, with what each is for. tags: - name: Auth x-family: Core description: Sign up, log in, refresh and end a session, and recover or verify an account by email. - name: Account x-family: Core description: The signed-in user's own account - profile, credentials, two-factor, data export and deletion. x-error-codes: EMAIL_ALREADY_CURRENT: { status: 409, description: 'The requested address is the one the account already has, so there is nothing to change.' } EMAIL_ALREADY_USED: { status: 409, description: 'Another account already holds this email address — on signup, or on an email change.' } EMAIL_ALREADY_VERIFIED: { status: 409, description: 'The account''s email address is verified already, so there is nothing to resend.' } EMAIL_CHANGE_ALREADY_PENDING: { status: 409, description: 'This address is already the pending one, and its link is on the way — `POST /account/email-change/resend` mails it again.' } EMAIL_CHANGE_TOO_SOON: { status: 429, description: 'An email change was already requested for this account in the last minute — carries `details.retryAfter`.' } EMAIL_VERIFY_RESEND_TOO_SOON: { status: 429, description: 'A verification email was already sent recently — carries `details.retryAfter`.' } SESSION_IDLE: { status: 401, description: 'A staff or admin session saw no real request for longer than `NODE_SESSION_IDLE_TIME_STAFF`, and ended. Sign in again. A shopper never gets this.' } TWO_FACTOR_RESEND_TOO_SOON: { status: 429, description: 'A two-factor code was already sent recently — carries `details.retryAfter`.' } # This module's section of the account data export (`POST /account/export`): the bundler adds it # to `AccountExportResponse`. Removing the module removes the section. x-personal-data: sessions: schema: type: array items: $ref: '#/components/schemas/ExportSession' paths: # --------- Authentication and profile --------- /account: # Bundler: adds the `If-Match` parameter and 412 to the writes listed, and `ETag` to the 200s. x-versioned: [get, put, patch] get: tags: [Account] summary: Current user info description: | Returns the full profile of the currently authenticated user, plus two read-only members that ride with it so a client needs no second call: `abilities` (the rules the SERVER enforces, packed for the client to evaluate) and `activity` (the session's idle clock). `abilities` is the same object a sign-in and a token refresh carry. The client's copy has NO AUTHORITY: it decides what to render, never what is allowed, and every request is re-evaluated server-side. A non-passive `GET /account` also counts as activity, so a restore needs no separate touch. The `ETag`'s edit part is the stored account's revision, which a role change moves, so an `If-Match` taken from an earlier read answers `412` after one. Its body part moves on every read (`lastActiveAt`). operationId: getAccount security: - bearerAuth: [] responses: '200': description: Current user info, with the caller's abilities and idle clock content: application/json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/AccountView' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } put: tags: [Account] summary: Replace own profile description: Replaces every writable field of the authenticated user's own profile — username, locale (RFC 9110 §9.3.4, an omitted optional field is cleared). The image is outside the representation — set by an upload, cleared by an explicit `imageUrl` null, kept when a PUT never mentions it. `analyticsConsent` is required — it has no cleared state, so a PUT always states it and consent is never reset or withdrawn by a forgotten field. Role, account state, email and password are out of scope — the first two belong to the admin `/users` endpoints, the email to `POST /account/email-change`, the password to `POST /account/password`. An `email` in the body is refused with 422 like any unknown field. operationId: replaceAccount security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ReplaceAccountRequest' multipart/form-data: schema: $ref: '#/components/schemas/ReplaceAccountRequestMultipart' responses: '200': description: Replaced profile content: application/json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Account' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `uploadLimiter` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } patch: tags: [Account] summary: Update own profile description: Merges the given fields into the authenticated user's own profile — username, locale, image (RFC 7396, an omitted field is left unchanged, `null` clears an optional one). Role, account state, email and password are out of scope — the first two belong to the admin `/users` endpoints, the email to `POST /account/email-change`, the password to `POST /account/password`. An `email` in the body is refused with 422 like any unknown field. operationId: updateAccount security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateAccountRequest' application/merge-patch+json: schema: $ref: '#/components/schemas/UpdateAccountRequest' multipart/form-data: schema: $ref: '#/components/schemas/UpdateAccountRequestMultipart' responses: '200': description: Updated profile content: application/json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Account' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `uploadLimiter` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } delete: tags: [Account] summary: Delete the account (locked at once, erased after a grace) description: >- Locks the authenticated user's account at once and schedules its erasure. Every session dies with the call (the session cookie is cleared) and the account can no longer sign in, so the answer is the last thing the caller sees. The account is erased `NODE_ACCOUNT_DELETION_GRACE_DAYS` days later (30 by default, never more than one calendar month: GDPR Art. 12(3)), at `purgeAt`. Until then it can be brought back by the link in the mail this call sends (`POST /account/restore`), by signing in (`POST /account/login` offers the restore), or by staff (`POST /users/{id}/restore`). Needs a critically fresh session; an account with a second factor armed also needs an `otp` proof in it (`401 REAUTH_REQUIRED` with `details.methods`). operationId: requestAccountDelete x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] responses: '202': description: The account is locked and its erasure is scheduled content: application/json: schema: $ref: '#/components/schemas/AccountDeletion' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/email-change: # Bundler: adds `ETag` and `Content-Location` to the 2xx answers: they name the account this answers. x-versioned: [post] post: tags: [Account] summary: Request an email change description: Starts a change of the account's sign-in and recovery address. The new address is held as `pendingEmail` until `POST /account/email-change/confirm` proves it, and a notice carrying a 7-day one-time undo link (`POST /account/email-change/undo`) is sent to the OLD address the moment the change is requested. A different address while one is already pending replaces it, revokes the earlier link and mails both addresses again. Needs a fresh session, always; an account with a second factor armed also needs an `otp` proof in it (`401 REAUTH_REQUIRED` with `details.methods`). Answers 409 `EMAIL_ALREADY_CURRENT` for the address the account already has and `EMAIL_CHANGE_ALREADY_PENDING` for the one already pending (nothing is mailed; `POST /account/email-change/resend` mails it again), and 409 `EMAIL_ALREADY_USED` when another account holds it. Answers 429 `EMAIL_CHANGE_TOO_SOON` inside the minute after the previous request. Cancel a pending change with `DELETE /account/email-change`. operationId: requestEmailChange x-error-codes: '401': [REAUTH_REQUIRED] '409': [EMAIL_ALREADY_CURRENT, EMAIL_ALREADY_USED, EMAIL_CHANGE_ALREADY_PENDING] '429': [EMAIL_CHANGE_TOO_SOON] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RequestEmailChangeRequest' responses: '200': description: The change is pending; both addresses have been mailed. The body is what `GET /account` answers content: application/json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/AccountView' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '409': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Conflict' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `signedInCredentialLimiters` sit in front of this route, and the service paces a # request inside the previous one's minute — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } delete: tags: [Account] summary: Cancel a pending email change description: Discards a pending `pendingEmail` change started by `POST /account/email-change`, without proving it. A no-op when nothing is pending — a client does not need to check `GET /account` first. operationId: cancelPendingEmailChange security: - bearerAuth: [] responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/email-change/resend: post: tags: [Account] summary: Resend the pending email confirmation description: Mails the NEW (pending) address a fresh confirmation link — and only that address; the old one is not told again. The previous link stops working, since only the newest one counts. Answers 200 with `resendAfter`, the seconds a client counts down before offering the button again — the same shape as `POST /account/email-verification/resend`. A no-op, answering 200 with `resendAfter` 0 and mailing nothing, when nothing is pending, so a client does not need to check `GET /account` first. Sending the pending address again through `POST /account/email-change` is refused with 409, which is why this route exists. Answers 429 inside the previous send's cooldown (the same 60 seconds as `POST /account/email-verification/resend`, with `details.retryAfter` naming the wait) and spends the same per-account budget on a failure, so a client that waits never sees one. No fresh-auth guard — it mails an address the caller already asked for and changes nothing about the account. operationId: resendPendingEmail x-error-codes: '409': [EMAIL_ALREADY_VERIFIED] '429': [EMAIL_VERIFY_RESEND_TOO_SOON] security: - bearerAuth: [] responses: '200': description: The confirmation link is on its way to the pending address, or nothing was pending (then `resendAfter` is 0) content: application/json: schema: $ref: '#/components/schemas/EmailVerificationRequested' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # `credentialLimiters` sits in front of this route, and the service refuses a send # inside the previous one's cooldown — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/password: post: tags: [Auth] summary: Change password description: Changes the authenticated user's password. Unlike the reset flow this proves possession of the current password rather than of the mailbox, so it needs no email round-trip. Every session is revoked and every pending one-time link and login challenge is purged; the response carries a fresh access token for the calling session, and sets fresh session cookies. An account with a second factor armed also needs a fresh session that proved an `otp` (`401 REAUTH_REQUIRED` with `details.methods`); an account without one is asked nothing new. operationId: changePassword x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ChangePasswordRequest' responses: '200': description: | Password changed. The body normally carries a fresh access token for this session, but is `{}` on the rare degraded success where the re-mint itself fails after the password write already committed — see `AuthTokens`. content: application/json: schema: $ref: '#/components/schemas/AuthTokens' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # A wrong current password is a 422 with a translated message, NOT a 401: a 401 # here would read as "your token expired" to every client interceptor and log # the user out of a session that is perfectly valid. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/password/check: post: tags: [Auth] summary: Check a candidate password's breach status description: Advisory only — never blocks anything itself. Reports whether a CANDIDATE password (not yet required to satisfy `PasswordNew`) matches a known-breached password, so a signup or password-change form can warn before submission. Unauthenticated, since signup needs it before an account exists. The four password-SET paths remain the actual gate, checked again server-side regardless of what this endpoint answered. operationId: checkPasswordBreached security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PasswordCheckRequest' responses: '200': description: The candidate's breach status content: application/json: schema: $ref: '#/components/schemas/PasswordCheck' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/reauth: get: tags: [Auth] summary: How this account can re-authenticate description: 'The ways THIS account can answer a `401 REAUTH_REQUIRED` challenge, in the order a client should offer them. An account with a password gets `password`; an account with none (it signed up through an OAuth provider) gets `email`, a code mailed to its verified address. Empty when the account has no password and this deployment cannot deliver mail, so a client shows a dead end instead of a form nobody can pass. The list is a server fact, not a client guess: the kernel that raises the challenge cannot see account data.' operationId: getReauthMethods x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] responses: '200': description: The applicable methods content: application/json: schema: $ref: '#/components/schemas/ReauthMethods' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } post: tags: [Auth] summary: Re-authenticate (step-up) description: Re-proves who the caller is to refresh how recently they authenticated, without ending the session — the answer to a `401 REAUTH_REQUIRED` challenge from a route gated by freshness (checkout, payments, deleting the account, changing the email, session management). The body is tagged by `method`, one of those `GET /account/reauth` lists, and may carry an `otp` code from an armed second factor. Re-mints the session and returns a fresh access token, same as `POST /account/password`. The new session carries ONLY what this call proved (`pwd` or `email`, plus `otp` when a code was given and verified). Proofs from the login are not carried over, so a password-only re-authentication no longer passes a route that demands `otp`. The refresh token the call was made with is retired. operationId: reauth x-error-codes: '401': [REAUTH_REQUIRED] '429': [TWO_FACTOR_RESEND_TOO_SOON] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ReauthRequest' responses: '200': description: Re-authenticated; a fresh access token for this session content: application/json: schema: $ref: '#/components/schemas/AuthTokens' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # A wrong password or code, or a method the account does not have, is a 422 with a # translated message, NOT a 401 — same reasoning as changePassword above: a 401 here # would read as "your session expired" to every client interceptor and log out a # session that is, in fact, still valid. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/reauth/methods/{method}/send: post: tags: [Auth] summary: Send a code to re-authenticate description: Mails the caller a one-time code for step-up, for an account that has no password to prove instead. Answers 422 for an account that has a password, or that has no verified address or no way to deliver mail, and 429 inside the per-code cooldown or once the account's hourly delivery budget is spent (shared with `POST /account/2fa/methods/{method}/send`, since both spend the same mailbox). Needs no fresh auth — it is what earns one. operationId: sendReauthCode x-error-codes: '429': [TWO_FACTOR_RESEND_TOO_SOON] security: - bearerAuth: [] parameters: - $ref: '#/components/parameters/ReauthMethodPathParam' responses: '200': description: A code is on its way content: application/json: schema: $ref: '#/components/schemas/TwoFactorDelivery' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/2fa: get: tags: [Auth] summary: Two-factor status description: 'What second factors this account has armed, and what it could still add. `available` crosses a deployment fact with an account fact — a method this deployment cannot reach at all (no SMTP configured) is absent entirely, while one the account is not yet eligible for (an unverified email address) is listed with `enrollable: false`.' operationId: getTwoFactorStatus security: - bearerAuth: [] responses: '200': description: The account's second factors, armed and available content: application/json: schema: $ref: '#/components/schemas/TwoFactorStatus' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/2fa/methods/{method}/setup: post: tags: [Auth] summary: Start enrolling one second factor description: Begins — or restarts — enrollment of one method. A device method answers with the secret to scan; a delivered method sends a code and answers with where it went. Nothing is armed until POST /account/2fa/methods/{method}/confirm proves the caller received it. Calling this again replaces whatever that method had pending, and disarms it if it was already confirmed. The FIRST factor an account arms needs only the fresh critical auth the route already demands. Once any factor is armed, every setup — a replace or a second method — also needs `code`, from an armed factor or an unused backup code, because a stolen-but-fresh session must not be able to swap the factor it would otherwise have to pass (OWASP MFA Cheat Sheet, "Changing MFA Factors"; NIST SP 800-63B). A caller whose only factor is delivered gets that code from POST /account/2fa/methods/{method}/send. operationId: setupTwoFactorMethod x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - $ref: '#/components/parameters/TwoFactorMethodPathParam' requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/TwoFactorSetupRequest' responses: '200': description: What the caller needs to finish enrolling this method content: application/json: schema: $ref: '#/components/schemas/TwoFactorSetup' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } # 422 rather than 403 for a method the account cannot enroll (an unverified email # address): the caller can fix it, and the message says how. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/2fa/methods/{method}/send: post: tags: [Auth] summary: Send a code to prove an armed factor description: Delivers a fresh code for one ARMED delivered method to a signed-in caller, so an account whose only factor is delivered (email) can satisfy the code that removing, replacing or disabling a factor asks for without spending a backup code. Answers 422 for a method that is not armed or does not deliver, and 429 inside the per-code cooldown or once the account's hourly delivery budget is spent. Needs fresh critical auth, like the calls it serves. operationId: sendTwoFactorMethodCode x-error-codes: '401': [REAUTH_REQUIRED] '429': [TWO_FACTOR_RESEND_TOO_SOON] security: - bearerAuth: [] parameters: - $ref: '#/components/parameters/TwoFactorMethodPathParam' responses: '200': description: A code is on its way content: application/json: schema: $ref: '#/components/schemas/TwoFactorDelivery' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/2fa/methods/{method}/confirm: post: tags: [Auth] summary: Arm one second factor description: Arms the method pending from its setup call, against a code the caller has demonstrably received. Backup codes are minted here — but only by the FIRST factor an account arms, since they recover the account, not the method. operationId: confirmTwoFactorMethod x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - $ref: '#/components/parameters/TwoFactorMethodPathParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TwoFactorConfirmRequest' responses: '200': description: The method is armed; backup codes if this was the first one content: application/json: schema: $ref: '#/components/schemas/TwoFactorConfirmed' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } /account/2fa/disable: post: tags: [Auth] summary: Disable two-factor authentication description: 'Drops EVERY enrolled method and every unused backup code. Requires a valid code from any enrolled method — or an unused backup code — in the body, on top of the route''s own fresh-auth requirement: disabling from a stolen-but-fresh session is otherwise the cheapest way around the whole feature. Removing one method and keeping the rest is POST /account/2fa/methods/{method}/remove.' operationId: disableTwoFactor x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TwoFactorCodeRequest' responses: '200': description: >- Two-factor authentication is off. The change revoked every session, this one included, and replaced it. A bearer client of a `cookie`-mode deployment has no cookie to refresh, so `sessionToken` carries its replacement `ses_…` id: the old one no longer works. content: application/json: schema: $ref: '#/components/schemas/AuthTokens' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } /account/2fa/methods/{method}/remove: post: tags: [Auth] summary: Remove one second factor description: Drops one method and leaves the others armed. Requires a valid code — from any enrolled method, or a backup code — for the same reason the full disable does. Removing the LAST armed method turns two-factor authentication off and discards the backup codes with it, exactly as POST /account/2fa/disable would. operationId: removeTwoFactorMethod x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - $ref: '#/components/parameters/TwoFactorMethodPathParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TwoFactorCodeRequest' responses: '200': description: >- The method is removed. The change revoked every session, this one included, and replaced it. A bearer client of a `cookie`-mode deployment gets its replacement `ses_…` id in `sessionToken`: the old one no longer works. content: application/json: schema: $ref: '#/components/schemas/AuthTokens' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } /account/2fa/backup-codes: post: tags: [Auth] summary: Regenerate backup codes description: Mints a fresh set of ten one-time backup codes and discards whatever was left of the old set — the answer to burning through them with no way back in short of admin-assisted recovery. Requires a valid code from any armed method, or an unused backup code, on top of the route's own fresh-auth requirement, same reasoning as disabling a factor. operationId: regenerateBackupCodes x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TwoFactorCodeRequest' responses: '200': description: The account's new backup codes, in the clear, shown exactly once content: application/json: schema: $ref: '#/components/schemas/TwoFactorBackupCodesRegenerated' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # No factor armed at all — there is nothing to regenerate a recovery list for. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } /account/logout: post: tags: [Auth] summary: Logout this session description: Logs out the CURRENT session only — deletes the session the `__Host-session` cookie (or, in `cookie` mode, a `ses_…` bearer) names, and clears the authentication cookies. Refused with 403 when the request names an `Origin` that is not an allowed frontend origin. Other devices stay signed in; `DELETE /account/sessions` is the one that revokes everything. Answers 204 whether or not a live session was found, because the caller's goal — not being logged in here — is met either way. operationId: logout security: [] responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '403': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Forbidden' } /account/sessions: get: tags: [Account] summary: List active sessions description: >- Lists the authenticated user's live sessions, one per sign-in, newest first. Each carries an id that stays the same for as long as the sign-in lasts (a `jwt` refresh or a `cookie` re-proof does not change it), when the sign-in happened, when it ends, and a `current` marker; never a credential. The session the caller's own cookie (or `ses_…` bearer) belongs to is flagged `current`. In `cookie` mode each also carries a coarse `device` label such as "Firefox on Linux", read from the User-Agent at the sign-in. A staff session that has idled out is not listed: it no longer signs anyone in. Unpaged: only live sign-ins are listed, and each ends when it expires. operationId: listSessions security: - bearerAuth: [] responses: '200': description: Active sessions content: application/json: schema: $ref: '#/components/schemas/SessionsResponse' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } delete: tags: [Auth] summary: Logout from all devices description: Logs out the authenticated user from ALL devices by deleting every session the account holds and clearing authentication cookies. Needs a fresh session (sensitive tier, `401 REAUTH_REQUIRED` when stale). operationId: logoutAll x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/sessions/current/touch: post: tags: [Account] summary: Count the caller's own session as active, and read its idle clock description: >- Marks the session as having seen a real request now, and answers its idle clock. A staff or admin session that sees none for `idleTimeoutSeconds` ends (`401 SESSION_IDLE`); a client shows a "still there?" prompt before then and calls this when the person answers. A shopper's session never idles out, so the field is absent. Every other request counts as activity too, except one sent with the `Session-Passive: true` header: a poll or a keep-alive that is not the person acting. operationId: touchSession x-error-codes: '401': [SESSION_IDLE] security: - bearerAuth: [] responses: '200': description: The session's idle clock content: application/json: schema: $ref: '#/components/schemas/SessionActivity' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/sessions/{sessionId}: get: tags: [Account] summary: Get one session description: >- One of the caller's own live sessions, by the id `GET /account/sessions` gave out. Scoped like the list: another account's session, a session that has ended, an invented id and a malformed one are the same 404. The `current` marker is judged against the credential this request carries. operationId: getSession security: - bearerAuth: [] parameters: - name: sessionId in: path required: true schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Id' description: Session identifier from `GET /account/sessions` responses: '200': description: The session content: application/json: schema: $ref: '#/components/schemas/Session' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } delete: tags: [Account] summary: Revoke one session description: >- Ends one sign-in by its session id — "log out that device". In `jwt` mode that is the whole family of refresh tokens the sign-in rotated through, so a revoke after a refresh still ends the device; in `cookie` mode it is the one session. Revoking the current session is allowed and equivalent to `POST /account/logout`, except that the cookies of OTHER clients cannot be cleared from here; their next request simply fails. Needs a fresh session (sensitive tier, `401 REAUTH_REQUIRED` when stale). operationId: revokeSession x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - name: sessionId in: path required: true schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Id' description: Session identifier from `GET /account/sessions` responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # Well-formed session id that matches none of the caller's live sessions. '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } /account/email-verification/resend: post: tags: [Auth] summary: Request email verification description: Sends a one-time verification token to the authenticated user's email address. The token must then be submitted to `/account/email-verification/confirm`. Signup already sends one automatically; this endpoint re-sends it for the mail that never arrived. Answers 429 inside the previous send's cooldown, so a client that respects `resendAfter` never sees one — unlike a login guess, a SUCCESSFUL call here is the expensive one, since each publishes mail. operationId: resendEmailVerification x-error-codes: '409': [EMAIL_ALREADY_VERIFIED] '429': [EMAIL_VERIFY_RESEND_TOO_SOON] security: - bearerAuth: [] responses: '200': description: A verification email is on its way content: application/json: schema: $ref: '#/components/schemas/EmailVerificationRequested' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # The account is already verified — there is nothing to send. '409': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Conflict' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/email-verification/confirm: post: tags: [Auth] summary: Confirm email verification description: Completes the email-verification flow. Validates the one-time token issued at signup or by `/account/email-verification/resend` and, if valid, marks the account's email address as verified. operationId: confirmEmailVerification security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/VerifyEmailConfirmRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/email-change/confirm: post: tags: [Auth] summary: Confirm a pending email change description: Completes the email-change flow started by `POST /account/email-change`. Validates the one-time `email-change` token sent to the NEW address and, if valid, swaps `pendingEmail` into `email`, marks the account verified, and revokes every refresh token — the same treatment `POST /account/password` gives a password change, since an email change is the stronger takeover primitive of the two. A `verify` token from the signup flow is refused here, and this token is refused by `/account/email-verification/confirm` — the two prove different things. operationId: confirmEmailChange security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/VerifyEmailConfirmRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } # 409: the new address was claimed by another account between the request and this # confirm. '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '409': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Conflict' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/email-change/undo: post: tags: [Auth] summary: Undo an email change description: Reverts an email change from the one-time link in the notice mailed to the OLD address when the change was requested. Valid for 7 days from that request, and untouched by a password change, so a person who reads mail weekly can still use it. While the change is only pending it is canceled; once the new address was confirmed the previous one is restored, and every session is ended (a refresh token cannot outlive the address it was issued under). Public, like `POST /account/email-change/confirm`, the token in the body is the credential. Answers 409 when the previous address was meanwhile claimed by another account. operationId: undoEmailChange security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/VerifyEmailConfirmRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '409': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Conflict' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/restore: post: tags: [Account] summary: Cancel a scheduled account deletion with the mailed link description: >- Spends the one-time restore token mailed by `DELETE /account` and brings the account back, provided its `purgeAt` has not passed. Public: the token is the credential. Restoring does NOT sign the person in: holding the mailbox is not a login, the same rule as a password reset. Unknown, expired and already-spent tokens answer alike (`422`). Answers 429 once an address (or its network block) has sent too many wrong tokens, like the other one-time-token confirms. operationId: restoreAccount x-no-refresh: true security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AccountRestoreRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/login/restore: post: tags: [Auth] summary: Restore an account in its deletion grace and sign in description: >- The last step of a sign-in by an account whose owner asked to delete it (`DELETE /account`) and whose `purgeAt` has not passed. Submits the `DeletionPending` claim check that `POST /account/login` (or `POST /account/login/2fa`) answered: it cancels the deletion, then starts the session exactly as `POST /account/login` does, `remember` and `transport` included. A client that does not want the account back simply never calls it, and the account is erased at `purgeAt`. Omit `challenge` for an OAuth-originated sign-in: that claim check never reached the client and is read from the httpOnly cookie the callback set. An unknown, expired or spent challenge answers 401. operationId: loginRestore x-no-refresh: true security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginRestoreRequest' responses: '200': description: The account is restored, and this is its new session content: application/json: schema: $ref: '#/components/schemas/AuthTokens' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/login: post: tags: [Auth] summary: Login description: >- Authenticates a user with email and password credentials. On success, the session is started in whichever mode the deployment runs (`session.mode` of `GET /config`): in `jwt` mode the body carries a short-lived access token (`token`) to pass as a Bearer token, and a refresh cookie is set; in `cookie` mode the session is an HttpOnly `__Host-session` cookie and the body carries no credential — unless the request asked for `transport: bearer`, which sets no session cookie (the `__Host-device` cookie is still set) and returns the `ses_…` id as `sessionToken` instead. When the account has two-factor authentication enabled the response is a short-lived challenge to submit to `POST /account/login/2fa` instead. When the account is inside the grace of its own deletion (`DELETE /account`) and has no second factor, the response is a `DeletionPending` claim check to submit to `POST /account/login/restore`: the account is not restored, and no session exists, until that call. operationId: login x-no-refresh: true security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginRequest' responses: '200': description: Auth tokens, a two-factor challenge, or the offer to restore an account in its deletion grace content: application/json: schema: $ref: '#/components/schemas/LoginOutcome' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # Once half the failure budget is spent a human-check token is required: 403. '403': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Forbidden' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/login/2fa: post: tags: [Auth] summary: Complete a two-factor login description: The second step of a login for an account with two-factor authentication enabled — submits the challenge from `POST /account/login` and a 6-digit code (or an unused backup code). On success, starts the session exactly as `POST /account/login` does for an account with no second factor, `transport` included. For an account inside the grace of its own deletion the second factor passing answers a `DeletionPending` claim check instead of a session, so two-factor is asked once and `POST /account/login/restore` finishes. operationId: loginTwoFactor x-no-refresh: true security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginTwoFactorRequest' responses: '200': description: Auth tokens, or the offer to restore an account in its deletion grace content: application/json: schema: $ref: '#/components/schemas/LoginTwoFactorOutcome' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # A wrong code is a 422, same reasoning as /account/reauth: a 401 here would read # as an expired challenge and send a caller back to /account/login for no reason. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` and `mfaChallengeLimiter` both sit in front of this route — # see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/login/2fa/send: post: tags: [Auth] summary: Send a login code description: Delivers a fresh code for one armed delivered method, against a live challenge. Public like the rest of the login flow — the challenge token is the credential. Answers 429 while the previous code is still inside its cooldown, so a client that respects `resendAfter` never sees one; the cooldown exists because this endpoint sends mail on an unauthenticated caller's say-so. operationId: sendTwoFactorCode x-error-codes: '429': [TWO_FACTOR_RESEND_TOO_SOON] x-no-refresh: true security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TwoFactorSendRequest' responses: '200': description: A code is on its way content: application/json: schema: $ref: '#/components/schemas/TwoFactorDelivery' # An expired or forged challenge is a 401. '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } # A method the account has not armed and a method that does not exist answer alike: # neither should tell a caller which one they hit. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/oauth/links: get: tags: [Auth] summary: List the caller's connected accounts description: 'The sign-in providers linked to the authenticated account (Google, GitHub), with when each was connected. Never carries a provider''s own identifier. An empty list means the account signs in with a password alone. Unpaged: at most one per provider.' operationId: listOAuthLinks security: - bearerAuth: [] responses: '200': description: The linked providers content: application/json: schema: $ref: '#/components/schemas/OAuthLinks' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } /account/oauth/links/{provider}: post: tags: [Auth] summary: Connect a sign-in provider to the signed-in account description: >- The only way to add a provider to an account that already exists: a sign-in with a provider whose email matches an account links nothing (`?error=account_exists` on the callback), because linking needs an authenticated session with the account (NIST SP 800-63C-4 §3.8.1). Needs a fresh session (`401 REAUTH_REQUIRED`). Sets the short-lived state, verifier and connect cookies and answers the provider's consent URL, which the client navigates the browser to; the callback then links the identity to THIS account and redirects to the frontend with `?linked=`. The owner is mailed that a sign-in method was added. `continue` and `locale` ride the same cookies as a login. Answers 404 for a provider this deployment never configured. A provider account that already belongs to another account is refused at the callback (`?error=already_linked`). operationId: startOAuthLink x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - name: provider in: path required: true schema: type: string maxLength: 32 description: One of the `oauthProviders` names `GET /config` lists. - name: continue in: query required: false schema: type: string maxLength: 512 description: A same-origin relative path to come back to; anything else is dropped. - name: locale in: query required: false schema: type: string maxLength: 16 description: The language tag the browser comes back in. responses: '200': description: Where to send the browser content: application/json: schema: $ref: '#/components/schemas/OAuthLinkStart' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } delete: tags: [Auth] summary: Disconnect a linked sign-in provider description: >- Removes the link between the account and `provider`, so that provider can no longer sign in to it, and mails the owner that a sign-in method was removed. Nothing re-links it by email match, so reconnecting is `POST /account/oauth/links/{provider}` from a signed-in session. Needs a fresh session (`401 REAUTH_REQUIRED`). There is no guard on removing the last sign-in method, on purpose (forgot-password recovers an account that was left with none). Answers 404 when `provider` is not linked. A link is a line of the caller's links list, so the answer is that list as it now stands (200 + the links left). operationId: unlinkOAuthProvider x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] parameters: - name: provider in: path required: true schema: type: string maxLength: 32 description: One of the `provider` names `GET /account/oauth/links` lists. responses: '200': description: The links the account still has content: application/json: schema: $ref: '#/components/schemas/OAuthLinks' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } /account/oauth/{provider}: get: tags: [Auth] summary: Start an OAuth login description: 'Browser-navigated only: redirects to `provider`''s consent screen, having minted the CSRF `state` as a cookie. Not called programmatically — the frontend points a plain `` at this URL.' operationId: startOAuthLogin security: [] parameters: - name: provider in: path required: true schema: type: string maxLength: 32 description: One of the `oauthProviders` names `GET /config` lists. - name: continue in: query required: false description: Same-origin relative path to send the browser back to once the login completes — the OAuth equivalent of the password-login flow's own `?continue=`. Saved as a cookie for the round trip to the provider and back; anything that is not a same-origin relative path (an absolute URL, a protocol-relative `//host/path`) is dropped silently rather than refused, since a browser navigation has nowhere to show a validation error. schema: { type: string, maxLength: 512 } - name: locale in: query required: false description: The language tag (`it`, `pt-BR`) of the page the visitor started from. Saved as a cookie for the round trip and echoed back as `?locale=` on the frontend redirect, so a visitor with no `continue` target and no saved language preference lands in the language they were reading. Anything not shaped like a tag is dropped silently, like `continue`. schema: { type: string, maxLength: 35 } responses: '302': description: Redirect to the provider's consent screen headers: Location: schema: { type: string } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } # `credentialLimiters` sits in front of this route — see routes.ts. Answered as the # problem-details body, not a redirect, same as every other limited route. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/oauth/{provider}/callback: get: tags: [Auth] summary: Complete an OAuth login description: 'Browser-navigated only: where `provider` sends the browser back after consent. Validates `state`, exchanges the code, finds-or-creates the account, and redirects to the frontend with the session cookies set — or with `?error=` on failure. When the account has two-factor authentication armed, no session is minted: the redirect instead carries `?mfaRequired=1&expiresAt=...&methods=...&defaultMethod=...` (the same fields MfaChallenge carries, minus the token itself), and the challenge token travels in a short-lived httpOnly cookie that POST /account/login/2fa and .../2fa/send read when their body omits `challenge`. When the account is inside the grace of its own deletion and has no second factor, no session is minted either: the redirect carries `?deletionPending=1&purgeAt=...&expiresAt=...` and the claim check travels in a short-lived httpOnly cookie that `POST /account/login/restore` reads when its body omits `challenge`. Either success redirect also carries `?continue=` when `GET /account/oauth/{provider}` saved one and it is still a valid same-origin path; every redirect, a failure''s included, carries `?locale=` likewise. A provider whose verified email matches an existing account links nothing and signs nobody in: the redirect carries `?error=account_exists`, and the owner connects the provider from a signed-in session (`POST /account/oauth/links/{provider}`). When that existing account never proved its own address, the redirect carries `?error=account_unverified` instead: the owner resets the password, which proves the mailbox, and signs in the way the account allows. That signed-in connect round trip comes back to this same callback, mints no session and redirects with `?linked=`, or `?error=already_linked` (the provider account belongs to another account) or `?error=link_expired` (the minutes the attempt lives ran out).' operationId: completeOAuthLogin security: [] parameters: - name: provider in: path required: true schema: type: string maxLength: 32 - name: code in: query required: false schema: { type: string, maxLength: 2048 } - name: state in: query required: false schema: { type: string, maxLength: 512 } - name: error in: query required: false description: Set by the provider instead of `code` when the user declines consent. schema: { type: string, maxLength: 256 } responses: '302': description: Redirect to the frontend, session cookies set on success # The failure codes the redirect's `?error=` query carries (absent on success). Inline, # not a component: the bundler inlines a `$ref` under an `x-` key and prunes the # component, so a shared schema would never reach the generated types. Both # repos' generated `REDIRECT_QUERY_ENUMS` (`api.generated/redirect-query.ts` here) read this # list. x-redirect-query: error: type: string enum: - access_denied - provider_error - already_linked - link_expired - email_unverified - account_exists - account_unverified description: >- `access_denied`: the user declined consent. `provider_error`: the provider failed or answered something unusable. `already_linked`: that provider account belongs to another account. `link_expired`: the minutes a connect attempt lives ran out. `email_unverified`: the provider does not vouch for the address. `account_exists`: a verified-email match, so nothing was linked. `account_unverified`: the matching account never proved its address. headers: Location: schema: { type: string } '400': description: Missing or mismatched CSRF state headers: Cache-Control: $ref: '../../../shared/contracts/openapi.root.yaml#/components/headers/CacheControlNoStore' content: application/problem+json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Problem' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } # `credentialLimiters` sits in front of this route — see routes.ts. Answered as the # problem-details body, not a redirect, same as every other limited route. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/signup: post: tags: [Auth] summary: Signup description: 'Registers a new user account. Takes no image — a stranger writes nothing to the store before registering; the signed-in caller sets an avatar with `PATCH /account`. Returns the newly created user profile on success, and signs the caller in — the refresh cookie is set here, so a client reaches a usable access token through `POST /account/refresh` rather than by calling `POST /account/login` again. The new account is an `unverified` audience until `POST /account/email-verification/confirm` proves the address — it browses freely and is stopped only at `checkout:Cart`. Signup takes no `transport`: a bearer client signs in with `POST /account/login` afterwards.' operationId: signup x-error-codes: '403': [ANTIBOT_VERIFICATION_FAILED] # The email is already registered. '409': [IDEMPOTENCY_IN_FLIGHT, EMAIL_ALREADY_USED] '422': [IDEMPOTENCY_KEY_MISMATCH] x-no-refresh: true security: [] parameters: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/parameters/AntibotChallengeTokenHeader' - $ref: '../../../shared/contracts/openapi.root.yaml#/components/parameters/IdempotencyKeyHeader' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SignupRequest' responses: '201': description: Created headers: Location: { $ref: '../../../shared/contracts/openapi.root.yaml#/components/headers/Location' } content: application/json: schema: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Account' # The BODY is identical when rung 2 of the anti-automation ladder refuses the # address: a fabricated profile from a document that was never saved, so a script # gets nothing to iterate on. Only the refresh cookie tells the two apart, since # a refusal has no account to mint a session for. # Also answered when a human-challenge provider is active and the caller's # token is missing or refused — a 403, see antibot/openapi.yaml. '403': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Forbidden' } '409': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Conflict' } # Also answered when `Idempotency-Key` was already used with a different body. '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `signupLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/password/reset: post: tags: [Auth] summary: Request password reset operationId: requestPasswordReset x-no-refresh: true description: Initiates the password-reset flow by sending a one-time reset token to the provided email address. The token should then be submitted to `/account/password/reset/confirm`. security: [] parameters: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/parameters/AntibotChallengeTokenHeader' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PasswordResetRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } # A human-challenge provider is active and the caller's token is missing or refused. '403': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Forbidden' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `resetRequestLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/password/reset/confirm: post: tags: [Auth] summary: Confirm password reset operationId: confirmPasswordReset x-no-refresh: true description: Completes the password-reset flow. Validates the one-time reset token issued by `/account/password/reset` and, if valid, updates the user's password to the supplied value. security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PasswordResetConfirmRequest' responses: '204': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NoContent' } '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '422': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/ValidationError' } # `credentialLimiters` sits in front of this route — see routes.ts. '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } /account/refresh: post: tags: [Auth] summary: Refresh access token description: >- `jwt` mode only — answers 404 in `cookie` mode, whose one session id never rotates. Creates a new short-lived access token from the refresh token in the `__Host-session` cookie, and rotates that token. A POST because it changes state, and refused with 403 when the request names an `Origin` that is not an allowed frontend origin — the cookie alone authenticates it. The cookie is `HttpOnly`, `Secure` in every environment and host-locked (no `Domain`, `Path=/`), so the token is never readable by page scripts, never appears in a URL, a proxy log or a `Referer` header, and a sibling subdomain cannot overwrite it. A refresh is passive: it never counts as activity. A staff family idle past `NODE_SESSION_IDLE_TIME_STAFF` answers 401 `SESSION_IDLE` and the family is removed, so the next call starts at the sign-in screen. A staff family signed in longer ago than `NODE_SESSION_LIFETIME_STAFF` answers an ordinary 401 and is removed the same way. operationId: refreshToken x-error-codes: '401': [SESSION_IDLE] security: [] responses: '200': description: New access token content: application/json: schema: $ref: '#/components/schemas/RefreshTokenResponse' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '403': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Forbidden' } # `cookie` mode: there is no refresh token to rotate. '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } /account/export: post: tags: [Auth] summary: Request an export of the caller's own data description: >- Starts "give me my data" (Art. 15, 20) and answers at once with `202`, the export's status (`AccountExport`) and `Location: /account/export`, the status monitor to poll (RFC 9110 §15.3.3). The file is built in the background from every collection that holds something of the caller's — profile, address book, orders, payments, shipments, cart, wishlist, live sessions (metadata only, never a token value), and their own audit trail — and a LINK to it is mailed to the account's address when it is ready, never the data itself. Check on it with `GET /account/export`, fetch it with `GET /account/export/file`. One live export per account. Asking while one is `building` returns that one; asking after one is `ready` or `failed` replaces it (the old file and record are deleted first). A file is kept for `NODE_ACCOUNT_EXPORT_TTL_DAYS` days. Requires a FRESH session (`requireFreshAuth`) rather than a request body — a personal-data dump is worth re-proving identity for, and this repository already has the mechanism. Starting a NEW build costs one mail from the per-mailbox mail budget, since it ends in a mailed link: a spent budget answers `429`, and the previous export is left in place. Asking while one is `building` is not charged. Needs a fresh session (sensitive tier: `401 REAUTH_REQUIRED`), as does downloading the file; reading the status does not. operationId: requestAccountExport x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] responses: '202': description: The export is queued (or is the one already building) headers: Location: { $ref: '../../../shared/contracts/openapi.root.yaml#/components/headers/Location' } content: application/json: schema: $ref: '#/components/schemas/AccountExport' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '429': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/TooManyRequests' } get: tags: [Auth] summary: Check on the caller's own data export description: >- The status of the caller's export: `building`, `ready` or `failed`, with `createdAt`, and `expiresAt` once it is `ready`. Reading it is not a download, so it needs a session but not a fresh one: it carries dates and a state, no personal data. An account has one export, so there is no id to name. `404` only when there is none: never asked for, already deleted, or past its retention and not yet swept (that last one counts as none). A `building` export older than the build limit reads as `failed`. The file itself is at `GET /account/export/file`. operationId: getAccountExport security: - bearerAuth: [] responses: '200': description: The caller's export, and where it stands content: application/json: schema: $ref: '#/components/schemas/AccountExport' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } /account/export/file: get: tags: [Auth] summary: Download an export of the caller's own data description: >- Streams the finished export — the JSON document `AccountExportResponse` describes — as an attachment. This is the page the mailed link opens. An account has one export, so there is no id to name: the caller's own is the one served. A FRESH session (`requireFreshAuth`), same as the request. `404` unless the export is `ready` and within its retention. A `ready` export whose file is missing from the store answers `404` too: the file honestly does not exist. x-cache: no-store operationId: downloadAccountExport x-error-codes: '401': [REAUTH_REQUIRED] security: - bearerAuth: [] responses: '200': description: The caller's own data headers: Content-Disposition: description: '`attachment; filename=account-export-.json` (the name is a plain token, so it is not quoted), e.g. `account-export-2026-10-27.json`; the date is the UTC day the export was requested.' schema: { type: string } content: # Kept as the document's own schema, not `format: binary`: every module's # export section reaches the bundle only through this reference. A browser # client asks for it as a blob and saves it under the `Content-Disposition` name. application/json: schema: $ref: '#/components/schemas/AccountExportResponse' '401': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/Unauthorized' } '404': { $ref: '../../../shared/contracts/openapi.root.yaml#/components/responses/NotFound' } components: schemas: # ---------- account — the schemas only this module's paths reference. ---------- # `AccountExportResponse` is the export file's document. Only the account's own half is written here: every other # module declares its section as `x-personal-data` in its own contract, and the bundler # adds it (`scripts/contracts/personal-data-assembly.ts`). A removed module takes its # section with it. AccountExportResponse: type: object additionalProperties: false required: [exportedAt, profile] properties: exportedAt: type: string format: date-time profile: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Account' AccountExport: type: object additionalProperties: false required: [id, status, createdAt, actions] description: >- The caller's data export and where it stands. `POST /account/export` answers it (always `building`) and `GET /account/export` reads it. properties: id: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Id' status: type: string enum: [building, ready, failed] description: >- `building` until the background job settles, then `ready` or `failed`. A `building` export older than the build limit reads as `failed`. Asking again after `ready` or `failed` replaces the export with a new `building` one. createdAt: type: string format: date-time expiresAt: type: string format: date-time description: >- When the file is deleted: the retention (`NODE_ACCOUNT_EXPORT_TTL_DAYS`) counted from the moment the build finished. Present only when `status` is `ready`. actions: type: object additionalProperties: false required: [download, request] description: What the caller may do with the export right now. properties: download: type: boolean description: '`GET /account/export/file` will answer the file: the export is `ready`.' request: type: boolean description: >- `POST /account/export` would start a new build. `false` while one is `building`: asking then only returns that one. OAuthLink: type: object additionalProperties: false required: [provider, connectedAt] properties: provider: type: string description: Registry name of the linked provider, e.g. `google`. connectedAt: type: string format: date-time description: When the account was linked to this provider. OAuthLinks: type: object additionalProperties: false required: [links] properties: links: type: array items: $ref: '#/components/schemas/OAuthLink' OAuthLinkStart: type: object additionalProperties: false required: [authorizeUrl] properties: authorizeUrl: type: string format: uri maxLength: 2048 description: The provider's consent screen, with the state and PKCE challenge of this attempt. Navigate the browser to it. # The 200 of every change that replaces the caller's own session: the password change and # the two factor removals. The body is `{}` when there is nothing new to hand back (a # browser's cookie was refreshed in place) and on the rare degraded success where the # re-mint itself failed — the write and the session revoke already committed by then, so # a 500 would misreport a change that DID succeed. Every field is optional for that reason. AuthTokens: type: object additionalProperties: false properties: token: type: string description: >- The access JWT — `jwt` mode only. Absent in `cookie` mode, where a browser holds no credential it can read. sessionToken: type: string description: >- The `ses_…` session id, to send back as `Authorization: Bearer ses_…`. Present only for a `cookie`-mode login that asked for `transport: bearer` (or a re-proof by such a client); that login sets no session cookie (the `__Host-device` cookie is still set). account: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/AccountView' description: >- The signed-in account, with its abilities and idle clock — exactly what `GET /account` answers, so a sign-in needs no follow-up read. Present on the answers that START a session (login, its second step, restore); absent on a re-mint after a password or factor change. RefreshTokenResponse: type: object additionalProperties: false required: [token, abilities] properties: token: type: string description: New access JWT abilities: $ref: '../access/openapi.yaml#/components/schemas/Abilities' description: >- The caller's abilities as they stand now, so a role granted mid-session shows within one refresh. MfaChallenge: type: object additionalProperties: false required: [mfaRequired, challenge, expiresAt, methods] properties: mfaRequired: type: boolean enum: [true] description: Always true — the credential check passed, but a second factor is required before a session is issued. challenge: type: string description: A claim check for this half-finished login, not a code — nothing is sent to the user to obtain it. Submit it, with a code, to POST /account/login/2fa, or to POST /account/login/2fa/send to have a code delivered first. expiresAt: type: string format: date-time description: When the challenge stops being accepted. Longer for an account with a delivered method armed, since the code has to survive an email round-trip. methods: type: array items: $ref: '#/components/schemas/TwoFactorMethodSummary' description: The factors armed on this account, in the order a client should offer them. defaultMethod: type: string description: Which of `methods` to offer first — the cheapest one for the user, which is a device method when there is one. DeletionPending: type: object additionalProperties: false required: [deletionPending, challenge, expiresAt, purgeAt] properties: deletionPending: type: boolean enum: [true] description: Always true. The credentials checked out, but the account is inside the grace of its own deletion, so no session is issued until the owner chooses to restore it. challenge: type: string description: A claim check recording how the sign-in was proven (password, and the second factor when armed). Submit it to `POST /account/login/restore`. expiresAt: type: string format: date-time description: When the challenge stops being accepted. Signing in again earns a new one. purgeAt: type: string format: date-time description: When the account is erased unless restored before. LoginOutcome: oneOf: - $ref: '#/components/schemas/AuthTokens' - $ref: '#/components/schemas/MfaChallenge' - $ref: '#/components/schemas/DeletionPending' description: A full session (AuthTokens), a step-up challenge (MfaChallenge) when the account has two-factor authentication enabled, or the offer to restore an account inside the grace of its own deletion (DeletionPending). LoginTwoFactorOutcome: oneOf: - $ref: '#/components/schemas/AuthTokens' - $ref: '#/components/schemas/DeletionPending' description: A full session (AuthTokens), or the offer to restore an account inside the grace of its own deletion (DeletionPending) once its second factor passed. LoginRestoreRequest: type: object additionalProperties: false properties: challenge: type: string maxLength: 128 minLength: 1 description: The `DeletionPending` challenge. Omit it for an OAuth-originated sign-in — that challenge was never sent to the client, and this endpoint reads it from the httpOnly cookie the callback set instead. remember: $ref: '#/components/schemas/RememberTier' transport: $ref: '#/components/schemas/SessionTransport' LoginTwoFactorRequest: type: object additionalProperties: false required: [code] properties: challenge: type: string maxLength: 128 minLength: 1 description: The challenge token from POST /account/login. Omit it for an OAuth-originated login — that challenge was never sent to the client, and this endpoint reads it from the httpOnly cookie the callback set instead. code: type: string maxLength: 64 minLength: 1 description: A code from any armed method, or an unused backup code. Which method it came from is the server's problem, not the client's. remember: $ref: '#/components/schemas/RememberTier' transport: $ref: '#/components/schemas/SessionTransport' TwoFactorSendRequest: type: object additionalProperties: false required: [method] properties: challenge: type: string maxLength: 128 minLength: 1 description: The challenge token from POST /account/login. Omit it for an OAuth-originated login — see LoginTwoFactorRequest.challenge. method: type: string maxLength: 32 description: Which armed delivered method to send through — a `method` from the challenge's own `methods` list whose `delivers` is true. TwoFactorMethodSummary: type: object additionalProperties: false required: [method, delivers] properties: method: type: string description: 'Wire name of the factor — `totp`, `email`. A string rather than an enum on purpose: a deployment that gains a channel must not need a new contract to name it.' delivers: type: boolean description: Whether the server sends the code (email, SMS) or the caller reads it off their own device (TOTP). A client renders a "send me a code" button for the former and nothing for the latter. target: type: string description: Where a delivered code goes, MASKED by the server — never a full address, so no client has to decide how to redact one. Absent for device methods. enrolledAt: type: string format: date-time description: When this factor was armed. Absent while its enrollment is still pending confirmation. resendAfter: type: integer minimum: 0 description: Seconds between two deliveries of this method. Absent for device methods. enrollable: type: boolean description: Whether this account may add this method right now. Only meaningful in `TwoFactorStatus.available`; `false` comes with `reason`. reason: type: string description: Why `enrollable` is false — a translated sentence a client can show as-is. TwoFactorStatus: type: object additionalProperties: false required: [enabled, methods, available, backupCodesRemaining] properties: enabled: type: boolean description: Whether a login on this account is challenged for a second factor. True exactly when `methods` holds at least one armed entry. methods: type: array items: $ref: '#/components/schemas/TwoFactorMethodSummary' description: The factors armed on this account, plus any enrollment still pending confirmation. available: type: array items: $ref: '#/components/schemas/TwoFactorMethodSummary' description: 'What this account could still add. A method this deployment cannot reach at all is absent; one the account is not yet eligible for is present with `enrollable: false` and a `reason`.' backupCodesRemaining: type: integer minimum: 0 description: How many unused backup codes are left. Zero with `enabled` true is the state worth warning about — a lost device then means admin-assisted recovery. TwoFactorSetup: type: object additionalProperties: false required: [method, delivers] properties: method: type: string description: The method being enrolled, echoed back. delivers: type: boolean description: Which half of this object to read. True — a code was just sent, see `sentTo`. False — enroll from `secret`/`otpauthUri`. secret: type: string description: A device method's secret, base32-encoded, shown once for manual entry as a fallback to scanning. Absent when `delivers`. otpauthUri: type: string description: An otpauth:// URI the client renders as a QR code — this API generates no image, so the secret crosses the wire once rather than twice. Absent when `delivers`. sentTo: type: string description: Masked destination the enrollment code just went to. Absent unless `delivers`. resendAfter: type: integer minimum: 0 description: Seconds before another code may be requested. Absent unless `delivers`. expiresAt: type: string format: date-time description: When the delivered code stops being accepted. Absent unless `delivers`. TwoFactorDelivery: type: object additionalProperties: false required: [method, sentTo, resendAfter, expiresAt] properties: method: type: string description: The method the code went through, echoed back. sentTo: type: string description: Masked destination — enough for the user to recognise the mailbox, not enough to learn a new address from. resendAfter: type: integer minimum: 0 description: Seconds before another code may be requested. A client counts down from this rather than inventing its own cooldown, so it never disagrees with the rate limiter. expiresAt: type: string format: date-time description: When this code stops being accepted. EmailVerificationRequested: type: object additionalProperties: false required: [resendAfter] properties: resendAfter: type: integer minimum: 0 description: Seconds before another verification email may be requested. A client counts down from this rather than inventing its own cooldown, so it never disagrees with the server. TwoFactorSetupRequest: type: object additionalProperties: false properties: code: type: string maxLength: 64 minLength: 1 description: A code from any armed method, or an unused backup code. Required once any factor is armed — a replace, or adding a second method — and ignored for the account's first factor. TwoFactorConfirmRequest: type: object additionalProperties: false required: [code] properties: code: type: string maxLength: 64 minLength: 1 description: 'The code for the method being armed — read off the device, or received through its channel. A backup code is NOT accepted here: the point of this call is to prove the new factor works.' TwoFactorCodeRequest: type: object additionalProperties: false required: [code] properties: code: type: string maxLength: 64 minLength: 1 description: A code from any armed method, or an unused backup code. Used to prove the factor being removed — or the account it protects — really belongs to the caller. TwoFactorConfirmed: type: object additionalProperties: false required: [method, backupCodesRemaining] properties: method: type: string description: The method just armed, echoed back. backupCodes: type: array items: type: string description: One-time recovery codes, in the clear, shown exactly once and never retrievable again. Present ONLY when this was the first factor the account armed — they recover the account, not the method, so a second factor mints none. backupCodesRemaining: type: integer minimum: 0 description: How many unused backup codes the account now holds. sessionToken: type: string description: >- The replacement `ses_…` id, for a bearer client of a `cookie`-mode deployment: arming a factor revoked every session, this one included, and the old id no longer works. Absent otherwise (a browser's cookie was refreshed in place). TwoFactorBackupCodesRegenerated: type: object additionalProperties: false required: [backupCodes, backupCodesRemaining] properties: backupCodes: type: array items: type: string description: The account's new one-time recovery codes, in the clear, shown exactly once — the old set no longer verifies. backupCodesRemaining: type: integer minimum: 0 description: How many unused backup codes the account now holds — `BACKUP_CODE_COUNT`, fresh off a regenerate. LoginRequest: type: object additionalProperties: false required: [email, password] properties: email: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Email' password: $ref: '#/components/schemas/Password' remember: $ref: '#/components/schemas/RememberTier' transport: $ref: '#/components/schemas/SessionTransport' SessionActivity: type: object additionalProperties: false required: [lastActiveAt] properties: lastActiveAt: type: string format: date-time description: When the session last saw a real request — now, for a touch. idleTimeoutSeconds: type: integer minimum: 1 description: >- How long the session may then sit unused before it ends. Absent when no idle timeout applies to this account (a shopper, or the timeout is switched off). idleRemainingSeconds: type: integer minimum: 0 description: >- How many seconds of idle time are left, counted by the server from the stamp it judges the session by (OAuth's `expires_in` idea), so a client with a wrong clock still warns on time. Absent whenever `idleTimeoutSeconds` is. lifetimeRemainingSeconds: type: integer minimum: 0 description: >- How many seconds are left before the staff lifetime cap ends the session, which activity cannot extend. Absent for a shopper, and when the cap is switched off. Operator: type: object additionalProperties: false required: [legalName, street, city, zip, country, email] description: >- Who runs the site: the provider identity a visitor is entitled to before any sale or signup (e-Commerce Directive Art. 5(1), GDPR Art. 13(1)(a)). Set once by the deployment in `NODE_LEGAL_*`; the footer, the Terms, the Legal notice and the Privacy page print it. properties: legalName: type: string description: The operator's name, as registered (`NODE_LEGAL_NAME`). vatNumber: type: string description: VAT identification number (`NODE_LEGAL_VAT_NUMBER`); absent below the registration threshold. tradeRegister: type: string description: The commercial register the operator is entered in (`NODE_LEGAL_TRADE_REGISTER`); absent for an operator in none. registrationNumber: type: string description: The operator's number in that register (`NODE_LEGAL_REGISTRATION_NUMBER`); absent when there is no register. street: type: string description: Street and number of the postal address (`NODE_LEGAL_STREET`). city: type: string description: City of the postal address (`NODE_LEGAL_CITY`). zip: type: string description: Postal code of the postal address (`NODE_LEGAL_ZIP`). country: allOf: [{ $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/CountryCode' }] description: Country of the postal address, ISO-3166 alpha-2 (`NODE_LEGAL_COUNTRY`). Also the shop's VAT jurisdiction. email: allOf: [{ $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Email' }] description: Where a visitor writes to (`NODE_LEGAL_EMAIL`, or the support address when unset). phone: type: string description: Telephone number (`NODE_LEGAL_PHONE`); absent when none is set. A deployment with the shop always sets it. SessionConfig: type: object additionalProperties: false required: [mode, lifetimeSeconds] properties: mode: type: string enum: [jwt, cookie] description: The deployment's `NODE_SESSION_MODE`. lifetimeSeconds: type: object additionalProperties: false required: [short, medium, long] description: >- How long a session lasts per "remember me" tier, in seconds (`NODE_SESSION_TIME_*`). `short` is what an unticked box gets; `long` is what the box offers today. A client prints these instead of a number of its own. properties: short: { type: integer, minimum: 1 } medium: { type: integer, minimum: 1 } long: { type: integer, minimum: 1 } staffLifetimeSeconds: type: integer minimum: 1 description: >- The longest a staff or admin session lives from sign-in, whatever the tier (`NODE_SESSION_LIFETIME_STAFF`). Absent when the cap is off. SessionTransport: type: string enum: [cookie, bearer] description: >- How a `cookie`-mode login hands its credential back. `cookie` (the default): the HttpOnly `__Host-session` cookie, nothing in the body — what a browser wants. `bearer`: no session cookie is set (the `__Host-device` cookie still is, as on any login) and the body returns the `ses_…` id as `sessionToken`, for a client with no cookie jar (a script, a mobile app). Ignored in `jwt` mode, which always sets its refresh cookie and returns an access token. RememberTier: type: string enum: [short, medium, long] description: >- The "remember me" choice, sized by the deployment (`short`, `medium`, `long`). Ticked: the refresh cookie persists for that tier. Omitted: a browser-session cookie (gone when the browser closes) whose token still lives for the `short` tier server-side. Refresh rotation, reauth and a password change keep the choice. SignupRequest: type: object additionalProperties: false required: [email, username, password, passwordConfirm, termsAccepted] properties: email: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Email' username: type: string minLength: 3 maxLength: 50 password: $ref: '#/components/schemas/PasswordNew' passwordConfirm: $ref: '#/components/schemas/Password' # Must be `true` — the checkbox gating the Terms of Service / Privacy Policy. # Server-enforced (see `accountService.signup`), not just a client-side gate. termsAccepted: type: boolean enum: [true] # Optional, opt-in, unticked by default. Absent: nobody was asked. Nothing is # recorded, and the banner choice applies until the account answers # (`docs/understand/analytics.md#consent`). An unticked box shown to the user is sent # as `false`, a recorded answer. analyticsConsent: type: boolean PasswordResetRequest: type: object additionalProperties: false required: [email] properties: email: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Email' PasswordResetConfirmRequest: type: object additionalProperties: false required: [token, password, passwordConfirm] properties: token: type: string maxLength: 128 minLength: 1 description: One-time password reset token (NOT a JWT). password: $ref: '#/components/schemas/PasswordNew' passwordConfirm: $ref: '#/components/schemas/Password' # The holder's own tick of the Terms. Needed only when the account holds no Terms # record (staff created it): without it the answer is a 422 naming this field, and # the link is not spent. Ignored when the account already has a record. termsAccepted: type: boolean enum: [true] description: >- Required when the account holds no Terms record, as an account an administrator created does not. Ignored otherwise. AccountRestoreRequest: type: object additionalProperties: false required: [token] properties: token: type: string maxLength: 128 minLength: 1 description: One-time account restore token (NOT a JWT). AccountDeletion: type: object additionalProperties: false required: [requestedAt, purgeAt] properties: requestedAt: type: string format: date-time description: When the deletion was asked for, and the account locked. purgeAt: type: string format: date-time description: >- When the account is erased unless restored before. At most one calendar month after `requestedAt`, at 00:00 UTC at the latest. # Self-service profile update. Deliberately narrower than `UpdateUserRequest`: no # `admin`, no `active`, no `password` — role and account state are the admin # endpoints' to change, and the password has its own flow (`POST /account/password`) # because it must prove knowledge of the current one. # PATCH /account — RFC 7396: every field optional, omitted means unchanged. UpdateAccountRequest: type: object additionalProperties: false properties: username: type: string minLength: 3 maxLength: 50 # `null` clears the override, falling back to the deployment default/negotiated locale. locale: oneOf: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Locale' - type: 'null' # `null` removes the image. Omitted leaves it unchanged; `''` is # invalid (`ImageUrl`'s own `minLength: 1`), never a third spelling of "no image". imageUrl: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/ImageRemoval' phone: type: [string, 'null'] maxLength: 32 minLength: 1 website: type: [string, 'null'] maxLength: 2048 minLength: 1 # Absent means "leave it alone" like every other field here — a client withdraws # consent by sending `false` explicitly, never by omission. analyticsConsent: type: boolean # A multipart part is a string or a file, never `null`: a clear cannot travel here. Send it as a JSON PATCH. UpdateAccountRequestMultipart: type: object additionalProperties: false properties: username: type: string minLength: 3 maxLength: 50 locale: type: string allOf: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Locale' imageUpload: type: string format: binary description: Optional user profile image phone: type: string maxLength: 32 minLength: 1 website: type: string maxLength: 2048 minLength: 1 analyticsConsent: type: boolean # PUT /account — RFC 9110 §9.3.4: the body IS the new resource, so every writable field # this resource has must be nameable and the identity fields are genuinely required. ReplaceAccountRequest: type: object additionalProperties: false required: [username, analyticsConsent] properties: username: type: string minLength: 3 maxLength: 50 locale: oneOf: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Locale' - type: 'null' imageUrl: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/ImageRemoval' phone: type: [string, 'null'] maxLength: 32 minLength: 1 website: type: [string, 'null'] maxLength: 2048 minLength: 1 analyticsConsent: type: boolean # A multipart part is a string or a file, never `null`: a clear cannot travel here. Send it as a JSON PATCH. ReplaceAccountRequestMultipart: type: object additionalProperties: false required: [username, analyticsConsent] properties: username: type: string minLength: 3 maxLength: 50 locale: type: string allOf: - $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Locale' imageUpload: type: string format: binary description: Optional user profile image phone: type: string maxLength: 32 minLength: 1 website: type: string maxLength: 2048 minLength: 1 analyticsConsent: type: boolean # POST /account/email-change — the one field the change needs. RequestEmailChangeRequest: type: object additionalProperties: false required: [email] properties: email: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Email' ChangePasswordRequest: type: object additionalProperties: false required: [currentPassword, password, passwordConfirm] properties: currentPassword: $ref: '#/components/schemas/Password' password: $ref: '#/components/schemas/PasswordNew' passwordConfirm: $ref: '#/components/schemas/Password' ReauthMethod: type: string enum: [password, email] description: 'One way to re-authenticate. `password` proves the account password; `email` proves control of the account''s verified address with a mailed code.' ReauthPasswordRequest: type: object additionalProperties: false required: [method, password] properties: method: type: string enum: [password] password: $ref: '#/components/schemas/Password' otp: type: string maxLength: 64 minLength: 1 description: A code from an armed second factor, or an unused backup code. Required to pass an identity route (changing the email or password, deleting the account) when the account has 2FA armed; the `401 REAUTH_REQUIRED` that asks for it carries `details.methods` of `[otp]`. Answers 422 when the account has no second factor armed. ReauthEmailRequest: type: object additionalProperties: false required: [method, code] properties: method: type: string enum: [email] code: type: string maxLength: 64 minLength: 1 description: The code from `POST /account/reauth/methods/email/send`. otp: type: string maxLength: 64 minLength: 1 description: A code from an armed second factor, or an unused backup code. Required to pass an identity route (changing the email or password, deleting the account) when the account has 2FA armed; the `401 REAUTH_REQUIRED` that asks for it carries `details.methods` of `[otp]`. Answers 422 when the account has no second factor armed. ReauthRequest: oneOf: - $ref: '#/components/schemas/ReauthPasswordRequest' - $ref: '#/components/schemas/ReauthEmailRequest' discriminator: propertyName: method mapping: password: '#/components/schemas/ReauthPasswordRequest' email: '#/components/schemas/ReauthEmailRequest' ReauthMethods: type: object additionalProperties: false required: [methods] properties: methods: type: array items: $ref: '#/components/schemas/ReauthMethod' description: The methods this account can use now, in the order to offer them. Empty means none can. PasswordCheckRequest: type: object additionalProperties: false required: [password] properties: password: type: string maxLength: 128 minLength: 1 description: A CANDIDATE password, not `PasswordNew` — this runs while someone is still typing, so it accepts anything non-empty rather than `PasswordNew`'s length rule. PasswordCheck: type: object additionalProperties: false required: [breached] properties: breached: type: boolean description: >- Whether the candidate matches a known-breached password — the bundled list or, when enabled, the HIBP range lookup. Advisory: the four password-SET paths are the actual gate, not this field. count: type: integer minimum: 0 description: >- How many times HIBP has seen this exact password. Present only when HIBP is what caught it — never for a bundled-list hit, and never when rung 2 is disabled or unreachable. VerifyEmailConfirmRequest: type: object additionalProperties: false required: [token] properties: token: type: string maxLength: 128 minLength: 1 description: One-time email verification token (NOT a JWT). # One live sign-in, presented as a session. The credential is never exposed — a live # refresh token or session id is as good as a password — so `id` is the handle revocation # takes: a family id, minted at login and kept across every refresh and re-proof. Session: type: object additionalProperties: false required: [id, createdAt, expiration, current] properties: id: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Id' createdAt: type: string format: date-time description: >- When this sign-in happened. It is the session's, not the current token's: refreshing or re-proving the password does not move it. expiration: type: string format: date-time description: When the session ends, whatever its "remember me" tier. lastUsedAt: type: string format: date-time description: >- When this session last made a request. Absent until it makes one, which is what makes an idle session visible as idle in the list. device: type: string description: >- A coarse label for the browser and system that signed in, such as "Firefox on Linux", read from the User-Agent at the sign-in. Present in `cookie` mode only, and absent for a client that names neither (a script, `curl`). current: type: boolean description: >- Whether this session is the one making the request, matched through its own cookie or `ses_…` bearer. Always `false` for a caller authenticating by an access token alone — a `jwt`-mode access token does not identify a session. # A live session, metadata only — never the credential, which is as good as a password. # Used by `POST /account/export`. ExportSession: type: object additionalProperties: false required: [id, createdAt, expiration] properties: id: $ref: '../../../shared/contracts/openapi.root.yaml#/components/schemas/Id' createdAt: type: string format: date-time expiration: type: string format: date-time lastUsedAt: type: string format: date-time device: type: string description: The coarse device label stored at sign-in (`cookie` mode only). SessionsResponse: type: object additionalProperties: false required: [sessions] properties: sessions: type: array items: $ref: '#/components/schemas/Session' Password: type: string maxLength: 128 minLength: 8 description: >- An EXISTING password, being proved rather than set — login, the current-password leg of a change, and re-auth. Length bounds only, like `PasswordNew`: a login attempt is not the place to also announce the site's password policy to whoever is guessing it. PasswordNew: type: string maxLength: 128 minLength: 8 description: >- A password being SET by its owner — signup, reset (or the setup link) and change. Length only, 8 to 128 characters. The minimum of 8 is the OWASP ASVS floor; NIST SP 800-63B rev 4 asks for 15 when the password is the only factor. No composition rules, no forced mix of classes (NIST SP 800-63B-4); what keeps a weak one out is the breached-password check on every set path, not a pattern. Hashed with argon2id, which has no 72-byte limit, so every character counts. parameters: # ---------- account — the parameters only this module's paths reference. ---------- ReauthMethodPathParam: name: method in: path required: true schema: type: string enum: [email] description: A re-authentication method that delivers a code — a `method` from `GET /account/reauth` other than `password`. TwoFactorMethodPathParam: name: method in: path required: true schema: type: string maxLength: 32 description: 'Wire name of a second factor — a `method` from `GET /account/2fa`. A bare string, not an enum: the set of methods is a deployment fact, and a contract that enumerated them would need regenerating to add a channel.'