Skip to main content

Notifications (A09, G01–G05)

:::caution Registered in code — live after the owner's next deploy The nine 008 routes (A09a/b, G01a–d, G02a/b, G05) are registered in lib/routes.ts in the notify route-area stack cse-http-be-<stage>-api-notify (Q27: shared HttpApi + authorizer). G03 (POST /v1/notification-rules:preview) rides POST /v1/{collection} in ApiStack (CR-2). All 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). Remaining gaps:

  • the NotifyStack (recompute/reconcile and digest workers) is built but not deployed, and exists only with -c busEnabled=true. Where it exists, audiences beyond the first 25 users are queued to notify-recompute (Q36); without it they are recomputed synchronously after commit, in chunks of 25, so rule writes in very large orgs can be slow (Lambda timeout 25 s); if the timeout is exceeded the rule is saved but some audiences may stay stale until the next weekly reconcile once the NotifyStack is deployed;
  • the notify.*.v1 events (notify.user.v1, notify.audience.v1, notify.org-settings.v1) are written to the outbox on deploy but reach TCP only when busEnabled is on;
  • PUSH/EMAIL availability comes from SSM channel flags; unset means UNAVAILABLE (Q37);
  • department/team recipients are not expanded from an org directory yet (Q38);
  • the email consumer is off by default (SES sandbox).

Nothing here has been executed against any stage. All JSON is an illustrative example, derived from the Zod schemas in packages/core/src/schemas.ts (RegisterPushTokenInput, PushTokenView, CreateNotificationRuleInput, UpdateNotificationRuleInput, PreviewNotificationRuleInput, PutNotificationSettingsInput, NotificationSettingsView) and specs/008-alerts-notifications/contracts/http-api.md. :::

This service stores the who and how of notifications (push tokens, rules, org settings) and publishes them to the TCP Server as projections. The TCP Server detects alerts and sends push. The delivery log is served by TCP over the WebSocket (get_notification_deliveries), not by this API (G04 was removed). See Notifications architecture.

Common rules​

AspectRule
AuthCognito JWT (Authorization: Bearer <idToken>) on every route
Org context/v1/orgs/{orgId}/… — org from the path; caller needs an ACTIVE membership → else 403 FORBIDDEN. G03 needs X-Org-Id → 400 ORG_CONTEXT_REQUIRED
Levelalerts permission of the caller's role: VIEW to read, MANAGE to edit rules, FULL to edit settings
BodiesContent-Type: application/json (else 415), ≤ 256 KB (else 413), strict (unknown field → 422 VALIDATION_FAILED)
Common errors400 MALFORMED_REQUEST, 400 VALIDATION_FAILED (unknown query param), 401, 403 FORBIDDEN / ACCOUNT_SUSPENDED, 429 RATE_LIMITED (+Retry-After), 503 DEPENDENCY_UNAVAILABLE, 500 INTERNAL
ConcurrencyResponses carry ETag: "<version>"; mutations need If-Match → missing 428 PRECONDITION_REQUIRED, stale 409 VERSION_CONFLICT (details.currentVersion)

A09a — POST /v1/me/push-tokens​

Register the FCM token of this device (Android, iOS, web browser). Call it after sign-in, on every token refresh, and (web) when desktop alerts are enabled. Self only. Idempotency-Key optional; naturally idempotent on (platform, token).

FieldTypeReqValidation
platformANDROID | IOS | WEByesenum
tokenstringyes16–4096 chars, ^[A-Za-z0-9:_\-.]+$; never logged or returned
appIdstringno≤ 128, ^[A-Za-z0-9._-]+$
deviceLabelstringnotrimmed, ≤ 64
appVersionstringno≤ 32

Response 201 (new) or 200 (same user re-registered the token) — illustrative example:

{ "tokenId": "q3Jk…43chars", "platform": "ANDROID", "deviceLabel": "Pixel 8",
"appVersion": "1.4.0", "createdAt": "2026-09-28T10:00:00.000Z",
"lastSeenAt": "2026-09-28T10:00:00.000Z" }
StatusCodeWhen
201 / 200—created / refreshed
422VALIDATION_FAILEDschema failure
422IDEMPOTENCY_KEY_REUSEDsame key, different body
409IDEMPOTENCY_IN_PROGRESSsame key in flight
429RATE_LIMITEDmore than 20 new registrations by this user in the current UTC day (Retry-After = seconds to 00:00 UTC)

