Skip to main content

Account settings API (/v1/me/settings, /v1/me/profile, /v1/me/preferences, security verbs, sessions)

Feature 010 (web console Settings screen). Every operation here is self only: each acts on the caller's own sub, and no path parameter names another user.

:::info Deployment status These routes are registered in the account area stack and are routed (the area stack is created by a default cdk synth; the web team observed these routes answering on dev on 2026-10-28). No execution has been captured. Every example below is an illustrative example derived from the Zod schemas in packages/core/src/schemas.ts and the contract in specs/010-account-settings/contracts/http-api.md. None is a captured response. :::

The legacy mobile GET /v1/me (Account API) is unchanged. The Flutter app keeps using it. These routes are additive.

Common to all operations​

AspectValue
AuthCognito JWT (HttpUserPoolAuthorizer). Never public
AuthZSelf only. A token issued before a "sign out everywhere", or of a sign-in that was ended, → 401 SESSION_REVOKED
HeadersAuthorization (required). Content-Type: application/json on bodies (else 415). X-Org-Id optional: picks the active org for the role row, locked formats and effective landing page. It must be one of your ACTIVE memberships, else 403 FORBIDDEN. X-Correlation-Id optional
Response headersX-Request-Id, Cache-Control: no-store; ETag where noted
BodiesStrict: unknown keys → 422 VALIDATION_FAILED. Max 256 KB (413 PAYLOAD_TOO_LARGE). Invalid JSON → 400 MALFORMED_REQUEST
Errors{ "error": { "code", "message", "details"?, "requestId" } }
Common errors401 gateway (bare {"message":"Unauthorized"}) · 401 SESSION_REVOKED · 403 FORBIDDEN · 429 RATE_LIMITED · 503 DEPENDENCY_UNAVAILABLE · 500 INTERNAL

GET /v1/me/settings: Settings screen bundle​

One call returns everything on the Settings page: account, role, security, preferences, locked formats, the 5 most recent sign-ins and org-settings links.

  • Query params: none. Any query parameter → 400 VALIDATION_FAILED.
  • Side effects (idempotent): creates a missing profile. Records or refreshes the caller's sign-in record (best-effort, before the bundle is built, so sessions includes this sign-in; every authenticated route does this, see Sessions). The MFA_DISABLED_OUT_OF_BAND access-log entry for MFA turned off outside the app is written by the Cognito PostAuthentication trigger at the user's next sign-in (MFA snapshot reconcile, one entry per ACTIVE org).
  • Degraded mode: if Cognito is unavailable, the response is still 200, with security.mfa.status: "UNKNOWN", account.phone: null and account.phoneStatus: "UNKNOWN". A DynamoDB failure → 503.
  • Response schema: SettingsView (in docs/openapi.yaml).

Field rules:

  • role is null when the caller has no ACTIVE membership.
  • role.managedBy is TEAM_AND_ACCESS or OPERATOR.
  • role.scope.kind is ALL | REGION | TAG | CUSTOMER | PLANTS | NONE.
  • account.joined.kind is JOINED | INVITED | ACCOUNT_CREATED.
  • account.avatar is the profile picture with a signed URL valid 5 minutes, or null when none is set (show account.initials then). Cache the image by account.avatar.avatarId, not by the URL. If the URL cannot be signed, avatar is null and the call still succeeds. Upload, change and remove: Profile picture API. (Added 2026-11-11, not deployed yet.)
  • security.mfa.status is ENABLED | DISABLED | UNKNOWN.
  • security.password.source is RESET | CLIENT_REPORTED, or absent.
  • formats.* are read-only here. Currency and timezone are edited in Customers → Business profile (editableIn).
  • orgSettingsLinks is empty for customer-org members.

Response 200 (illustrative example):

