Skip to main content

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).

TopicRule
VersioningBreaking change → new route or /v2/ for that resource, never silently. Error codes never change meaning
URL namingPlural 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
MethodsGET read · POST create/action · PATCH partial update (.strict(), null clears a field) · PUT full replace of a singleton sub-resource · DELETE remove
Screen endpointsOne 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)
EnumsUPPER_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
TotalsNot 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 · PathPurposeAuthZIdemStatus
A01GET /v1/meAdds memberships[], default activeOrgId, MFA state, preferences summary (additive)self—C
A02PUT /v1/me/selected-plantMobile last-selected plantplants ≥ VIEWNC
A03GET /v1/me/context?orgId=Shell bootstrap: allowed modules, levels per category, badgesmember—N
A04GET · PUT /v1/me/preferencesTheme, density, landing, units, personal notification prefsselfNN
A05PATCH /v1/me/profileName, job title (phone change removed, OQ-11)self—N
A06GET /v1/me/sessionsInformational sign-in recordsself—N
A07POST /v1/me/sessions:end-allGlobalSignOut + tokensValidAfterselfON
A08GET /v1/me/favorites · PUT/DELETE …/{type}/{id}Favourites / watchlistentity VIEWNN
A09POST /v1/me/push-tokens · DELETE …/{tokenId}Push token registrationselfON
A10POST /v1/realtime/ticketsSigned WS ticketmember—N
A11GET /v1/realtime/jwks publicTicket verification keys for TCPpublic—N
A12GET /v1/search/suggestionsGlobal search across permitted collectionsper type—N
A13GET /v1/lookup?code=Resolve a display code to {type, id}entity VIEW—N
A14GET /v1/catalog/{name}Static vocabulariesany—N

B — Organisations, team and access (003)​

#Method · PathPurposeAuthZIdemStatus
B01GET · PATCH /v1/orgs/{orgId}Org + business profile, localisation, brandingsettings VIEW / EDIT—N
B02GET /v1/orgs/{orgId}/membersPeople table (status, role, department, q)team ≥ VIEW—N
B03GET …/members/summaryTiles and department cardsteam ≥ VIEW—N
B04GET …/members/{sub}Member drawerteam ≥ VIEW—N
B05PATCH …/members/{sub}Role, scope, department, mfaRequiredteam ≥ MANAGE—N
B06POST …/members/{sub}:suspend · :restore · :end-sessions · :reset-mfaLifecycle actionsteam ≥ MANAGEON
B07POST …/members:bulk-assign-scopeOne scope → many membersteam ≥ MANAGERN
B08/v1/orgs/{orgId}/roles CRUDRoles + matrix (system roles read-only)team ≥ VIEW / FULLRN
B09/v1/orgs/{orgId}/departments CRUDDepartmentsteam ≥ VIEW / MANAGERN
B10GET …/scopes/summaryScope kinds with member countsteam ≥ VIEW—N
B11/v1/orgs/{orgId}/invitations (create, list, :resend, delete)Internal invites (in-app only, no email — ADR 0027)team ≥ MANAGERN
B12POST /v1/invitations/{token}:acceptAccept an invite (email must match)inviteeON
B13/v1/orgs/{orgId}/shares CRUDExternal accesscustomers ≥ MANAGERN
B14GET …/access-logAppend-only access-change logteam ≥ VIEW—N
B15POST /v1/plants/{plantId}/access-requests · list · :approve · :rejectInstaller asks, customer/operator approvesplants ≥ EDIT / approverRN

C — Plants, customers, partners, tags (004)​