Rate limit (WP-7, committed 2026-11-06, not deployed). Only a token the user does not already hold counts. Re-posting a registered token (the 200 case: page load, token refresh) never counts. The limit is per user, in a fixed UTC-day window that resets at 00:00 UTC. It is not a rolling 24 hours. Before this change every call counted, re-posts included.

Push is for End Users only, on every platform (ADR 0025, which generalises WP-3 / ADR 0022). A token of any platform (ANDROID, IOS, WEB) is accepted from anyone with the same 201/200. It is sent to the TCP Server only while every active membership the person holds is an End User membership, which means one of:

  • the End User role;
  • a Customer org;
  • their personal org.

A staff user's tokens (Super Admin, Administrator, Business, Installer) are stored but not used for alerts or other pushes. The person's notify.user.v1 carries pushEligible: false, so the TCP Server also skips the tokens the app registered with it directly. The tokens are used for everything again if the person later holds End User memberships only.

Exception: membership notices (ADR 0031, 2026-11-26). Since ADR 0031 a staff user's endpoints are sent to the TCP Server too. The only pushes they can receive are JOIN_REQUEST_RECEIVED, INVITATION_RECEIVED and ADDED_TO_BUSINESS.

Edge cases: a token already held by another user moves to the caller; an 11th token evicts the least recently seen one (max 10 per user). Registration works even when the Push channel is unavailable.

A09b — DELETE /v1/me/push-tokens/{tokenId}​

Sign-out on this device. tokenId is 43-char base64url → else 422 VALIDATION_FAILED. Always 204: absent token, deleted token, and a token owned by someone else (nothing changes — non-disclosure).

G01a — GET /v1/orgs/{orgId}/notification-rules​

alerts ≥ VIEW. No pagination (≤ 50 rules by construction); any query param → 400. The system rule ("Critical alerts — all plants") is seeded on first read. Response 200 — illustrative example:

{
"items": [
{ "ruleId": "00000000000000000000000000", "name": "Critical alerts — all plants",
"severity": "CRITICAL", "categories": [], "scope": { "kind": "ALL", "targetIds": [] },
"recipients": [{ "kind": "ALERT_MANAGERS" }], "schedule": { "kind": "ANY_TIME" },
"channels": ["PUSH", "EMAIL"], "notifyOn": ["RAISED"], "enabled": true, "system": true,
"lockedFields": ["name", "severity", "scope", "schedule", "enabled"], "version": 1,
"createdAt": "2026-09-28T10:00:00.000Z", "updatedAt": "2026-09-28T10:00:00.000Z" }
],
"summary": { "count": 1, "activeCount": 1 },
"viewer": { "capabilities": ["notificationRules.view"] }
}

viewer.capabilities includes notificationRules.edit when the caller's alerts level is ≥ MANAGE — use it to show the edit controls. A label whose target no longer exists is omitted and the entry gets stale: true.

G01b — POST /v1/orgs/{orgId}/notification-rules​

alerts ≥ MANAGE. Idempotency-Key required (428 PRECONDITION_REQUIRED). 60 rule writes / org / hour. Body CreateNotificationRuleInput: name?, severity, categories?, scope, recipients, schedule, channels, notifyOn?, enabled?. Response 201 with the rule, ETag: "1" and Location.

scope.targetIds: none for ALL; for PLANT_TYPE, 1–3 unique values from RESIDENTIAL, COMMERCIAL, INDUSTRIAL (owner decision Q1); every other kind 1–50 ids in this org. Out of range or an unknown plant type → 422 VALIDATION_FAILED.

StatusCodeWhen
201—created (replay: original 201 + Idempotent-Replayed: true)
422VALIDATION_FAILEDschema; scope/recipient target missing or in another org
422UNSUPPORTED_OPERATIONchannel SMS/WHATSAPP (details.reason: CHANNEL_PLANNED)
422LIMIT_EXCEEDED50 rules (details.limit: 50)
428PRECONDITION_REQUIREDno Idempotency-Key
422IDEMPOTENCY_KEY_REUSEDsame key, different body
409IDEMPOTENCY_IN_PROGRESSsame key in flight
429RATE_LIMITED> 60 rule writes / org / hour (shared by POST, PATCH, DELETE)
403FORBIDDENalerts < MANAGE