{
"account": {
"userId": "01J9Z0000000000000000000AA", "displayName": "Hamza Iqbal", "initials": "HI",
"email": "<email>", "emailNote": "USED_TO_SIGN_IN",
"phone": "+92300XXXX174", "phoneVerified": true,
"jobTitle": "Head of Operations",
"department": { "departmentId": "01J9Z0000000000000000000DP", "name": "Operations" },
"joined": { "kind": "JOINED", "at": "2024-02-14T09:00:00.000Z" },
"avatar": {
"avatarId": "01JCF6Z3M5W8Z0XK9R4T6V1AA0", "contentType": "image/jpeg", "sizeBytes": 48213,
"updatedAt": "2026-11-11T10:01:12.000Z",
"url": "https://cse-http-be-dev-service-files.s3.us-east-1.amazonaws.com/avatars/<sub>/01JCF6Z3M5W8Z0XK9R4T6V1AA0?X-Amz-Signature=…",
"expiresAt": "2026-11-11T10:06:12.000Z"
},
"version": 3
},
"role": {
"orgId": "01J9Z0000000000000000000OR", "orgName": "Crown Solar Pakistan", "orgKind": "OPERATOR",
"roleId": "01J9Z0000000000000000000RL", "roleName": "Administrator", "managedBy": "TEAM_AND_ACCESS",
"scope": { "kind": "ALL", "plantCount": 1284, "approximate": true, "summary": "ALL_PLANTS" }
},
"security": {
"password": { "changedAt": "2026-03-14T08:10:00.000Z", "source": "CLIENT_REPORTED", "accountCreatedAt": "2024-02-14T09:00:00.000Z" },
"mfa": { "status": "ENABLED", "methods": ["TOTP"], "preferred": "TOTP", "requiredBy": [] },
"lastSignInAt": "2026-09-28T07:55:00.000Z"
},
"preferences": { "…": "same shape as GET /v1/me/preferences" },
"formats": {
"unitSystem": { "value": "METRIC", "locked": true, "owner": "PLATFORM" },
"currency": { "value": "PKR", "locked": true, "owner": "ORGANISATION", "editableIn": "CUSTOMERS_BUSINESS_PROFILE" },
"timezone": { "value": "Asia/Karachi", "locked": true, "owner": "ORGANISATION", "editableIn": "CUSTOMERS_BUSINESS_PROFILE" }
},
"sessions": { "items": [], "hasMore": false },
"orgSettingsLinks": [ { "id": "ALERTS", "allowed": true }, { "id": "ENGINEERING", "allowed": false } ]
}
StatusCodeWhen
200—success (possibly degraded)
400VALIDATION_FAILEDunknown query parameter
403FORBIDDENX-Org-Id not an ACTIVE membership
401 / 429 / 500 / 503common—

PATCH /v1/me/profile: edit display name and job title​

  • Headers: If-Match: "<version>" is optional. When you send it, it is enforced.
  • Body (UpdateProfileInput, at least one field):
FieldTypeValidation
displayNamestringtrimmed, 1–120. null or "" → 422 (it cannot be cleared)
jobTitlestring | nulltrimmed, max 80. null or "" removes it

Any other field (email, phone, department, role, version, …) → 422 VALIDATION_FAILED.

A missing profile is created on the fly and the save retried.

A changed displayName is also copied to Cognito on a best-effort basis. If that copy fails, it is logged and the response is still 200.

Response 200: the account block (SettingsAccount); phone fields may be absent. It comes with a new ETag.

The profile picture is not edited here: use the Profile picture API (/v1/me/avatar). The response's account.avatar shows the current one.

Illustrative request: PATCH /v1/me/profile with body {"displayName":"Hamza Iqbal","jobTitle":null}.

StatusCodeWhen
200—saved
400MALFORMED_REQUESTinvalid JSON
400VALIDATION_FAILEDmalformed If-Match (*, a list, an unquoted number)
428PRECONDITION_REQUIREDIf-Match sent but empty
409VERSION_CONFLICTstale If-Match (details.currentVersion)
413 / 415PAYLOAD_TOO_LARGE / UNSUPPORTED_MEDIA_TYPE—
422VALIDATION_FAILEDempty body, non-editable field, length

GET /v1/me/preferences​

Returns your preferences with defaults filled in, plus the effective landing page for the active org. It has no side effects. isDefault: true means nothing has been saved yet. The ETag carries version. effectiveLandingPage is your landingPage, or OVERVIEW when you lack that module in the active org.

Response 200 (illustrative example, UserPreferencesView):

{
"appearance": { "theme": "LIGHT", "density": "COMFORTABLE", "landingPage": "SERVICE", "effectiveLandingPage": "OVERVIEW" },
"formats": { "energyScaling": "AUTO", "dateFormat": "D_MMM_YYYY", "clock": "H24", "weekStart": "MONDAY" },
"notifications": {
"channels": { "inApp": true, "push": true, "email": true, "sms": false, "smsAvailable": false },
"dailySummary": { "enabled": false, "time": "08:00" },
"quietHours": { "enabled": false, "start": "22:00", "end": "06:00", "criticalBypass": true },
"timezone": "Asia/Karachi"
},
"history": { "paramKeys": [] },
"version": 0,
"isDefault": true
}

