API conventions & planned inventory
:::caution Planned — not implemented
This page summarises the proposed API rules, endpoint inventory and
error taxonomy from the cse-http-be blueprint
(docs/blueprint/04-api-design.md, 06-errors-and-edge-cases.md) and ADR
0010. Only the routes listed on the API reference
exist today; everything marked N below is not implemented, and rules marked
(new) do not apply to the deployed API yet. Per-endpoint contracts will
live in each feature's specs/00N-*/contracts/http-api.md in cse-http-be.
:::
Consistency rules
Existing conventions (all routes under /v1/, camelCase JSON, ISO-8601 UTC,
ULIDs, stable error codes, {items, nextCursor} lists capped at 50) are
kept. New rules are marked (new).
| Topic | Rule |
|---|
| Versioning | Breaking change → new route or /v2/ for that resource, never silently. Error codes never change meaning |
| URL naming | Plural kebab-case nouns (/v1/work-orders/{workOrderId}); path params camelCase with Id suffix; nesting at most one level for true containment |
| Actions (new) | Non-field state transitions use a colon verb: POST /v1/plants/{plantId}:archive, POST /v1/commands/{id}:approve |
| Methods | GET read · POST create/action · PATCH partial update (.strict(), null clears a field) · PUT full replace of a singleton sub-resource · DELETE remove |
| Screen endpoints | One call per screen load for HTTP-owned data (e.g. GET /v1/plants/{plantId}/workspace). Telemetry is never embedded; the client joins TCP data by id |
| Content type (new) | Content-Type: application/json required on bodies (415 UNSUPPORTED_MEDIA_TYPE); JSON bodies capped at 256 KB (413 PAYLOAD_TOO_LARGE) |
| IDs and codes (new) | ULIDs are canonical; display codes are a separate read-only code field; GET /v1/lookup?code= resolves one |
| Dates, money, quantities | …On fields are YYYY-MM-DD in the plant timezone; money is { amount, currency } in major units; one base unit per quantity named in the field (pvCapacityKwp) |
| Enums | UPPER_SNAKE; closed sets; responses may gain values — clients treat unknown values as "other" |
| Pagination (new behaviour) | limit 1–50 (default 25) + opaque cursor. A page may be short while nextCursor is present. Cursors are bound to the query (filters + sort hashed in, HMAC-protected); malformed, tampered or foreign cursor → 400 INVALID_CURSOR — replaces today's silent restart. No page numbers |
| Totals | Not returned by list endpoints; counts come from summary/screen endpoints fed by facet counters, flagged approximate: true when they may lag |
| Filtering (new) | Params named after the field; repeat = OR within a field, AND across fields; …Min/…Max, …From/…To. Unknown filter param → 400 VALIDATION_FAILED, never ignored |
| Sorting (new) | ?sort=name / ?sort=-createdAt; allowed values per endpoint; anything else → 400 with details.allowed |
| Search (new) | ?q= 2–64 chars, per-word prefix; GET /v1/search/suggestions?q=&types= → { items: [{ type, id, label, matchedField }] } |
| Concurrency (new) | Versioned resources: responses carry ETag: "<version>" and version; mutations need If-Match (428 PRECONDITION_REQUIRED if missing, 409 VERSION_CONFLICT if stale). Legacy mobile routes keep working without it |
| Idempotency (new) | Idempotency-Key (1–128 chars, [A-Za-z0-9_-]) on POST creates/actions, required where listed. Stored 24 h; a replay returns the original status + body with Idempotent-Replayed: true; same key + different body → 422 IDEMPOTENCY_KEY_REUSED; same key in flight → 409 IDEMPOTENCY_IN_PROGRESS |
| Async (new) | Long work returns 202 Accepted + the job/command resource and a Location header |
| Org context (new) | Web requests send X-Org-Id; it selects, never grants. Missing where required → 400 ORG_CONTEXT_REQUIRED |
| Tracing (new) | Optional X-Correlation-Id (≤ 64 chars) echoed back; X-Request-Id always returned |
| Errors (new field) | { "error": { "code", "message", "details"?, "requestId" } } — requestId is additive |
| Rate limits (new) | 429 RATE_LIMITED + Retry-After. Planned per-user limits include invitations 50/day/org, command requests 60/min/user, report generation 20/h/org |
| Caching (new) | Cache-Control: no-store on authenticated responses; /v1/catalog/* private, max-age=300 + ETag |
| Bulk (new) | POST /v1/<collection>:bulk-<verb> with ids (≤ 200) or a filter; 202 + job, or 200 with per-item { id, ok, error? } for ≤ 50 ids. Never silently partial |
| CORS (new) | Per-stage allow-list of web-console origins only; allowed headers Authorization, Content-Type, Idempotency-Key, If-Match, X-Org-Id, X-Correlation-Id |
Standard shapes — illustrative example:
// list
{ "items": [ /* … */ ], "nextCursor": "eyJ…" }
// screen endpoint — viewer.capabilities gates the UI; the server re-checks every action
{ "plant": { /* … */ }, "viewer": { "capabilities": ["plant.edit"], "levels": { "plants": "FULL" } }, "counts": { /* … */ } }
// async
{ "commandId": "01J…", "status": "QUEUED", "links": { "self": "/v1/commands/01J…" } }
// error
{ "error": { "code": "VERSION_CONFLICT", "message": "The plant was changed by someone else.", "details": { "currentVersion": 8 }, "requestId": "…" } }
Planned API inventory
Status: E exists unchanged · C exists, planned change · N new
(not implemented). Idem: R Idempotency-Key required · O optional ·
N naturally idempotent. AuthZ is "category ≥ level" on the relevant
plant(s)/org (see Tenancy & access). Every route
carries the Cognito authorizer except A11 and C14, which are
explicitly public.
Totals: 7 existing routes (5 changed) and ~150 new operations across ~95
paths.
A — Platform, identity, context (002 / 003 / 008 / 010)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| A01 | GET /v1/me | Adds memberships[], default activeOrgId, MFA state, preferences summary (additive) | self | — | C |
| A02 | PUT /v1/me/selected-plant | Mobile last-selected plant | plants ≥ VIEW | N | C |
| A03 | GET /v1/me/context?orgId= | Shell bootstrap: allowed modules, levels per category, badges | member | — | N |
| A04 | GET · PUT /v1/me/preferences | Theme, density, landing, units, personal notification prefs | self | N | N |
| A05 | PATCH /v1/me/profile | Name, job title (phone change removed, OQ-11) | self | — | N |
| A06 | GET /v1/me/sessions | Informational sign-in records | self | — | N |
| A07 | POST /v1/me/sessions:end-all | GlobalSignOut + tokensValidAfter | self | O | N |
| A08 | GET /v1/me/favorites · PUT/DELETE …/{type}/{id} | Favourites / watchlist | entity VIEW | N | N |
| A09 | POST /v1/me/push-tokens · DELETE …/{tokenId} | Push token registration | self | O | N |
| A10 | POST /v1/realtime/tickets | Signed WS ticket | member | — | N |
| A11 | GET /v1/realtime/jwks public | Ticket verification keys for TCP | public | — | N |
| A12 | GET /v1/search/suggestions | Global search across permitted collections | per type | — | N |
| A13 | GET /v1/lookup?code= | Resolve a display code to {type, id} | entity VIEW | — | N |
| A14 | GET /v1/catalog/{name} | Static vocabularies | any | — | N |
B — Organisations, team and access (003)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| B01 | GET · PATCH /v1/orgs/{orgId} | Org + business profile, localisation, branding | settings VIEW / EDIT | — | N |
| B02 | GET /v1/orgs/{orgId}/members | People table (status, role, department, q) | team ≥ VIEW | — | N |
| B03 | GET …/members/summary | Tiles and department cards | team ≥ VIEW | — | N |
| B04 | GET …/members/{sub} | Member drawer | team ≥ VIEW | — | N |
| B05 | PATCH …/members/{sub} | Role, scope, department, mfaRequired | team ≥ MANAGE | — | N |
| B06 | POST …/members/{sub}:suspend · :restore · :end-sessions · :reset-mfa | Lifecycle actions | team ≥ MANAGE | O | N |
| B07 | POST …/members:bulk-assign-scope | One scope → many members | team ≥ MANAGE | R | N |
| B08 | /v1/orgs/{orgId}/roles CRUD | Roles + matrix (system roles read-only) | team ≥ VIEW / FULL | R | N |
| B09 | /v1/orgs/{orgId}/departments CRUD | Departments | team ≥ VIEW / MANAGE | R | N |
| B10 | GET …/scopes/summary | Scope kinds with member counts | team ≥ VIEW | — | N |
| B11 | /v1/orgs/{orgId}/invitations (create, list, :resend, delete) | Internal invites (in-app only, no email — ADR 0027) | team ≥ MANAGE | R | N |
| B12 | POST /v1/invitations/{token}:accept | Accept an invite (email must match) | invitee | O | N |
| B13 | /v1/orgs/{orgId}/shares CRUD | External access | customers ≥ MANAGE | R | N |
| B14 | GET …/access-log | Append-only access-change log | team ≥ VIEW | — | N |
| B15 | POST /v1/plants/{plantId}/access-requests · list · :approve · :reject | Installer asks, customer/operator approves | plants ≥ EDIT / approver | R | N |
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| C01 | GET /v1/plants | Mobile unchanged; with X-Org-Id adds filters (lifecycle, type, customer, installer, tag, region, country, capacity, created range, q) and sort name, -createdAt, code | plants ≥ VIEW | — | C |
| C02 | GET /v1/plants/summary | Facet counts for strip & drawer | plants ≥ VIEW | — | N |
| C03 | GET /v1/plants/geo | Map mode, pages of 1,000 | plants ≥ VIEW | — | N |
| C04 | POST /v1/plants | Mobile body unchanged; web body v2 (customer, installer, tags, tariff v2, commissioning, expected yield) — fixes KI-21 | plants ≥ EDIT | R (web) / O (mobile) | C |
| C05 | GET /v1/plants/{plantId} | Adds code, customer, installer, tags, lifecycle, version, viewer | plants ≥ VIEW | — | C |
| C06 | GET /v1/plants/{plantId}/workspace | Workspace screen endpoint | plants ≥ VIEW | — | N |
| C07 | PATCH /v1/plants/{plantId} | Edit (If-Match); updates denormalised copies in the same transaction | plants ≥ EDIT | — | N |
| C08 | PUT …/settings/alert-rules | Plant alert rules → published to TCP | alerts ≥ MANAGE | N | N |
| C09 | PUT …/settings/tariff | Tariff | plants ≥ EDIT | N | N |
| C10 | POST …:archive · :restore | Lifecycle | plants ≥ MANAGE | O | N |
| C11 | DELETE /v1/plants/{plantId} | Delete saga for organisation-managed plants. The route already exists for the owner's hard delete of mobile plants (Plants API) | plant.delete (Crown) | R | C |
| C12 | PUT/DELETE …/tags/{tagId} · POST /v1/plants:bulk-tag | Tagging (impact logged) | plants ≥ EDIT | N / R | N |
| C13 | POST …/share-links · DELETE …/{linkId} | Public read-only link (OQ-06) | plants ≥ EDIT | R | N |
| C14 | GET /v1/share-links/{token} public | Public dashboard metadata | token | — | N |
| C15 | /v1/plant-drafts CRUD + :submit | Save as draft | self | R | N |
| C16 | /v1/orgs/{orgId}/saved-views CRUD | Personal / team saved views | screen VIEW; team views EDIT | R | N |
| C17 | /v1/orgs/{orgId}/customers CRUD + :close | Customers | customers ≥ VIEW / EDIT / MANAGE | R | N |
| C18 | GET …/customers/{customerOrgId}/overview | Customer drawer (HTTP tabs) | customers ≥ VIEW | — | N |
| C19 | /v1/orgs/{orgId}/partners CRUD | Partner businesses | customers ≥ VIEW / MANAGE | R | N |
| C20 | /v1/orgs/{orgId}/tags CRUD + …/dependents | Tags (system region tags locked) | plants ≥ VIEW / settings ≥ EDIT | R | N |
| C21 | GET /v1/dashboard | Fleet dashboard HTTP part (counts, attention items); KPIs from TCP | plants ≥ VIEW | — | N |
| C22 | GET /v1/me/work-queue | Top-bar work queue (HTTP items) | member | — | N |
D — Device registry (005)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| D01 | GET /v1/plants/{plantId}/devices | Mobile shape kept; adds type, parentDeviceId, registrationState, bindingState | devices ≥ VIEW | — | C |
| D02 | POST /v1/plants/{plantId}/devices | Mobile claim — fixes KI-8/KI-9 via a serial guard | devices ≥ EDIT | O | C |
| D03 | GET /v1/orgs/{orgId}/devices | Inventory table | devices ≥ VIEW | — | N |
| D04 | GET …/devices/summary | 7-tile strip + type counts | devices ≥ VIEW | — | N |
| D05 | GET /v1/devices/{deviceId} | Device detail (registry facts, parent, children, observed snapshot) | devices ≥ VIEW | — | N |
| D06 | GET /v1/plants/{plantId}/topology | Plant → loggers → hosted devices | devices ≥ VIEW | — | N |
| D07 | POST /v1/orgs/{orgId}/devices | Register one device | devices ≥ EDIT | R | N |
| D08 | POST /v1/devices:verify-serial | Wizard check, no side effects | devices ≥ EDIT | — | N |
| D09 | PATCH /v1/devices/{deviceId} | Label, model correction, country | devices ≥ EDIT | — | N |
| D10 | POST …:bind · :unbind · :set-parent | Binding | devices ≥ EDIT | O | N |
| D11 | POST …:verify · :reject | Crown verification | PLATFORM devices ≥ MANAGE | O | N |
| D12 | DELETE /v1/devices/{deviceId} | Remove (saga) | device.remove (Crown) | R | N |
| D13 | …/transfers (create, list, :accept, :decline, :cancel) | Org-to-org transfer | devices ≥ MANAGE (both sides) | R | N |
| D14 | /v1/orgs/{orgId}/device-imports (upload, :validate, rows, :commit, error report) | Batch import (chunked, resumable) | devices ≥ EDIT | R | N |
| D15 | GET /v1/catalog/device-models · POST/PATCH /v1/device-models/{modelId} | Product catalog | any / PLATFORM devices FULL | R | N |
| D16 | POST /v1/manufacturing-records:import | Manufacturing records (B-07) | PLATFORM devices FULL | R | N |
E — Service / O&M (006)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| E01 | GET /v1/orgs/{orgId}/work-orders | Work-order table; sort queue, -createdAt, dueAt | service ≥ VIEW | — | N |
| E02 | GET …/work-orders/summary | Metric strip + technician workload | service ≥ VIEW | — | N |
| E03 | POST /v1/work-orders | Create (from service, plant, device or alert) | service ≥ EDIT | R | N |
| E04 | GET /v1/work-orders/{id} | Drawer (audience-redacted) | service ≥ VIEW | — | N |
| E05 | PATCH /v1/work-orders/{id} | Edit (If-Match) | service ≥ EDIT | — | N |
| E06 | POST …:assign · :schedule · :start · :wait · :resume · :complete · :cancel · :reopen | State machine | service ≥ EDIT (cancel/reopen ≥ MANAGE) | O | N |
| E07 | POST /v1/work-orders:bulk-assign · :bulk-reschedule · :bulk-cancel | Bulk | service ≥ MANAGE | R | N |
| E08 | POST · GET …/events | Timeline / progress notes | service ≥ EDIT / VIEW | R | N |
| E09 | …/attachments (presigned PUT/GET, delete) | Photos, files, signature | service ≥ EDIT / VIEW | R | N |
| E10 | GET /v1/plants/{plantId}/service | Workspace Service tab | service ≥ VIEW | — | N |
| E11 | /v1/orgs/{orgId}/maintenance-plans CRUD + :pause · :resume · :run-now | Plans | service ≥ VIEW / MANAGE | R | N |
| E12 | GET …/maintenance-history | History table + tiles | service ≥ VIEW | — | N |
| E13 | …/technicians · teams CRUD | Roster, workload | service ≥ VIEW / MANAGE | R | N |
F — Device operations / Engineering (007)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| F01 | GET /v1/catalog/commands?modelId= | Command catalog with required level, risk, params schema, locked reason | commands ≥ VIEW | — | N |
| F02 | POST /v1/commands | Request a command → 202 (see Command lifecycle) | commands ≥ required level; platformOnly | R | N |
| F03 | GET /v1/commands/{id} | Status + operation-log detail | commands ≥ VIEW | — | N |
| F04 | POST …:approve · :reject · :cancel | Second-person approval / cancel | commands ≥ MANAGE, different sub | O | N |
| F05 | GET /v1/orgs/{orgId}/operation-log · …:export | Append-only operation log + export | commands ≥ VIEW / audit.export | — | N |
| F06 | GET /v1/devices/{deviceId}/commands | Device Commands tab | commands ≥ VIEW | — | N |
| F07 | /v1/bulk-tasks (create, list, detail, devices, :approve, :stop) | Bulk firmware / config / command / assign | per kind | R | N |
| F08 | POST /v1/bulk-tasks:preview | Eligibility preview | per kind | — | N |
| F09 | /v1/firmware-packages (create → presigned upload, :approve, :release, :withdraw) | Firmware library | firmware ≥ VIEW / firmware.approve | R | N |
| F10 | /v1/device-files (presigned) | Device files with visibility | devices ≥ VIEW / FULL | R | N |
G — Notifications (008)
Alert lists, drawer and acknowledge / assign / resolve are TCP WebSocket
messages (TCP-REQ-09) — there are no HTTP alert routes.
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| G01 | /v1/orgs/{orgId}/notification-rules CRUD | Rules (critical rule locked) | alerts ≥ MANAGE | R | N |
| G02 | GET · PUT …/notification-settings | Channels, grouping window, digest, quiet hours | alerts ≥ FULL | N | N |
| G03 | POST /v1/notification-rules:preview | Plain-language preview + recipient count | alerts ≥ MANAGE | — | N |
| G04 | GET …/notification-deliveries | Delivery log (support) | alerts ≥ MANAGE | — | N |
| G05 | GET /v1/alerts/{alertId}/work-orders | Work orders linked to a TCP alert | service ≥ VIEW | — | N |
H — Reports (009)
| # | Method · Path | Purpose | AuthZ | Idem | Status |
|---|
| H01 | GET /v1/orgs/{orgId}/reports · GET/DELETE /v1/reports/{id} | Library + drawer | reports ≥ VIEW / MANAGE | — | N |
| H02 | POST /v1/reports → 202 | Generate → TCP render job | reports ≥ EDIT on every plant in scope | R | N |
| H03 | POST …:regenerate · GET …/download (presigned ≤ 15 min) | Regenerate / download | reports ≥ EDIT / VIEW | R | N |
| H04 | GET …/report-templates · GET /v1/report-templates/{id} | Templates by audience | reports ≥ VIEW | — | N |
| H05 | /v1/orgs/{orgId}/report-schedules CRUD + :pause · :resume · :run-now | Schedules | reports ≥ MANAGE | R | N |
| H06 | POST /v1/plants/{plantId}/reports | "Download plant report" shortcut → H02 | reports ≥ EDIT | R | N |
Error taxonomy
Envelope: { "error": { "code", "message", "details"?, "requestId" } }.
message is safe English — clients show their own localised copy keyed by
code. Never in a body: stack traces, AWS error names, table/key names,
ARNs, other tenants' ids, or whether an account exists. Gateway-generated
responses (401 {"message":"Unauthorized"}, unknown-route 404, throttle /
timeout 5xx) stay outside the envelope, as today — see
API overview → Gateway-generated responses.
Retry: N never · Y as-is (same Idempotency-Key) · A after user action ·
B with backoff. Status: exists = in the deployed API today;
planned = not implemented.
| HTTP | code | When | Retry | Status |
|---|
| 400 | MALFORMED_REQUEST | Body not valid JSON / not an object (fixes KI-7) | N | planned |
| 422 | VALIDATION_FAILED | Field errors; every 422 also logs a WARN validation_failed line with field paths/codes (no values) | A | exists |
| 400 | VALIDATION_FAILED | Unknown filter / sort / query param | N | exists (code); planned use |
| 400 | INVALID_CURSOR | Malformed, tampered or cross-query cursor | A | planned |
| 400 | ORG_CONTEXT_REQUIRED | X-Org-Id missing where required | A | planned |
| 413 | PAYLOAD_TOO_LARGE | JSON body > 256 KB | N | planned |
| 415 | UNSUPPORTED_MEDIA_TYPE | Not application/json | N | planned |
| 401 | UNAUTHENTICATED | Route missing its authorizer (misconfiguration — pages on-call) | N | exists |
| 401 | SESSION_REVOKED | Token issued before tokensValidAfter (end sessions / suspend) | A | planned |
| 403 | FORBIDDEN | Lacks the level; may carry details.deniedPlantIds | N | exists |
| 403 | MFA_REQUIRED | Org context requires TOTP — reserved, not emitted since 2026-11-11 | A | retired |
| 403 | ACCOUNT_SUSPENDED | Membership suspended in this org | N | planned |
| 403 | SELF_APPROVAL_FORBIDDEN | Approver = requester | A | removed (ADR 0012) — commands belong to TCP |
| 422 | PERIOD_OUTSIDE_RETENTION | Report period starts before the retention floor; details.floor (YYYY-MM-DD), details.granularity (DAILY or ALERT_HISTORY; feature 009) | A | only when an optional floor (REPORT_RETENTION_DAILY_DAYS/REPORT_RETENTION_ALERT_DAYS) is set; no stage sets one, so it is off |
| 404 | NOT_FOUND | Missing or not visible (non-disclosure) | N | exists |
| 410 | GONE | Deleted / DELETING resource | N | planned |
| 409 | ALREADY_EXISTS | Unique value taken (serial, code, member email, tag label) | A | planned |
| 409 | CONFLICT | Legacy generic conflict; unattributable transaction cancel | A / B | exists |
| 409 | VERSION_CONFLICT | Stale If-Match; details.currentVersion | A | planned |
| 428 | PRECONDITION_REQUIRED | If-Match missing | N | planned |
| 409 | INVALID_STATE | Transition not allowed from the current state | A | planned |
| 409 | DUPLICATE_COMMAND_PENDING | Identical non-terminal command exists | A | removed (ADR 0012) — commands belong to TCP |
| 409 | APPROVAL_REQUIRED | Needs a second person | A | planned |
| 422 | IDEMPOTENCY_KEY_REUSED | Same key, different body | N | planned |
| 409 | IDEMPOTENCY_IN_PROGRESS | Same key still in flight | B | planned |
| 422 | PRECONDITION_FAILED | Static command precondition fails (HTTP-side) | A | removed (ADR 0012) — commands belong to TCP |
| 422 | SCOPE_TOO_BROAD | Too many scope targets for listing | A | planned |
| 422 | LIMIT_EXCEEDED | Quota / limit (e.g. 200 bulk ids) | A | planned |
| 422 | UNSUPPORTED_OPERATION | Model can't do the command / feature off | N | planned |
| 429 | RATE_LIMITED | Rate limit, with Retry-After | B | planned |
| 503 | DEPENDENCY_UNAVAILABLE | DynamoDB throttle/5xx, SNS, S3, KMS, SES failure (today these surface as INTERNAL) | B | planned |
| 500 | INTERNAL | Anything else | B once | exists |
Device-side outcomes are not HTTP errors: a command is accepted with
202 and later reaches TIMED_OUT / FAILED with a reasonCode
(DEVICE_OFFLINE, NO_RESPONSE, DEVICE_REJECTED, READBACK_MISMATCH,
PRECONDITION_FAILED_LIVE, DEADLINE_PASSED, BUSY). Bulk partial failure
is reported per item, with job status PARTIALLY_SUCCEEDED. There is no
HTTP error for "TCP unavailable" — HTTP never calls TCP; the client surfaces
WebSocket loss itself.