G01c — PATCH /v1/orgs/{orgId}/notification-rules/{ruleId}​

alerts ≥ MANAGE, If-Match required, JSON merge with at least one field; null is rejected. Response 200 + ETag.

StatusCodeWhen
404NOT_FOUNDrule not in this org, or ruleId not a ULID
428PRECONDITION_REQUIREDno If-Match
409VERSION_CONFLICTstale version
422UNSUPPORTED_OPERATIONsystem rule locked field (SYSTEM_RULE_LOCKED, details.fields); planned channel
422VALIDATION_FAILEDschema; empty recipients/channels; digest schedule without EMAIL
429RATE_LIMITEDshared 60 rule writes / org / hour

G01d — DELETE /v1/orgs/{orgId}/notification-rules/{ruleId}​

alerts ≥ MANAGE, If-Match required. 204. Already deleted → 404; system rule → 422 UNSUPPORTED_OPERATION; non-ULID ruleId → 404; plus 428, 409, 429 RATE_LIMITED (shared 60 / org / hour).

G02a — GET /v1/orgs/{orgId}/notification-settings[?include=rules]​

alerts ≥ VIEW. include=rules adds the G01a items. No stored settings → defaults with version: 0. An include value other than rules → 400 VALIDATION_FAILED. Response 200 + ETag — illustrative example:

{
"orgId": "01J9Z1…", "timezone": "Asia/Karachi", "version": 4,
"channels": [
{ "channel": "PUSH", "enabled": true, "availability": "ACTIVE" },
{ "channel": "EMAIL", "enabled": true, "availability": "UNAVAILABLE",
"unavailableReason": "EMAIL_PROVIDER_NOT_READY" },
{ "channel": "SMS", "enabled": false, "availability": "PLANNED" },
{ "channel": "WHATSAPP", "enabled": false, "availability": "PLANNED" }
],
"grouping": { "enabled": true, "windowMinutes": 60 },
"digest": { "enabled": true, "time": "08:00", "weeklyDay": "MON" },
"quietHours": { "enabled": false, "start": "22:00", "end": "07:00" },
"workingHours": { "start": "09:00", "end": "18:00", "days": ["MON","TUE","WED","THU","FRI","SAT"] },
"workOrderAssignment": { "inApp": true, "push": true, "audience": "ASSIGNEE", "timing": "IMMEDIATE" },
"rulesSummary": { "count": 5, "activeCount": 4 },
"viewer": { "capabilities": ["notificationSettings.view", "notificationRules.view"] },
"updatedAt": "2026-09-28T10:00:00.000Z"
}

viewer.capabilities ⊆ notificationSettings.view, notificationSettings.edit (alerts = FULL), notificationRules.view, notificationRules.edit (≥ MANAGE), notificationDeliveries.view (≥ MANAGE; a UI hint — the log itself comes from TCP).

Availability comes from SSM flags: PUSH is ACTIVE only while /cse-tcp-be/<stage>/notify/push-enabled is true, EMAIL only while /cse-http-be/<stage>/notify/email-enabled is true. An unset flag means UNAVAILABLE (PUSH_SENDER_NOT_READY / EMAIL_PROVIDER_NOT_READY).