Errors: 400 VALIDATION_FAILED (unknown query parameter), 403 FORBIDDEN (bad X-Org-Id), plus the common errors.

PATCH /v1/me/preferences: save any subset​

This is PATCH, not PUT. Send only the fields you change. Nested objects are deep-partial and strict at every level. At least one value is required. If-Match is optional; when sent, it is enforced. No Idempotency-Key is needed: sending the same body twice gives the same state.

FieldValues
appearance.themeLIGHT | DARK | SYSTEM
appearance.densityCOMFORTABLE | COMPACT
appearance.landingPageOVERVIEW | PLANTS | ALERTS | SERVICE | ANALYTICS
formats.energyScalingAUTO | KWH
formats.dateFormatD_MMM_YYYY | DD_MM_YYYY | YYYY_MM_DD
formats.clockH24 | H12
formats.weekStartMONDAY | SUNDAY
notifications.channels.push / .emailboolean
notifications.channels.inApponly true (else 422 UNSUPPORTED_OPERATION)
notifications.channels.smsonly false (else 422 UNSUPPORTED_OPERATION)
notifications.dailySummary.enabledboolean
notifications.dailySummary.timeHH:mm, quarter-hour
notifications.quietHours.enabledboolean
notifications.quietHours.start / .endHH:mm; start must differ from end
notifications.timezonevalid IANA zone
history.paramKeysarray of at most 20 unique parameter keys (1–64 chars, A-Z a-z 0-9 _ . : -); replaces the stored list whole, [] clears it

Behaviour:

  • Two saves that change different keys at the same time both persist. For the same key, the last write wins.
  • If you send only one quiet-hours bound, the server reads the stored other bound and checks that they differ. If the other bound changes before the write lands → 409 VERSION_CONFLICT. Reload and retry.
  • History picker selection (2026-11-30, not deployed). history.paramKeys holds the parameters chosen in the Historical data picker, so the choice follows the account across browsers and devices. The keys are TCP parameter keys; this server stores them as given and does not check them against the TCP catalogue. GET returns [] until one is saved. Only the chosen keys are stored; the "all parameters" set and the active chip stay in the browser.
  • unitSystem, currency and timezone at the top level are not preferences → 422 VALIDATION_FAILED.
  • Push toggle (mobile "Receive push notifications", ADR 0025, 2026-11-13, not deployed). Send {"notifications":{"channels":{"push":false}}} to turn push off, or true to turn it back on. Off means no push at all, CRITICAL alerts included. A critical alert then goes by email if the org's email is on, and always appears in the in-app bell. Push goes only to End Users, so for staff accounts the switch is stored but changes nothing.
  • Any change under notifications is sent to the TCP Server (which sends the pushes) in the same transaction as the save, as an updated notify.user.v1. The switch takes effect within the bus latency, typically seconds. Such a save is conditioned on the version it read. A concurrent save is retried once on the server, then 409 VERSION_CONFLICT. Changes outside notifications work exactly as before.

Illustrative request for the mobile toggle (derived from the schema, not a captured call): PATCH /v1/me/preferences with {"notifications":{"channels":{"push":false}}}. The response is 200 with the full UserPreferencesView. Its notifications.channels.push is false, version is one higher, and a new ETag is set.

Illustrative request: {"appearance":{"theme":"DARK"},"notifications":{"quietHours":{"enabled":true}}}. The response is 200: the updated UserPreferencesView with a new ETag.

StatusCodeWhen
200—saved
400MALFORMED_REQUESTinvalid JSON
400VALIDATION_FAILEDmalformed If-Match (*, a list, an unquoted number)
428PRECONDITION_REQUIREDIf-Match sent but empty
409VERSION_CONFLICTstale If-Match, a lost race on the other quiet-hours bound, or (notifications changes) a concurrent save that still conflicts after one server retry
413 / 415PAYLOAD_TOO_LARGE / UNSUPPORTED_MEDIA_TYPE—
422VALIDATION_FAILEDunknown key, bad enum/time, empty body, start = end (details.fieldErrors)
422UNSUPPORTED_OPERATIONinApp:false or sms:true (details.field)

Security: POST /v1/me/mfa:disable and POST /v1/me/password:report-change​