#Method · PathPurposeAuthZIdemStatus
C01GET /v1/plantsMobile unchanged; with X-Org-Id adds filters (lifecycle, type, customer, installer, tag, region, country, capacity, created range, q) and sort name, -createdAt, codeplants ≥ VIEW—C
C02GET /v1/plants/summaryFacet counts for strip & drawerplants ≥ VIEW—N
C03GET /v1/plants/geoMap mode, pages of 1,000plants ≥ VIEW—N
C04POST /v1/plantsMobile body unchanged; web body v2 (customer, installer, tags, tariff v2, commissioning, expected yield) — fixes KI-21plants ≥ EDITR (web) / O (mobile)C
C05GET /v1/plants/{plantId}Adds code, customer, installer, tags, lifecycle, version, viewerplants ≥ VIEW—C
C06GET /v1/plants/{plantId}/workspaceWorkspace screen endpointplants ≥ VIEW—N
C07PATCH /v1/plants/{plantId}Edit (If-Match); updates denormalised copies in the same transactionplants ≥ EDIT—N
C08PUT …/settings/alert-rulesPlant alert rules → published to TCPalerts ≥ MANAGENN
C09PUT …/settings/tariffTariffplants ≥ EDITNN
C10POST …:archive · :restoreLifecycleplants ≥ MANAGEON
C11DELETE /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)RC
C12PUT/DELETE …/tags/{tagId} · POST /v1/plants:bulk-tagTagging (impact logged)plants ≥ EDITN / RN
C13POST …/share-links · DELETE …/{linkId}Public read-only link (OQ-06)plants ≥ EDITRN
C14GET /v1/share-links/{token} publicPublic dashboard metadatatoken—N
C15/v1/plant-drafts CRUD + :submitSave as draftselfRN
C16/v1/orgs/{orgId}/saved-views CRUDPersonal / team saved viewsscreen VIEW; team views EDITRN
C17/v1/orgs/{orgId}/customers CRUD + :closeCustomerscustomers ≥ VIEW / EDIT / MANAGERN
C18GET …/customers/{customerOrgId}/overviewCustomer drawer (HTTP tabs)customers ≥ VIEW—N
C19/v1/orgs/{orgId}/partners CRUDPartner businessescustomers ≥ VIEW / MANAGERN
C20/v1/orgs/{orgId}/tags CRUD + …/dependentsTags (system region tags locked)plants ≥ VIEW / settings ≥ EDITRN
C21GET /v1/dashboardFleet dashboard HTTP part (counts, attention items); KPIs from TCPplants ≥ VIEW—N
C22GET /v1/me/work-queueTop-bar work queue (HTTP items)member—N

D — Device registry (005)​

#Method · PathPurposeAuthZIdemStatus
D01GET /v1/plants/{plantId}/devicesMobile shape kept; adds type, parentDeviceId, registrationState, bindingStatedevices ≥ VIEW—C
D02POST /v1/plants/{plantId}/devicesMobile claim — fixes KI-8/KI-9 via a serial guarddevices ≥ EDITOC
D03GET /v1/orgs/{orgId}/devicesInventory tabledevices ≥ VIEW—N
D04GET …/devices/summary7-tile strip + type countsdevices ≥ VIEW—N
D05GET /v1/devices/{deviceId}Device detail (registry facts, parent, children, observed snapshot)devices ≥ VIEW—N
D06GET /v1/plants/{plantId}/topologyPlant → loggers → hosted devicesdevices ≥ VIEW—N
D07POST /v1/orgs/{orgId}/devicesRegister one devicedevices ≥ EDITRN
D08POST /v1/devices:verify-serialWizard check, no side effectsdevices ≥ EDIT—N
D09PATCH /v1/devices/{deviceId}Label, model correction, countrydevices ≥ EDIT—N
D10POST …:bind · :unbind · :set-parentBindingdevices ≥ EDITON
D11POST …:verify · :rejectCrown verificationPLATFORM devices ≥ MANAGEON
D12DELETE /v1/devices/{deviceId}Remove (saga)device.remove (Crown)RN
D13…/transfers (create, list, :accept, :decline, :cancel)Org-to-org transferdevices ≥ MANAGE (both sides)RN
D14/v1/orgs/{orgId}/device-imports (upload, :validate, rows, :commit, error report)Batch import (chunked, resumable)devices ≥ EDITRN
D15GET /v1/catalog/device-models · POST/PATCH /v1/device-models/{modelId}Product catalogany / PLATFORM devices FULLRN
D16POST /v1/manufacturing-records:importManufacturing records (B-07)PLATFORM devices FULLRN