Work order assignment (workOrderAssignment, issue #14 BP-3, committed 2026-11-13, not deployed): the "Work order assignment" default row. When a work order is assigned or reassigned, the assignee always gets the in-app inbox item (WORK_ORDER_ASSIGNED). push (default true) decides whether that item is also sent as a web push. inApp: true, audience: "ASSIGNEE" and timing: "IMMEDIATE" are fixed. Settings saved before this field existed read as push: true. It affects only the WORK_ORDER_ASSIGNED push; every other inbox kind is unchanged. A monthly customer summary default is not built (there is no backend source for it).

G02b — PUT /v1/orgs/{orgId}/notification-settings​

alerts = FULL. If-Match required ("0" for the first write). Full replace: channels (all four keys, each { enabled }), grouping, digest, quietHours, workingHours, and optionally workOrderAssignment: { push: boolean } (issue #14). If workOrderAssignment is left out, the stored value is kept, so older clients keep working. Computed fields are rejected (send only push, not inApp, audience or timing). Response 200 (G02a shape without rules).

StatusCodeWhen
422UNSUPPORTED_OPERATIONenabling SMS/WHATSAPP (CHANNEL_PLANNED); disabling both PUSH and EMAIL (LAST_CRITICAL_CHANNEL)
422VALIDATION_FAILEDranges/formats; quietHours.start == end; workingHours.start >= end
428PRECONDITION_REQUIREDno If-Match
409VERSION_CONFLICTstale
403FORBIDDENalerts < FULL

A digest-time change applies to digests scheduled after the change.

G03 — POST /v1/notification-rules:preview​

alerts ≥ MANAGE in the X-Org-Id org. No side effects. 60 / user / min. Body { "rule": CreateNotificationRuleInput, "ruleId"?: ULID } (ruleId when previewing an edit). Response 200 — illustrative example:

{
"summary": "Warning alerts · Region: Sindh → Operations Manager · Working hours (09:00–18:00) · Push",
"parts": { "severity": "Warning alerts", "scope": "Region: Sindh", "recipients": "Operations Manager",
"when": "Working hours (09:00–18:00)", "channels": "Push" },
"plantCount": { "value": 312, "approximate": true },
"recipientCount": 6,
"recipientSample": [{ "sub": "…", "name": "Bilal Ahmed" }],
"warnings": [{ "code": "CHANNEL_UNAVAILABLE", "channel": "EMAIL" }]
}

warnings[].code ∈ CHANNEL_UNAVAILABLE, CHANNEL_DISABLED_FOR_ORG, NO_RECIPIENT_WITH_ACCESS, DUPLICATE_RULE, COVERED_BY_SYSTEM_RULE, SCOPE_EMPTY. Errors: 400 ORG_CONTEXT_REQUIRED, 422 VALIDATION_FAILED, 422 UNSUPPORTED_OPERATION, 403 FORBIDDEN.

G04 — delivery log (served by TCP)​

Not an HTTP route. The TCP Server serves it over the WebSocket as get_notification_deliveries. It needs only a verified (signed-in) caller and returns that caller's own deliveries; no alerts level is checked (confirmed by the TCP Server, 2026-10-29). See the TCP Server docs.

HTTP in-app inbox (T-12)​

:::caution Routed on dev, not captured signed in GET /v1/me/notifications and POST /v1/me/notifications:mark-read are committed (867d62d, 2026-10-29). The web team observed GET /v1/me/notifications answering 401 without a token on dev on 2026-11-02, so it is routed there. No signed-in response has been captured yet. Every JSON block below is an illustrative example derived from the Zod schemas (InboxListView, InboxNotificationView, MarkNotificationsReadInput in packages/core/src/schemas.ts) and packages/api/src/handlers/me-notifications.ts, not a captured response. :::

Two inboxes, agreed with the TCP Server. Each server keeps its own inbox. The TCP Server keeps device-alert items; this server keeps items for HTTP-owned events. The web console shows both, and its unread badge is the TCP device-alert unread count plus this server's unreadCount.

Producers. Items are planned in packages/core/src/inbox/producers.ts. The stream-router writes them, and work-order items are also written on the request path (below). One item goes to one known user, never to the actor about their own action:

kindRecipientlink.type
WORK_ORDER_ASSIGNEDThe newly assigned technicianWORK_ORDER
WORK_ORDER_STATUSThe work order's creator (user)WORK_ORDER
ACCESS_REQUEST_DECIDEDThe requesterACCESS_REQUEST
SHARE_GRANTEDA user grantee of a shareSHARE
REPORT_READYThe user who created the reportREPORT
WORK_ORDER_UNASSIGNEDThe previous technician, on reassign or unassign (WO-10, 2026-11-04)WORK_ORDER
WORK_ORDER_ACCEPTED / WORK_ORDER_DECLINEDThe Business user who made the assignment (assignedBy) and the order's creatorWORK_ORDER
WORK_ORDER_COMPLETEDThe same Business users; replaces the creator's WORK_ORDER_STATUS item for that transitionWORK_ORDER
WORK_ORDER_STARTEDThe Business users (assignedBy and the creator), when the Installer starts an accepted order (ADR 0023)WORK_ORDER
WORK_ORDER_PROGRESSThe Business users, when the assigned Installer adds a note; at most one per order per recipient per hour (the id embeds the hour) (ADR 0023)WORK_ORDER
WORK_ORDER_HOLD_REQUESTEDThe Business users, when the Installer asks for a hold (ADR 0023)WORK_ORDER
WORK_ORDER_VERIFIEDThe Business users, when the order is verified (ADR 0023)WORK_ORDER
WORK_ORDER_COMPLETION_REJECTEDThe Installer, when the Business sends the completion back (ADR 0023)WORK_ORDER
WORK_ORDER_ON_HOLD / WORK_ORDER_RESUMEDThe Installer and the Business users, on hold and resume (ADR 0023)WORK_ORDER
WORK_ORDER_CLOSED / WORK_ORDER_CANCELLEDThe Installer and the Business users, on close and cancel (ADR 0023)WORK_ORDER
SERVICE_REQUEST_SUBMITTED / SERVICE_REQUEST_DECIDEDNo longer produced (ADR 0023 D12 retired service requests). Older items stay readable until they expireSERVICE_REQUEST
INVITATION_RECEIVEDThe invitee, when an INTERNAL/DELEGATED invitation to their verified email is created or renewed (2026-11-23, console R1). Carries an extra invitation object. See Invitation notificationINVITATION (no orgId)
JOIN_REQUEST_RECEIVEDThe Business members who can decide it (team ≥ MANAGE, at most 20, never the requester), when an Installer's POST /v1/me/join-requests succeeds (ADR 0031, 2026-11-26)JOIN_REQUEST (with orgId)
ADDED_TO_BUSINESSAn End User a plant transfer added straight into a Business as a member, never the actor (ADR 0031, 2026-11-26)ORG (id = orgId)
PLANT_SHARE_REQUESTED2026-11-27 (ADR 0032): an independent End User asked to share a plant. To the Business's active members with team ≥ MANAGE (at most 20), never the actorPLANT_SHARE (id = shareId, orgId = the Business)
PLANT_SHARE_ACCEPTED / PLANT_SHARE_DECLINEDADR 0032: to the End User when the Business answersPLANT_SHARE
PLANT_SHARE_REVOKEDADR 0032: an active share ended. To the other side (the End User, or the Business's team ≥ MANAGE members)PLANT_SHARE

The six kinds added on 2026-11-04/05 (ADR 0019) are deployed on dev. The nine kinds added by ADR 0023 (work-order lifecycle v2, 2026-11-10) are built but not deployed; until the next deploy, dev still produces the service-request kinds. "The Business users" are the user who made the current assignment and the order's creator. The creator's generic WORK_ORDER_STATUS item is not sent when one of the specific items already reaches them. Crown staff are not notified about every Business's orders; they use the activity history and the Crown-wide work-order list. Details: work-order notifications.

The work-order items are written on the request path right after the change (best-effort). They therefore arrive even without the stream-router. The ids are deterministic, so a later stream delivery of the same change is a no-op.

INVITATION_RECEIVED (built and deployed to dev 2026-11-23) is also written on the request path: after an INTERNAL/DELEGATED invitation is created or renewed, the handler resolves the invited address to the one account with that email verified (one Cognito ListUsers) and writes the item. No account → no item; the person sees the invitation in GET /v1/me/invitations after sign-up and verification. The item is marked read when the invitation is accepted, declined, revoked or renewed, and its TTL is the invitation's expiry. Full rules: Invitation notification.

:::note Needs the stream-router The producers run in the stream-router, which exists only when the stage is deployed with busEnabled on. It is deployed on dev, the only stage: the bus has been on since 2026-11-19, and the cse-http-be-dev-integration stack was re-verified UPDATE_COMPLETE on 2026-11-23. On a stage without the stream-router, the list holds only the work-order items (and, until ADR 0023 is deployed, the service-request items) that are written on the request path. ACCESS_REQUEST_DECIDED, SHARE_GRANTED and REPORT_READY still need the stream-router. See KI-43. :::

Web push for inbox items (WP-4 / WP-6, committed 2026-11-06, not deployed). When an item of the kinds below is created, the same DynamoDB transaction writes one notify.push.requested.v1 for the TCP Server to send. The item is therefore always in this inbox before the push goes out. A duplicate delivery of the same change creates nothing and sends nothing. The push goes to web endpoints only (platforms: ["WEB"]), so the mobile app gets no new notifications. Only End Users have endpoints in the TCP Server's copy (pushEligible, see A09a above), so staff recipients get no push either.

kindPush linktag
WORK_ORDER_ASSIGNED, WORK_ORDER_STATUS, WORK_ORDER_UNASSIGNED, WORK_ORDER_ACCEPTED, WORK_ORDER_DECLINED, WORK_ORDER_COMPLETED, and the nine ADR 0023 kinds (WORK_ORDER_STARTED, WORK_ORDER_PROGRESS, WORK_ORDER_COMPLETION_REJECTED, WORK_ORDER_VERIFIED, WORK_ORDER_CLOSED, WORK_ORDER_CANCELLED, WORK_ORDER_ON_HOLD, WORK_ORDER_RESUMED, WORK_ORDER_HOLD_REQUESTED)/service?order=<workOrderId>wo-<workOrderId>
REPORT_READY/reportsreport-<reportId>
INVITATION_RECEIVED/ (confirmed by the console team 2026-11-23: the header bell lists invitations on every page)invite-<inviteId>
JOIN_REQUEST_RECEIVED (ADR 0031)/joinreq-<requestId>
ADDED_TO_BUSINESS (ADR 0031)/joined-<orgId>
PLANT_SHARE_REQUESTED, PLANT_SHARE_ACCEPTED, PLANT_SHARE_DECLINED, PLANT_SHARE_REVOKED (ADR 0032)/pshare-<shareId> (data.shareId, data.orgId)

INVITATION_RECEIVED, JOIN_REQUEST_RECEIVED and ADDED_TO_BUSINESS are the exception to "web only" and "End Users only". See Membership notices.

The four PLANT_SHARE_* kinds (ADR 0032, 2026-11-27) are pushed to Android, iOS and web, but only to End Users (ADR 0025 eligibility applies, no exception). The End User gets accepted, declined and revoked on their phone. Business staff get the inbox item only. See the share a plant with a business guide.

Push title and body are the item's title and body. With no body the push says "Open the console for details.". data carries type (the kind), notificationId, tag, workOrderId, reportId, inviteId or requestId, and orgId when known (never for INVITATION_RECEIVED). ACCESS_REQUEST_DECIDED, SHARE_GRANTED and the (retired) service-request kinds are not pushed: the console team has not given a path for them yet. Sending needs the TCP Server's web push sender, which is not running yet (KI-48). REPORT_READY cannot happen until a report renderer exists (KI-41).

Storage and retention. One item USER#<sub>/NOTIF#<ulid> per notification, deleted by DynamoDB TTL 90 days after createdAt, or at the invitation's expiry for INVITATION_RECEIVED (expired items are also filtered out of reads). The unread counter USER#<sub>/NOTIFCOUNT goes +1 with each new item (same transaction) and −n on mark-read (never below 0). Item ids are derived from the source event, so a redelivered stream record creates nothing new.

GET /v1/me/notifications​

Signed-in user, own items only. No org level; X-Org-Id is optional, but if sent it must be an org you can select. Rate-limit family me-settings.

QueryRule
limit1–50; default 15 on the first page, 10 with a cursor (lazy loading)
cursorOpaque nextCursor from the previous page; an invalid one is 400 INVALID_CURSOR
unreadOnlytrue or false (default false)
anything else400 VALIDATION_FAILED

Newest first. A page may hold fewer than limit items when many are read or expired (at most 5 DynamoDB queries per page); keep following nextCursor until it is absent. unreadCount is maintained incrementally, so it may briefly over-count after unread items expire (TTL); a mark-all resets it, and a list that reads the whole partition also repairs it. Clients must tolerate unknown kind and link.type values (the enums are additive).

200 — illustrative example
{
"items": [
{
"notificationId": "01JBZ0000000000000000000N1",
"kind": "WORK_ORDER_ASSIGNED",
"title": "Work order assigned to you",
"body": "WO-0042 at Lahore Rooftop",
"link": { "type": "WORK_ORDER", "id": "01JBZ0000000000000000000W1", "orgId": "01JBZ0000000000000000000O1" },
"actor": { "displayName": "Ayesha Khan" },
"createdAt": "2026-10-29T08:00:00.000Z"
}
],
"unreadCount": 1,
"nextCursor": "eyJ…"
}

Fields: title ≤ 160 chars, body ≤ 500 (optional), actor optional, readAt present once read. link carries ids only; opening the target goes through that target's own route and its own authorization, so a link the user can no longer open returns that route's 403/404.

POST /v1/me/notifications:mark-read​

Body {"ids": ["<ulid>", …]} (1–100 ULIDs) marks those items read. No body (or {}) marks all unread items read. Each call marks at most 500 items (5 pages of 100) and still returns 204; if more remain, call it again. After a mark-all the counter is recounted from the live unread items, without losing an item created meanwhile. "ids": [] is rejected (422 VALIDATION_FAILED). Unknown, foreign or already-read ids are skipped silently. Idempotent; no Idempotency-Key. 204 No Content on success. Rate-limited to 120 calls per hour per user: over the limit it returns 429 RATE_LIMITED with Retry-After.

Request — illustrative example
{ "ids": ["01JBZ0000000000000000000N1"] }

Errors for both routes: 400 VALIDATION_FAILED (unknown query parameter), 401, 403 FORBIDDEN (X-Org-Id not selectable), 415/422 on a bad body, 429 RATE_LIMITED, 503 DEPENDENCY_UNAVAILABLE.

G05 — GET /v1/alerts/{alertId}/work-orders​

Implemented in packages/api/src/handlers/list-alert-work-orders.ts, registered in cse-http-be-<stage>-api-notify (live after the owner's next deploy). Work-order strip in the alert drawer. Signed in, no org context. Each row is kept only if the caller has service ≥ VIEW on its plant. At most 20 rows, newest first, no cursor.

FieldNotes
workOrderId, code, plantId, status, priority, createdAtalways present
assigneeoptional; { sub?, name } — sub is omitted for customer-portal-only callers
dueAtoptional; equals the work order's responseTargetAt

Response 200 — illustrative example:

{ "items": [{ "workOrderId": "01J…", "code": "WO-2026-0498", "plantId": "01J…",
"status": "ASSIGNED", "priority": "HIGH", "assignee": { "sub": "…", "name": "Hina Rauf" },
"dueAt": "…", "createdAt": "…" }] }
StatusCodeWhen
200—rows (possibly empty). Unknown alert, invisible rows, or links whose work order or plant is gone → dropped / { "items": [] } (never 404/403)
400VALIDATION_FAILEDany query parameter
422VALIDATION_FAILEDalertId not ^[A-Za-z0-9_-]{1,64}$
401 / 403commonnot signed in; ACCOUNT_SUSPENDED

Membership notices (ADR 0031)​

Built 2026-11-26, not committed, not deployed. Fixes the bug "a Business sees an Installer's join request only after a refresh, and gets no push". The owner named three exceptions to the End-Users-only push rule. There are no others:

Who is toldWhenKind
The Business: ACTIVE members with effective team ≥ MANAGE, at most 20, never the requesterAn Installer sends a join request with the join code (POST /v1/me/join-requests)JOIN_REQUEST_RECEIVED
The InstallerA Business invites them (in-app invitation)INVITATION_RECEIVED
The End UserA Business invites them (INVITATION_RECEIVED), or a plant transfer adds them straight into the Business (ADDED_TO_BUSINESS)INVITATION_RECEIVED, ADDED_TO_BUSINESS
  • Inbox item first. Each item is written on the request path right after the join request, invitation or transfer commits. It is best-effort: a failure is logged and the original call still succeeds. Ids are deterministic, so a retry does not notify twice.
  • Push on every platform. These kinds write notify.push.requested.v1 with platforms: ["ANDROID","IOS","WEB"] and eligibilityExempt: true. The TCP Server sends them even when the person's pushEligible is false. The person's own push toggle and quiet hours still apply.
  • No refresh needed (Flutter). The push data carries type (the kind), orgId and, for a join request, requestId. On a push with data.type = JOIN_REQUEST_RECEIVED, foreground included, the app reloads GET /v1/orgs/{orgId}/join-requests. On INVITATION_RECEIVED it reloads GET /v1/me/invitations. On ADDED_TO_BUSINESS it reloads GET /v1/me/context. The item is also in GET /v1/me/notifications, and unreadCount goes up.
  • Open dependency (TCP Server). The TCP Server must honour eligibilityExempt. Until it does, staff recipients (the Business for a join request, an Installer for an invitation) get the inbox item but no push. End Users already get theirs.
  • Not done: a Business's JOIN_REQUEST_RECEIVED items stay unread after the request is accepted, rejected or cancelled. They expire after 90 days.

Illustrative example, derived from packages/core/src/inbox/push.ts. It is not a captured execution.

{
"requestId": "inbox-<notificationId>",
"userSub": "<business-member-sub>",
"title": "Ali Installer asked to join your business",
"body": "Open Requests to accept or reject.",
"link": "/",
"tag": "joinreq-<requestId>",
"platforms": ["ANDROID", "IOS", "WEB"],
"eligibilityExempt": true,
"data": { "type": "JOIN_REQUEST_RECEIVED", "notificationId": "<notificationId>", "requestId": "<requestId>", "orgId": "<orgId>", "tag": "joinreq-<requestId>" }
}

Push: End Users only and the push toggle (ADR 0025)​

Committed to the working tree 2026-11-13. Not deployed, and not exercised against any stage. This generalises ADR 0022 (below) from web push to every platform.

  • Who gets push: End Users only (rule under A09a). Super Admin, Administrator, Business and Installer never get push, on any platform, even if they are also an End User elsewhere.
  • notify.user.v1 gains pushEligible: boolean. It is always sent by this server. Consumers treat a missing value (older events) as true. When it is false, the event has no endpoints, and the TCP Server must also skip the tokens it holds itself. The flag is in the content hash, so an eligibility change alone republishes the event.
  • Push toggle: PATCH /v1/me/preferences notifications.channels.push (Account settings). false (pushEnabled: false in the event) means no push at all, CRITICAL included. The CRITICAL override falls back to email, then to NO_CHANNEL. A notifications change republishes notify.user.v1 in the same transaction as the save.
  • When eligibility changes: member suspend, restore or remove, a role or scope change, a bulk scope change and an invitation accept all republish the person's notify.user.v1, whether or not they hold an HTTP token. It goes in the same transaction for up to 25 people, otherwise right after the commit. Rule, share, technician-team and role-permission changes skip this, because they cannot change eligibility.
  • Coverage: an End User who never registered a token here, never changed preferences and never had a membership change has no notify.user.v1. The TCP Server treats such a user as eligible. The reconciliation gives a first notify.user.v1 to every member of a Platform, Business or Installer org that has none, so after one completed run every staff member is covered with pushEligible: false.
  • Delivery-policy reason: a new NOT_ELIGIBLE reason marks a push suppressed for a staff member (contract §C2, conformance vectors).

Web push (ADR 0022)​

Browser notifications for the web console, sent by the TCP Server through FCM (Firebase project crown-solar-energy-dev on dev; dev is the only stage). Committed 2026-11-06, not deployed, and nothing has been sent yet. This server's part:

  • Who: End Users only, decided per person (see A09a). A person with any active staff membership gets no web push, even if they are also an End User elsewhere.
  • When it stops: a membership or role change republishes the person's notify.user.v1 in the same transaction (≤ 25 users) or right after the commit. Since ADR 0025 this applies to every platform (see above). Their endpoints disappear from the TCP Server's copy within seconds of the bus delivering it, inside the console's 2-minute bound. The weekly reconciliation repairs any miss.
  • What: alert pushes come from the TCP Server (its docs). HTTP-owned pushes are the inbox kinds listed under HTTP in-app inbox.
  • Dead tokens: when the TCP Server reports notify.endpoint.invalid.v1, this server deletes the token. That part is already built.
  • Quota: see the rate-limit note under A09a.

The TCP Server's half is listed in KI-48.