Both are colon-verb URLs on one wire route, POST /v1/me/{action}: the whole last segment is the verb. Any other verb → 404 NOT_FOUND. Neither takes a body (a body → 422 VALIDATION_FAILED). Same auth, headers and common errors as above. Routed; the examples are illustrative, not captured.

Turning MFA on (no route)​

Enrolment is client-direct against Cognito: AssociateSoftwareToken → VerifySoftwareToken → SetUserMFAPreference. Then reload GET /v1/me/settings.

POST /v1/me/mfa:disable​

Turns TOTP off. Two-factor is the user's own choice (2026-11-11): no organisation, org kind or role requires it, so this call is never refused with MFA_REQUIRED, and any user who turned two-factor on can turn it off. security.mfa.requiredBy in the settings bundle is always [] (kept for contract compatibility). Don't lock the switch because of it.

On success the server disables TOTP in Cognito and writes one MFA_DISABLED access-log entry in each ACTIVE org. If MFA was already off the response is still 200 with changed: false and no entries.

  • Rate limit: 10 per hour per user.
  • Idempotency-Key: optional; a replay with the same key returns the stored response.

Illustrative 200: { "mfa": { "status": "DISABLED" }, "changed": true, "auditedOrgIds": ["01J..."] }

StatusCodeWhen
200—disabled, or already disabled (changed: false)
403FORBIDDEN / ACCOUNT_SUSPENDEDX-Org-Id sent but not one of your ACTIVE memberships / that membership is suspended (the route has no org, but the header is still checked)
409IDEMPOTENCY_IN_PROGRESSsame key still in flight
422VALIDATION_FAILED / IDEMPOTENCY_KEY_REUSEDbody sent / key reused
429RATE_LIMITEDover 10/h
503DEPENDENCY_UNAVAILABLECognito or DynamoDB unavailable

POST /v1/me/password:report-change​

Call this right after the app changes the password client-direct (Cognito ChangePassword). The server stamps passwordChangedAt with server time and source CLIENT_REPORTED. It never receives a password.

A forgot-password reset is different: the Cognito post-confirmation trigger stamps it with source RESET. The app does not call this route after a reset. The settings bundle shows the latest of either as security.password.changedAt / security.password.source.

  • Rate limit: 10 per 24 hours per user.
  • Other sign-ins end (QA B4, 2026-11-30): every other live sign-in of the caller is ended, as by :end-others. Their tokens get 401 SESSION_REVOKED, each affected org's access log gets a SESSION_ENDED entry ("Password changed: signed out N other sessions"), and access.revoked.v1 SESSIONS_ENDED closes their TCP WebSocket sockets (close code 4401). The calling sign-in stays signed in. A token without origin_jti ends nothing, because the calling sign-in can't be told apart. If ending fails, the error is logged and the 200 answer stays the same.

Illustrative 200: { "passwordChangedAt": "2026-10-23T09:41:07.000Z", "source": "CLIENT_REPORTED" }

StatusCodeWhen
200—stamped
403FORBIDDEN / ACCOUNT_SUSPENDEDX-Org-Id sent but not one of your ACTIVE memberships / that membership is suspended (the route has no org, but the header is still checked)
404NOT_FOUNDcaller's profile item missing (load GET /v1/me/settings first, which creates it)
422VALIDATION_FAILEDbody sent
429RATE_LIMITEDover 10/24 h
503DEPENDENCY_UNAVAILABLEDynamoDB unavailable

Sessions: sign-in records and sign-out​

Feature 010 US5 (FR-033 to FR-037), N-50, and the session fixes of 2026-11-12 (web console requests B-1, B-3, B-4, S-1 to S-4). Five operations, all self only, all behind the Cognito authorizer.

:::caution Not deployed yet (2026-11-12) The 2026-11-12 changes on this section are in code on cse-http-be main, not deployed to dev. Until they are, dev still behaves as before: one row per Cognito trigger call, no ipAddress/expiresAt, :end-others answers 404, and an ended sign-in is refused only on routes that resolve the request context. No execution of the new behaviour has been captured; every example below is an illustrative example derived from the code. :::

One record per sign-in​

