Skip to main content

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.

MethodPathNotes
POST/v1/work-order-draftsCreates a draft. Idempotency-Key is required (428 without it). Returns 201 with Location and ETag
GET/v1/work-order-draftsLists 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 body at most 16 KB. Larger requests return 413 PAYLOAD_TOO_LARGE.
  • Body (WorkOrderDraftBody): every CreateWorkOrderInput field, all optional, with no defaults and no cross-field rules. An unknown key returns 422 VALIDATION_FAILED. lastStep is an integer from 1 to 10.
  • List pages: a short page that still has a nextCursor is normal, because expired drafts and drafts from other orgs are filtered out.
  • Errors: 400 ORG_CONTEXT_REQUIRED (no X-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 (stale If-Match) and 428 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.

MethodPathNotes
GET/v1/me/layoutsReturns 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:

  • 413 when the serialised layout is over 8 KB.
  • 409 VERSION_CONFLICT with details.currentVersion when If-Match is stale.
  • 428 when If-Match is sent but empty.
  • 422 for duplicate column keys or widget ids.

Report schedules and templates (N-39)​

  • recipientNote on a report schedule (create, PATCH and view) is optional, at most 500 characters, trimmed, and may not contain control characters. In PATCH, null or a blank string clears it. It is absent from the view when no note is set. The note is stored and returned only.
  • samplePreviewUrl on a report template is <REPORT_SAMPLES_BASE_URL>/<sampleImage>. It appears only when the stage was synthesised with -c reportSamplesBaseUrl=<https URL>, which sets REPORT_SAMPLES_BASE_URL on the report-templates function. Synth rejects a value that is not https:// 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. :::

RouteNew field / parameterSourceExact?
GET /v1/orgs/{orgId}/customerstotal: customers in the requested status (ACTIVE, CHURNED, or both for ALL)COUNT#customers#status#*, or the PLATFORM#CUSTOMERS shards on the Crown-wide listApproximate
GET /v1/orgs/{orgId}/customerstiles.cities[] = { city, count }: the city filter options (per-org lists only)COUNT#customers#city#<normalised> (counts ACTIVE customers only)Approximate
GET /v1/orgs/{orgId}/customersoperatorOrgId=none: Independent End Users only (personal orgs). Crown-wide list onlyFilterExpression personal = true on the LISTALL#CUSTOMER entries. Pages may be short and still carry a cursorExact rows
GET /v1/orgs/{orgId}/partnerstotalSum of COUNT#partners#status#*Approximate
GET /v1/orgs/{orgId}/tagstotalSum of groupCountsApproximate
GET /v1/orgs/{orgId}/tagsq (2–64 chars): every word must be the start of a word in the labelFiltered 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 qExact
GET /v1/orgs/{orgId}/businessestotalPaged Select: COUNT on GSI2 ORGS#OPERATOR. This small directory never holds personal orgsExact at read time
GET /v1/orgs/{orgId}/membersstatusCounts = { ACTIVE, SUSPENDED, INVITED, total, approximate }. Also sent on the q pathCOUNT#members#status#*. INVITED is the pending-invitation counterApproximate
GET /v1/orgs/{orgId}/membersplantCount on each itemPLANTS = 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 orgApproximate
GET /v1/orgs/{orgId}/reportstotal (not sent with q)COUNT#reports#all#all, the same counter as H01b libraryTotalApproximate
GET /v1/orgs/{orgId}/report-schedulestotalCOUNT#reportSchedules#all#all, the same counter as H01b scheduleCountApproximate
GET /v1/orgs/{orgId}/maintenance-planstotalPaged Select: COUNT on the org's PLAN# slice. Plans are never deletedExact at read time
GET /v1/me/favoritestotalPaged Select: COUNT on the caller's own FAV#<type># slice. It counts stored stars, so it includes favourites the caller can no longer seeExact 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 /departments items already carry memberCount from the COUNT#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 Plants q.
  • Plants favorite=true. It combines with every other filter, including q. It does not combine with sort: that is 400 VALIDATION_FAILED, with details.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 with customers ≥ 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-typed model string. 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 own count stays single-facet.
  • Technicians and installers in service history. GET …/maintenance-history/technicians lists 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 without q (2026-11-25). Share-based callers get queue, createdAt/-createdAt and dueAt only; page 1 says access: shared. queue still 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. Has count and capacityKwp, from per-customer plant sums, and approximate: true.
  • service: available only when the caller has service ≥ VIEW. Has openWorkOrders from the COUNT#WOCUST#OPEN#<c> counter, with approximate: true. lastVisitAt is not filled yet.
  • reports: available only with reports ≥ VIEW. lastDeliveredAt is the readyAt of 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)​

  • lastSignInAt on the member list and member detail is now filled. It holds the member's last sign-in to the product (any org, any app), from USER#<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.
  • granteeLastSignInAt on 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 Admin ERROR, Administrator WARNING, Viewer NEUTRAL). On a custom role the colour is optional, and null in 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).

MethodPathAuthZNotes
POST/v1/orgs/{orgId}/brand-assetssettings ≥ EDITIdempotency-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}:confirmsettings ≥ EDITChecks 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 ≥ VIEWReturns 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, contentType and sizeBytes. PNG and JPEG only, at most 1 MB. SVG is refused (422) because it can carry script.
  • Upload the bytes with the returned headers unchanged. 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. :confirm copies the object to the final key and deletes the upload. Use the download.url (a presigned GET, at most 300 s) from :confirm or GET, never the upload URL.
  • Confirm errors:
    • 409 INVALID_STATE with details.reason OBJECT_MISSING when nothing was uploaded.
    • 422 VALIDATION_FAILED with SIZE_MISMATCH or TYPE_MISMATCH when the object does not match. The staged upload is deleted.
    • 404 for an unknown asset, or one that stayed PENDING for more than 2 days.
  • Business profile: branding.<slot>.assetId in the business-profile PATCH must now name a READY asset of the org for that slot. Otherwise it returns 422 VALIDATION_FAILED with details.reason ASSET_NOT_FOUND, ASSET_NOT_READY or ASSET_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_FOUND when the session is not the caller's, or is unknown.
  • 409 INVALID_STATE with details.reason NO_ORIGIN when the record was never bound to a token. It returns CURRENT_SESSION for the caller's own sign-in; use current:end instead.
  • 409 INVALID_STATE with details.reason CONCURRENT_UPDATE when a racing write wins twice; 404 when the session record disappeared meanwhile.
  • 429 RATE_LIMITED above 10 calls per hour. To end all other sign-ins in one call, use POST /v1/me/sessions:end-others (2026-11-12, see Account settings API).
  • Writes one SESSION_ENDED access-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_jti returns 401 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.

FieldSource
apiVersionAlways 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
retentionConstants 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):

stateMeaning
OPERATIONALDefault. Also returned when the item is absent, unreadable, or holds any other state
DEGRADEDAn operator has marked the platform as partly impaired
MAINTENANCEAn operator has marked planned maintenance
  • message is optional, trimmed, and cut to 500 characters. updatedAt is optional and passed through as stored. When the stored state is 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 OPERATIONAL during an outage unless someone updates it. Each warm Lambda caches it for at most 60 s, and a read failure is reported as OPERATIONAL (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 state values; treat an unknown one like DEGRADED. A suitable display is green for OPERATIONAL, a warning colour for DEGRADED and MAINTENANCE, with message as 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.