E — Service / O&M (006)​

#Method · PathPurposeAuthZIdemStatus
E01GET /v1/orgs/{orgId}/work-ordersWork-order table; sort queue, -createdAt, dueAtservice ≥ VIEW—N
E02GET …/work-orders/summaryMetric strip + technician workloadservice ≥ VIEW—N
E03POST /v1/work-ordersCreate (from service, plant, device or alert)service ≥ EDITRN
E04GET /v1/work-orders/{id}Drawer (audience-redacted)service ≥ VIEW—N
E05PATCH /v1/work-orders/{id}Edit (If-Match)service ≥ EDIT—N
E06POST …:assign · :schedule · :start · :wait · :resume · :complete · :cancel · :reopenState machineservice ≥ EDIT (cancel/reopen ≥ MANAGE)ON
E07POST /v1/work-orders:bulk-assign · :bulk-reschedule · :bulk-cancelBulkservice ≥ MANAGERN
E08POST · GET …/eventsTimeline / progress notesservice ≥ EDIT / VIEWRN
E09…/attachments (presigned PUT/GET, delete)Photos, files, signatureservice ≥ EDIT / VIEWRN
E10GET /v1/plants/{plantId}/serviceWorkspace Service tabservice ≥ VIEW—N
E11/v1/orgs/{orgId}/maintenance-plans CRUD + :pause · :resume · :run-nowPlansservice ≥ VIEW / MANAGERN
E12GET …/maintenance-historyHistory table + tilesservice ≥ VIEW—N
E13…/technicians · teams CRUDRoster, workloadservice ≥ VIEW / MANAGERN

F — Device operations / Engineering (007)​

#Method · PathPurposeAuthZIdemStatus
F01GET /v1/catalog/commands?modelId=Command catalog with required level, risk, params schema, locked reasoncommands ≥ VIEW—N
F02POST /v1/commandsRequest a command → 202 (see Command lifecycle)commands ≥ required level; platformOnlyRN
F03GET /v1/commands/{id}Status + operation-log detailcommands ≥ VIEW—N
F04POST …:approve · :reject · :cancelSecond-person approval / cancelcommands ≥ MANAGE, different subON
F05GET /v1/orgs/{orgId}/operation-log · …:exportAppend-only operation log + exportcommands ≥ VIEW / audit.export—N
F06GET /v1/devices/{deviceId}/commandsDevice Commands tabcommands ≥ VIEW—N
F07/v1/bulk-tasks (create, list, detail, devices, :approve, :stop)Bulk firmware / config / command / assignper kindRN
F08POST /v1/bulk-tasks:previewEligibility previewper kind—N
F09/v1/firmware-packages (create → presigned upload, :approve, :release, :withdraw)Firmware libraryfirmware ≥ VIEW / firmware.approveRN
F10/v1/device-files (presigned)Device files with visibilitydevices ≥ VIEW / FULLRN

G — Notifications (008)​

Alert lists, drawer and acknowledge / assign / resolve are TCP WebSocket messages (TCP-REQ-09) — there are no HTTP alert routes.

#Method · PathPurposeAuthZIdemStatus
G01/v1/orgs/{orgId}/notification-rules CRUDRules (critical rule locked)alerts ≥ MANAGERN
G02GET · PUT …/notification-settingsChannels, grouping window, digest, quiet hoursalerts ≥ FULLNN
G03POST /v1/notification-rules:previewPlain-language preview + recipient countalerts ≥ MANAGE—N
G04GET …/notification-deliveriesDelivery log (support)alerts ≥ MANAGE—N
G05GET /v1/alerts/{alertId}/work-ordersWork orders linked to a TCP alertservice ≥ VIEW—N

H — Reports (009)​