A sign-in is one successful Cognito authentication. Cognito stamps every token that sign-in ever mints (the first ID/access tokens and every token from a refresh) with the same origin_jti claim. The API keys the record by it:

  • The record is created on the sign-in's first authenticated request to any route, not by the Cognito trigger. A sign-in whose tokens were never used (for example a pending sign-in the console discarded) leaves no row.
  • A refreshed token carries the same origin_jti, so it only moves lastActiveAt on the same record (at most every 15 minutes, or sooner when the IP or device changes). It never adds a row.
  • Each browser or device sign-in is its own record; several may be active at once.
  • The Cognito PostAuthentication trigger only stamps lastSignInAt/previousSignInAt on the profile.
  • Rows written before 2026-11-12 by the trigger that were never tied to a token (no origin_jti) are not listed any more; they expire by TTL.
  • Expiry (issue #29, 2026-11-12, not deployed). A sign-in ends for good when its refresh token expires (expiresAt, below). From then on it is not listed, and its record and pointer are deleted by DynamoDB TTL one day later (was 90 days). A request made with that sign-in's last access token (valid up to 1 hour past expiresAt) creates and updates nothing.
  • No duplicates (issue #29). Two records tied to the same origin_jti can remain from the binding used before 2026-11-12. They are listed once (the newest).

What is recorded. Device: from the User-Agent header (only the parsed label and class are kept, never the raw string). If the first request had no recognisable User-Agent, the label comes from the issuing app client instead (issue #29, 2026-11-12, not deployed): Dart's default Dart/<ver> (dart:io) → "Crown mobile app" (PHONE); otherwise a MOBILE client → "Crown mobile app" (UNKNOWN), a WEB client → "Web browser" (DESKTOP). Only the SERVER (admin) client still reads "Unknown device". Rows already stored as "Unknown device" are shown the same way. The next request with a recognisable User-Agent still replaces the label. The Flutter app should send CrownSolar/<version> (<model>; <os>) so the phone model is shown. IP address and place: only from the web console. The API reads the first hop of X-Forwarded-For when (1) the token's app client is one of the console's (SESSION_IP_CLIENT_IDS, see Infrastructure), (2) the value is a public IPv4 or IPv6 address (private, loopback, link-local and CGNAT ranges are ignored), and (3) it differs from the address that connected to the API (equal means the console sent no header and the hop is the console's own server). Every other client's X-Forwarded-For is ignored. CloudFront viewer headers are no longer read.

Place (location). Resolved from that IP to { city, country } only (never coordinates, a postal code or a street address) and cached per IP for 30 days. No IP-location provider is configured yet, so location is still absent on every row; ipAddress is recorded. See Known issues.

Ending a sign-in​

Every way of ending a sign-in (current:end, {sessionId}:end, :end-others, :end-all) marks it ended by its origin_jti. From the next request, every token of that sign-in, including tokens it mints later by refreshing, gets 401 SESSION_REVOKED on every authenticated route of this API, not only the account routes.

:::warning What ending a sign-in cannot do

  • Cognito cannot revoke one sign-in's refresh token from the server. RevokeToken needs the refresh token itself, which only that device holds, and the only server-side call (AdminUserGlobalSignOut) ends every sign-in, including the caller's. So after {sessionId}:end or :end-others the ended device can still refresh at Cognito; every token it gets is refused here. The web console revokes its own refresh token when it receives SESSION_REVOKED. :end-all does call AdminUserGlobalSignOut, so there no refresh works.
  • The TCP WebSocket is a separate backend. POST /v1/realtime/tickets refuses new tickets at once. Since 2026-11-30 (QA B5) current:end, {sessionId}:end, :end-others and password:report-change also publish access.revoked.v1 {reason: SESSIONS_ENDED, originJtis}. ws-gateway closes those sign-ins' sockets right away (code 4401) and refuses their tickets after that. The ticket carries the sign-in as its oj claim. This needs the integration bus (busEnabled, on in dev). Without the bus, or for a socket opened with an older ticket that has no oj, the old limit still applies: the socket drops within about 11 minutes. See KI-52.
  • The check reads DynamoDB with eventual consistency: a request in the same second as the end may still pass. :::

GET /v1/me/sessions​

Lists your own sign-ins, newest sign-in first. current: true marks the sign-in of the token making this call. Like every route, the call also creates or refreshes your record.

QueryTypeRule
limitint1 to 50; default 15 on the first page, 10 with a cursor (lazy loading). 51 → 422 VALIDATION_FAILED
cursorstringopaque nextCursor from the previous page. Malformed or foreign → 400 INVALID_CURSOR

limit out of range (e.g. 51) → 422 VALIDATION_FAILED; unknown query parameter → 400 VALIDATION_FAILED. No filters, no sort. Only sign-ins that can still be live are read: the query starts at signedInAt = now − the longest refresh-token lifetime (90 days). Legacy unbound rows, expired sign-ins and repeats of one origin_jti are then skipped (issue #29), so a page can hold fewer than limit items while nextCursor is still present: keep paging until it is absent. A nextCursor that falls before that 90-day window (kept a long time) returns an empty last page (items: [], no nextCursor).

SessionView fields:

FieldTypeNotes
sessionIdULIDuse with {sessionId}:end
currentbooleanthe calling sign-in
clientKindWEB / MOBILE / SERVERfrom the token's app client. The console signs in with flutter-app-default/-remembered today, so its rows read MOBILE
deviceLabelstring ≤ 80e.g. "Chrome on macOS". Until a request with a recognisable User-Agent: "Crown mobile app" / "Web browser" by client kind; "Unknown device" only for the SERVER client (see "What is recorded")
deviceClassDESKTOP / PHONE / TABLET / UNKNOWN
location{ city?, country? }optional; see "Place" above (absent until a provider is configured)
ipAddressstringoptional, new: the public IP the console forwarded. Absent for other clients
signedInAtISOthe token's auth_time
lastActiveAtISOoptional
expiresAtISOnew: signedInAt + the issuing app client's refresh-token lifetime
statusenumderived, see below

Never returned: the token id (origin_jti) or the app client id.

status is derived in this order:

statusWhen
SIGNED_OUTended with current:end, {sessionId}:end or :end-others
ENDED_BY_SIGN_OUT_EVERYWHEREsigned in before your last :end-all
EXPIREDnow is past expiresAt. Never returned by a list since issue #29 (2026-11-12, not deployed): expired sign-ins are filtered out. The value stays in the enum
ACTIVEotherwise

Refresh-token lifetimes (lib/auth-stack.ts REFRESH_TOKEN_VALIDITY): web-console 1 day, flutter-app-default 1 day, flutter-app-remembered ("Remember me") 90 days, server-admin 1 day.

supportsEndSingleSession is true: {sessionId}:end exists.

Illustrative 200 (not a captured response):

{
"items": [
{ "sessionId": "01J9Z3K8Q2W4E6R8T0Y2U4I6O8", "current": true, "clientKind": "MOBILE",
"deviceLabel": "Chrome on macOS", "deviceClass": "DESKTOP",
"ipAddress": "203.0.113.7",
"signedInAt": "2026-11-12T07:55:00.000Z", "lastActiveAt": "2026-11-12T09:40:00.000Z",
"expiresAt": "2026-11-13T07:55:00.000Z", "status": "ACTIVE" }
],
"nextCursor": "eyJ…",
"supportsEndSingleSession": true
}
StatusCodeWhen
200—including items: []
400INVALID_CURSORbad cursor
400VALIDATION_FAILEDunknown query parameter
401SESSION_REVOKEDthe calling sign-in was ended
403FORBIDDEN / ACCOUNT_SUSPENDEDoptional X-Org-Id sent: not an ACTIVE membership / that membership is suspended
422VALIDATION_FAILEDlimit out of range

POST /v1/me/sessions/current:end​

Ends the calling sign-in, for a normal "Sign out" button. No body (a body → 422 VALIDATION_FAILED). Always 204: also when it was already ended, and also when the sign-in never made a record (it is ended all the same, and no row appears). This route itself is never answered SESSION_REVOKED. Natural idempotency, no key.

This does not revoke the refresh token at Cognito. After the 204, the client must call Cognito RevokeToken with its refresh token and discard its tokens.

StatusCodeWhen
204—ended, already ended, or no record
403FORBIDDEN / ACCOUNT_SUSPENDEDX-Org-Id sent but not one of your ACTIVE memberships / that membership is suspended (the route has no org, but the header is still checked)
404NOT_FOUNDunknown verb
422VALIDATION_FAILEDbody sent

POST /v1/me/sessions/{sessionId}:end​

Ends one other sign-in (N-50). On the wire this is POST /v1/me/sessions/{action} with action = <sessionId>:end. No body. Writes one SESSION_ENDED access-log entry per ACTIVE org. To end every other sign-in use :end-others below, not this route in a loop.

StatusCodeWhen
204—ended, or already ended
401SESSION_REVOKEDthe calling sign-in was itself ended
404NOT_FOUNDnot your sign-in, or unknown
409INVALID_STATEdetails.reason: NO_ORIGIN (a legacy row never tied to a token), CURRENT_SESSION (use current:end), CONCURRENT_UPDATE (racing write; retry)
429RATE_LIMITEDover 10 per hour

POST /v1/me/sessions:end-others​

New (S-1, 2026-11-12). Ends every other live sign-in of the caller in one call, keeping the one the calling token belongs to (matched by its origin_jti). On the wire this is POST /v1/me/{action} with action = sessions:end-others.

  • Headers: Idempotency-Key required (missing → 428 PRECONDITION_REQUIRED, details.header: "Idempotency-Key").
  • Body: none (a body → 422). Query: none (→ 400).
  • Effect: each ended sign-in reads SIGNED_OUT, and from its next request every token of it gets 401 SESSION_REVOKED on every route. Already-ended, expired and legacy unbound rows are skipped. One SESSION_ENDED access-log entry per ACTIVE org when anything was ended.
  • Response: 200 { "ended": <number> }, the count this call ended (0 when nothing else was live).
  • Replay: the same key returns the first answer with Idempotent-Replayed: true.
  • Rate limit: 30 calls per hour per user. There is no per-sign-in limit: one call ends any number.
  • Limit: as for {sessionId}:end, the ended devices' Cognito refresh tokens stay valid until they expire; everything they mint is refused here.

Illustrative 200: { "ended": 24 }

StatusCodeWhen
200—done, or replay
400VALIDATION_FAILEDquery parameter sent, or malformed Idempotency-Key
401SESSION_REVOKEDthe calling sign-in was itself ended
403FORBIDDEN / ACCOUNT_SUSPENDEDX-Org-Id sent but not one of your ACTIVE memberships / suspended
409IDEMPOTENCY_IN_PROGRESSsame key still in flight
422VALIDATION_FAILED / IDEMPOTENCY_KEY_REUSEDbody sent / key reused
428PRECONDITION_REQUIREDno Idempotency-Key
429RATE_LIMITEDover 30 calls/h
503DEPENDENCY_UNAVAILABLEDynamoDB unavailable (retry with the same key)

POST /v1/me/sessions:end-all (sign out everywhere)​

Signs you out on every device, including this one.

:::warning Account-wide, not org-scoped (CR-6) This sets profile.tokensValidAfter = now and calls Cognito GlobalSignOut. It is account-wide: every refresh token in every org is revoked, and every access/ID token issued before now gets 401 SESSION_REVOKED on its next call, whichever org it targets. Since 2026-11-12 every sign-in is also marked ended by its origin_jti, so the refusal covers every route. It is a different lever from the org admin's "End all sessions" on a member (POST /v1/orgs/{orgId}/members/{sub}:end-sessions, see Team API), which sets membership.tokensValidAfter for one org only. An org admin cannot use this endpoint on another person: it only ever acts on the caller. Because it is account-wide, your sign-out-everywhere is visible in every org you belong to. :::

  • Headers: Idempotency-Key required (missing → 428 PRECONDITION_REQUIRED, details.header: "Idempotency-Key").
  • Body: none (a body → 422).
  • Rate limit: 10 per hour per user.
  • Event: writes an outbox item access.revoked.v1 { scope: "USER", sub, reason: "END_ALL_SESSIONS" } in the same transaction. It reaches the TCP side only once the integration bus is deployed (busEnabled, off by default; see Infrastructure). Until then nothing is delivered and live WebSocket streams are not cut by this call.
  • Retry: on 503 (Cognito down) retry with the same key; both steps are safe to repeat.

Illustrative 200: { "endedAt": "2026-10-23T09:41:07.000Z", "tokensValidAfter": 1792748467, "currentSessionEnded": true, "reauthenticationRequired": true }

After the 200, the client must discard its tokens and show the sign-in screen. A replay with the same key returns the stored body with Idempotent-Replayed: true.

StatusCodeWhen
200—done, or replay
403FORBIDDEN / ACCOUNT_SUSPENDEDX-Org-Id sent but not one of your ACTIVE memberships / that membership is suspended (the route has no org, but the header is still checked)
409IDEMPOTENCY_IN_PROGRESSsame key still in flight
422VALIDATION_FAILED / IDEMPOTENCY_KEY_REUSEDbody sent / key reused
428PRECONDITION_REQUIREDno Idempotency-Key
429RATE_LIMITEDover 10/h
503DEPENDENCY_UNAVAILABLECognito or DynamoDB unavailable