Web console additions (N-37 … N-51)
This page covers the web-console features added after the 010 account settings work. They are drafts, layouts, brand assets, session end, phone edit, the About panel, report notes and customer counters.
:::warning Not deployed
Every route on this page is implemented in code and registered in lib/routes.ts, but none of them is
deployed to any stage yet. No request has been executed against them. Every example below is an
illustrative example built from docs/openapi.yaml, packages/core/src/schemas.ts and the handlers. None
is a captured response.
:::
All routes use the shared conventions: JWT bearer auth (Cognito authorizer), the
{ error: { code, message } } envelope, camelCase JSON and ISO-8601 UTC timestamps.
Work-order drafts (N-37)
The service stack cse-http-be-<stage>-api-service hosts these routes (family work-order-drafts, area service).
A draft is private to the caller and scoped to the org in X-Org-Id. Every call needs service ≥ EDIT in
that org.
| Method | Path | Notes |
|---|---|---|
POST | /v1/work-order-drafts | Creates a draft. Idempotency-Key is required (428 without it). Returns 201 with Location and ETag |
GET | /v1/work-order-drafts | Lists the caller's drafts, newest first. limit (max 50) and cursor |
GET | /v1/work-order-drafts/{draftId} | Returns the full draft with its ETag |
PUT | /v1/work-order-drafts/{draftId} | Replaces the whole draft. If-Match is required. Resets the expiry |
DELETE | /v1/work-order-drafts/{draftId} | Idempotent. Returns 204 whether or not the draft existed |
Limits and rules:
- Expiry: 30 days after the last save (
expiresAt). Expired drafts disappear from reads. - Count: at most 50 drafts per user per org. The 51st returns
422 LIMIT_EXCEEDED(details.limit). - Size: the request must be at most 256 KB, and the serialised
bodyat most 16 KB. Larger requests return413 PAYLOAD_TOO_LARGE. - Body (
WorkOrderDraftBody): everyCreateWorkOrderInputfield, all optional, with no defaults and no cross-field rules. An unknown key returns422 VALIDATION_FAILED.lastStepis an integer from 1 to 10. - List pages: a short page that still has a
nextCursoris normal, because expired drafts and drafts from other orgs are filtered out. - Errors:
400 ORG_CONTEXT_REQUIRED(noX-Org-Id),400 INVALID_CURSOR,403,404 NOT_FOUND(an unknown or expired draft, or one that belongs to another org or another user),409 VERSION_CONFLICT(staleIf-Match) and428 PRECONDITION_REQUIRED.
Submitting a draft: there is no submit verb. The client sends the final body to POST /v1/work-orders, which
runs the full validation. Then it calls DELETE /v1/work-order-drafts/{draftId}.
Illustrative example (derived from the schema, not a captured run):
POST /v1/work-order-drafts
X-Org-Id: 01J…ORG
Idempotency-Key: 6f1c…
{ "body": { "plantId": "01J…PLANT", "title": "Inverter fault check", "priority": "HIGH" }, "lastStep": 2 }
{ "draftId": "01J…DRAFT", "orgId": "01J…ORG", "title": "Inverter fault check", "plantId": "01J…PLANT",
"lastStep": 2, "version": 1, "expiresAt": "2026-11-28T10:00:00.000Z",
"createdAt": "2026-10-29T10:00:00.000Z", "updatedAt": "2026-10-29T10:00:00.000Z" }
The summary's title falls back to alert.title, then to "Untitled work order".
Saved screen layouts (N-40)
These routes are self-only, with no org or level check (family me-settings, area account). Layouts are separate
from /v1/me/preferences.
| Method | Path | Notes |
|---|---|---|
GET | /v1/me/layouts | Returns only the layouts the user saved, at most 8 and never paginated. A missing key means "use the screen default". A stored layout that no longer validates is skipped (and logged), not returned as an error |
PUT | /v1/me/layouts/{layoutKey} | Replaces the whole layout. If-Match is optional but enforced when sent ("0" means create only). Returns the saved layout with a new ETag |
DELETE | /v1/me/layouts/{layoutKey} | Resets the layout to the screen default. Idempotent 204. Sending a body returns 422 |
layoutKey is one of PLANTS_TABLE, CUSTOMERS_TABLE, WORK_ORDERS_TABLE, MEMBERS_TABLE, REPORTS_TABLE,
DEVICES_TABLE, ALERTS_TABLE or DASHBOARD. Any other value returns 404 NOT_FOUND. The body is a
TableLayout (columns, at most 40) for every *_TABLE key and a DashboardLayout for DASHBOARD. Both are
strict, so an unknown field returns 422. Errors:
413when the serialised layout is over 8 KB.409 VERSION_CONFLICTwithdetails.currentVersionwhenIf-Matchis stale.428whenIf-Matchis sent but empty.422for duplicate column keys or widget ids.
Report schedules and templates (N-39)
recipientNoteon a report schedule (create, PATCH and view) is optional, at most 500 characters, trimmed, and may not contain control characters. In PATCH,nullor a blank string clears it. It is absent from the view when no note is set. The note is stored and returned only.samplePreviewUrlon a report template is<REPORT_SAMPLES_BASE_URL>/<sampleImage>. It appears only when the stage was synthesised with-c reportSamplesBaseUrl=<https URL>, which setsREPORT_SAMPLES_BASE_URLon thereport-templatesfunction. Synth rejects a value that is nothttps://or is longer than 200 characters.- "Current view" scope: send scope
{ "kind": "PLANTS", "ids": [...] }with at most 200 ids. - Not built: the CSV format, because it waits on the TCP-side renderer, and custom templates.
Admin-web list totals, counts and filter options (2026-11-24)
The admin web console (cse-admin-web) asked for first-page totals and a few filters on its listing screens.
Each is HTTP-owned data, read from counters or small bounded Queries. No Scan, and nothing reads telemetry.
Every total is first page only (no cursor sent) and ignores the other filters and q. It is the size of
the whole collection, not of the filtered result.
:::info Not deployed
None of this has run against a deployed stage. The shapes below are illustrative, taken from
packages/core/src/schemas.ts and docs/openapi.yaml.
:::
| Route | New field / parameter | Source | Exact? |
|---|---|---|---|
GET /v1/orgs/{orgId}/customers | total: customers in the requested status (ACTIVE, CHURNED, or both for ALL) | COUNT#customers#status#*, or the PLATFORM#CUSTOMERS shards on the Crown-wide list | Approximate |
GET /v1/orgs/{orgId}/customers | tiles.cities[] = { city, count }: the city filter options (per-org lists only) | COUNT#customers#city#<normalised> (counts ACTIVE customers only) | Approximate |
GET /v1/orgs/{orgId}/customers | operatorOrgId=none: Independent End Users only (personal orgs). Crown-wide list only | FilterExpression personal = true on the LISTALL#CUSTOMER entries. Pages may be short and still carry a cursor | Exact rows |
GET /v1/orgs/{orgId}/partners | total | Sum of COUNT#partners#status#* | Approximate |
GET /v1/orgs/{orgId}/tags | total | Sum of groupCounts | Approximate |
GET /v1/orgs/{orgId}/tags | q (2–64 chars): every word must be the start of a word in the label | Filtered in Lambda over the label-ordered partition. Up to 5 Queries per page, so a page may be short and still carry a cursor. The cursor is bound to q | Exact |
GET /v1/orgs/{orgId}/businesses | total | Paged Select: COUNT on GSI2 ORGS#OPERATOR. This small directory never holds personal orgs | Exact at read time |
GET /v1/orgs/{orgId}/members | statusCounts = { ACTIVE, SUSPENDED, INVITED, total, approximate }. Also sent on the q path | COUNT#members#status#*. INVITED is the pending-invitation counter | Approximate |
GET /v1/orgs/{orgId}/members | plantCount on each item | PLANTS = number of targets. NONE = 0. ALL, CUSTOMER, REGION and TAG = sum of the plants facet counters, so a plant in two targets counts twice. Absent for an ALL scope in the PLATFORM org | Approximate |
GET /v1/orgs/{orgId}/reports | total (not sent with q) | COUNT#reports#all#all, the same counter as H01b libraryTotal | Approximate |
GET /v1/orgs/{orgId}/report-schedules | total | COUNT#reportSchedules#all#all, the same counter as H01b scheduleCount | Approximate |
GET /v1/orgs/{orgId}/maintenance-plans | total | Paged Select: COUNT on the org's PLAN# slice. Plans are never deleted | Exact at read time |
GET /v1/me/favorites | total | Paged Select: COUNT on the caller's own FAV#<type># slice. It counts stored stars, so it includes favourites the caller can no longer see | Exact at read time |
Illustrative example (not a captured response). Page 1 of GET /v1/orgs/{orgId}/customers for a Business:
{
"items": [],
"total": 42,
"tiles": {
"active": 42, "totalOnRecord": 45, "noPortalAccess": 6, "capacityKwp": 812.5,
"cities": [{ "city": "lahore", "count": 20 }, { "city": "karachi", "count": 9 }],
"approximate": true
},
"refs": { "orgs": {}, "tags": {} }
}
Pass a cities[].city value back unchanged as ?city=. The filter compares normalised names.
Already supported (no change):
- Departments.
GET /departmentsitems already carrymemberCountfrom theCOUNT#members#departmentId#<id>counter. - Plants
q. It covers the plant name, plant code, customer name, address city, address region and tag labels (plantSearchFields) and, since 2026-11-24, the street address and an exact plant id — see Plantsq. - Plants
favorite=true. It combines with every other filter, includingq. It does not combine withsort: that is400 VALIDATION_FAILED, withdetails.allowed: []. - Customers
q. It covers the customer name, customer code, contact name, contact email and city. Contact name and email are searched only for callers withcustomers≥ MANAGE. Since 2026-11-24 it also matches the customer's plant names (Customers list).
Not done (reason):
- Plants
model=. A device binding holds only an optional, client-typedmodelstring. A plant does not hold it, and the model catalogue belongs to TCP.
Added 2026-11-24 (not deployed yet; no execution captured):
- Saved-view match counts for any filters.
GET …/saved-views/{viewId}/count— a bounded count (cap 500,capped) through the plant list path. The list's owncountstays single-facet. - Technicians and installers in service history.
GET …/maintenance-history/technicianslists everyone named on closed orders (unscoped callers), including people without a roster profile. - Work-order column sorts.
sort=planned|priority|status|plant|technician|device|cost(and-), plus-dueAt, on E01, per Business and Crown-wide, with or withoutq(2026-11-25). Share-based callers getqueue,createdAt/-createdAtanddueAtonly; page 1 saysaccess: shared.queuestill orders open work by the response deadline (SLA target) first, then by priority, then newest first (service/queue-key.ts).
Existing rows need the backfills in Operations (backfill:customer-plant-names,
backfill:wo-console-indexes, then rebuild:projections for search tokens).
Customer overview and list counts (N-46)
GET /v1/orgs/{orgId}/customers/{customerOrgId}/overview (C18) now fills these blocks:
devices: always available. HascountandcapacityKwp, from per-customer plant sums, andapproximate: true.service: available only when the caller has service ≥ VIEW. HasopenWorkOrdersfrom theCOUNT#WOCUST#OPEN#<c>counter, withapproximate: true.lastVisitAtis not filled yet.reports: available only with reports ≥ VIEW.lastDeliveredAtis thereadyAtof the first READY report from this operator among the customer's 5 newest portal reports. It is absent when there is none.
The customer list tiles (capacityKwp) also carry approximate: true. The counters are stream-maintained and
eventually consistent. Plants and open work orders that existed before the projector was deployed are missing from
them until the owner runs the backfill script once. See
Operations. Alerts and live health are not part of these
counts. They come from the TCP server.
Tag dependents: the tag-retire impact view (dependents, sources) now also has providers for
MAINTENANCE_PLAN (the plan's scopeRule.tagIds), REPORT_SCHEDULE and NOTIFICATION_RULE (scope kind
TAG or REGION on that tag), alongside MEMBER_SCOPE, SHARE and SAVED_VIEW.
Members, shares and roles (N-48)
lastSignInAton the member list and member detail is now filled. It holds the member's last sign-in to the product (any org, any app), fromUSER#<sub>/PROFILE.lastSignInAt, which the Cognito PostAuthentication trigger writes. It is omitted when no sign-in is recorded.phone(E.164, possibly unverified) appears in the member detail only, and only for a caller with team ≥ MANAGE. It is never on the list. It is omitted when not set or when the identity provider is unavailable, and the drawer still loads.granteeLastSignInAton a share (USER grantee with an account only) is that user's last sign-in to the product. It is not a record of the share being used. It is absent for ORG grantees, pre-accept email grantees and users with no recorded sign-in.- Role
color:NEUTRAL | INFO | SUCCESS | WARNING | ERROR | ACCENT. System roles have fixed colours (Super AdminERROR, AdministratorWARNING, ViewerNEUTRAL). On a custom role the colour is optional, andnullin an update clears it.
Brand assets (N-49)
These routes are hosted in the new stack cse-http-be-<stage>-api-reports-settings (family org-branding).
| Method | Path | AuthZ | Notes |
|---|---|---|---|
POST | /v1/orgs/{orgId}/brand-assets | settings ≥ EDIT | Idempotency-Key is required. Creates a PENDING asset and returns a presigned S3 PUT valid for at most 15 minutes. A replay returns a fresh URL for the same PENDING asset. Limited to 30 uploads per user per hour (429) |
POST | /v1/orgs/{orgId}/brand-assets/{assetId}:confirm | settings ≥ EDIT | Checks the uploaded object, copies it to the asset's final key and moves the asset from PENDING to READY. Returns {asset, download} (since issue #14, 2026-11-13; before, the bare asset). Confirming a READY asset is a no-op 200 with a fresh download URL |
GET | /v1/orgs/{orgId}/brand-assets/{assetId} | settings ≥ VIEW | Returns a READY asset with a presigned GET, valid for at most 300 s. A PENDING or unknown asset returns 404 |
- Input is
slot(PRIMARY_LOCKUP | REVERSE_LOCKUP | APP_MARK | REPORT_COVER),fileName,contentTypeandsizeBytes. PNG and JPEG only, at most 1 MB. SVG is refused (422) because it can carry script. - Upload the bytes with the returned
headersunchanged. Content-Type and Content-Length are signed. - Upload key (KI-40 fix, issue #14, committed 2026-11-13, not deployed): the presigned PUT now points at a
staging key under
pending/. Treat the URL as opaque.:confirmcopies the object to the final key and deletes the upload. Use thedownload.url(a presigned GET, at most 300 s) from:confirmorGET, never the upload URL. - Confirm errors:
409 INVALID_STATEwithdetails.reason OBJECT_MISSINGwhen nothing was uploaded.422 VALIDATION_FAILEDwithSIZE_MISMATCHorTYPE_MISMATCHwhen the object does not match. The staged upload is deleted.404for an unknown asset, or one that stayed PENDING for more than 2 days.
- Business profile:
branding.<slot>.assetIdin the business-profile PATCH must now name a READY asset of the org for that slot. Otherwise it returns422 VALIDATION_FAILEDwithdetails.reasonASSET_NOT_FOUND,ASSET_NOT_READYorASSET_SLOT_MISMATCH. - Cleanup: an upload that is never confirmed is deleted by the bucket's 1-day
pending/lifecycle rule. This closes KI-40 once deployed.
Notification defaults (GET/PUT /v1/orgs/{orgId}/notification-settings) are in code, in area notify.
They only work once the cse-http-be-<stage>-api-notify stack is deployed.
End one other session and edit your phone (N-50)
POST /v1/me/sessions/{sessionId}:end ends one other sign-in of the caller. On the wire this is
POST /v1/me/sessions/{action} with action = <sessionId>:end.
- Returns 204 when the sign-in was ended, or was already ended.
404 NOT_FOUNDwhen the session is not the caller's, or is unknown.409 INVALID_STATEwithdetails.reason NO_ORIGINwhen the record was never bound to a token. It returnsCURRENT_SESSIONfor the caller's own sign-in; usecurrent:endinstead.409 INVALID_STATEwithdetails.reason CONCURRENT_UPDATEwhen a racing write wins twice;404when the session record disappeared meanwhile.429 RATE_LIMITEDabove 10 calls per hour. To end all other sign-ins in one call, usePOST /v1/me/sessions:end-others(2026-11-12, see Account settings API).- Writes one
SESSION_ENDEDaccess-log entry for each ACTIVE org.
Honest limits:
- The ended sign-in's Cognito refresh token stays valid until it expires, so it can still mint tokens.
- This API refuses those tokens. Since 2026-11-12 (not deployed) every request on every authenticated
route that carries that sign-in's
origin_jtireturns401 SESSION_REVOKED. - An already-open TCP WebSocket drops within about 11 minutes (10-minute ticket plus the gateway's 60 s re-ticket grace). New realtime tickets are refused at once.
- See KI-52.
Phone edit: PATCH /v1/me/profile accepts phone (E.164). It is written to the identity provider
unverified (phone_number_verified=false). No SMS is sent and nothing verifies it, so it never becomes a
sign-in alias. phone: null returns 422 UNSUPPORTED_OPERATION (details.reason PHONE_REQUIRED), because phone
is a required attribute on the user pool. When the identity provider fails, the call returns 503. The profile
version may already have advanced, and a retry is safe.
About / Help panel (N-51)
GET /v1/about is open to any signed-in user (family discovery, in the main cse-http-be-<stage>-api stack).
Any query parameter returns 400. The response has Cache-Control: private, max-age=300 and a strong ETag, and
If-None-Match returns 304. The route never calls CloudWatch or the TCP service.
| Field | Source |
|---|---|
apiVersion | Always v1 |
build.commit | -c aboutBuildCommit, a 7 to 40 character hex hash (env ABOUT_BUILD_COMMIT). Since 2026-12-02 (BE-12) npm run deploy:dev passes the current git rev-parse HEAD |
build.builtAt | -c aboutBuiltAt, ISO-8601 (env ABOUT_BUILT_AT). Since 2026-12-02 npm run deploy:dev passes the deploy time (UTC) |
support.email | -c supportEmail (env SUPPORT_EMAIL). Since 2026-12-02 (BE-12, owner) cdk.json sets info@crownsolarenergy.com |
support.url | -c supportUrl, https (env SUPPORT_URL) |
legal.privacyUrl / legal.termsUrl | -c privacyUrl / -c termsUrl, https (env PRIVACY_URL / TERMS_URL). Not set (owner, 2026-12-02): legal stays {} and support.url is absent until URLs are supplied |
retention | Constants in code: reportFilesDays 90, signInRecordsDays 1 (days a sign-in record is kept after its refresh token expires; was 90 before issue #29, 2026-11-12, not deployed), plantDraftsDays 30, workOrderDraftsDays 30, accessLogDays null (no automatic expiry). Telemetry retention belongs to the TCP side |
status | { state, message?, updatedAt? } from one DynamoDB item, PLATFORM/STATUS, written by hand. See Platform status below |
Platform status
status.state is one of three values (PlatformStatusState in packages/core/src/schemas.ts):
state | Meaning |
|---|---|
OPERATIONAL | Default. Also returned when the item is absent, unreadable, or holds any other state |
DEGRADED | An operator has marked the platform as partly impaired |
MAINTENANCE | An operator has marked planned maintenance |
messageis optional, trimmed, and cut to 500 characters.updatedAtis optional and passed through as stored. When the storedstateis not one of the three values, both are dropped.- It is not a health check. The value is whatever an operator last wrote out of band
(Operations). Nothing in this service writes it, and no probe or CloudWatch alarm changes it,
so it stays
OPERATIONALduring an outage unless someone updates it. Each warm Lambda caches it for at most 60 s, and a read failure is reported asOPERATIONAL(logged), not as an error. - Who updates it, and when, is not defined yet. That is an open owner decision, as is whether real health checks should ever drive it.
- Clients must tolerate new
statevalues; treat an unknown one likeDEGRADED. A suitable display is green forOPERATIONAL, a warning colour forDEGRADEDandMAINTENANCE, withmessageas the tooltip.
An optional field is omitted when the stage does not set its context key. Nothing is invented. Synth fails on a malformed value: a URL that is not https, any value over 200 characters, a bad email address, a bad timestamp or a bad commit hash.