#Method · PathPurposeAuthZIdemStatus
H01GET /v1/orgs/{orgId}/reports · GET/DELETE /v1/reports/{id}Library + drawerreports ≥ VIEW / MANAGE—N
H02POST /v1/reports → 202Generate → TCP render jobreports ≥ EDIT on every plant in scopeRN
H03POST …:regenerate · GET …/download (presigned ≤ 15 min)Regenerate / downloadreports ≥ EDIT / VIEWRN
H04GET …/report-templates · GET /v1/report-templates/{id}Templates by audiencereports ≥ VIEW—N
H05/v1/orgs/{orgId}/report-schedules CRUD + :pause · :resume · :run-nowSchedulesreports ≥ MANAGERN
H06POST /v1/plants/{plantId}/reports"Download plant report" shortcut → H02reports ≥ EDITRN

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.

HTTPcodeWhenRetryStatus
400MALFORMED_REQUESTBody not valid JSON / not an object (fixes KI-7)Nplanned
422VALIDATION_FAILEDField errors; every 422 also logs a WARN validation_failed line with field paths/codes (no values)Aexists
400VALIDATION_FAILEDUnknown filter / sort / query paramNexists (code); planned use
400INVALID_CURSORMalformed, tampered or cross-query cursorAplanned
400ORG_CONTEXT_REQUIREDX-Org-Id missing where requiredAplanned
413PAYLOAD_TOO_LARGEJSON body > 256 KBNplanned
415UNSUPPORTED_MEDIA_TYPENot application/jsonNplanned
401UNAUTHENTICATEDRoute missing its authorizer (misconfiguration — pages on-call)Nexists
401SESSION_REVOKEDToken issued before tokensValidAfter (end sessions / suspend)Aplanned
403FORBIDDENLacks the level; may carry details.deniedPlantIdsNexists
403MFA_REQUIREDOrg context requires TOTP — reserved, not emitted since 2026-11-11Aretired
403ACCOUNT_SUSPENDEDMembership suspended in this orgNplanned
403SELF_APPROVAL_FORBIDDENApprover = requesterAremoved (ADR 0012) — commands belong to TCP
422PERIOD_OUTSIDE_RETENTIONReport period starts before the retention floor; details.floor (YYYY-MM-DD), details.granularity (DAILY or ALERT_HISTORY; feature 009)Aonly when an optional floor (REPORT_RETENTION_DAILY_DAYS/REPORT_RETENTION_ALERT_DAYS) is set; no stage sets one, so it is off
404NOT_FOUNDMissing or not visible (non-disclosure)Nexists
410GONEDeleted / DELETING resourceNplanned
409ALREADY_EXISTSUnique value taken (serial, code, member email, tag label)Aplanned
409CONFLICTLegacy generic conflict; unattributable transaction cancelA / Bexists
409VERSION_CONFLICTStale If-Match; details.currentVersionAplanned
428PRECONDITION_REQUIREDIf-Match missingNplanned
409INVALID_STATETransition not allowed from the current stateAplanned
409DUPLICATE_COMMAND_PENDINGIdentical non-terminal command existsAremoved (ADR 0012) — commands belong to TCP
409APPROVAL_REQUIREDNeeds a second personAplanned
422IDEMPOTENCY_KEY_REUSEDSame key, different bodyNplanned
409IDEMPOTENCY_IN_PROGRESSSame key still in flightBplanned
422PRECONDITION_FAILEDStatic command precondition fails (HTTP-side)Aremoved (ADR 0012) — commands belong to TCP
422SCOPE_TOO_BROADToo many scope targets for listingAplanned
422LIMIT_EXCEEDEDQuota / limit (e.g. 200 bulk ids)Aplanned
422UNSUPPORTED_OPERATIONModel can't do the command / feature offNplanned
429RATE_LIMITEDRate limit, with Retry-AfterBplanned
503DEPENDENCY_UNAVAILABLEDynamoDB throttle/5xx, SNS, S3, KMS, SES failure (today these surface as INTERNAL)Bplanned
500INTERNALAnything elseB onceexists

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.