Service: work orders (E01–E09)
:::warning Routed; scheduling/queues are opt-in
Every endpoint on this page is implemented and registered as a route in
code (handlers packages/api/src/handlers/service-*.ts, services
packages/core/src/services/work-order-service.ts and
attachment-service.ts). Per the owner's Q27 decision the routes live in
the route-area stack cse-http-be-<stage>-api-service (one
work-orders Lambda family, RouteDef.area: 'service' in lib/routes.ts),
attached to the shared HttpApi. They 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). The attachments
bucket cse-http-be-<stage>-service-files is now defined in DataStack,
and the work-orders family gets SERVICE_FILES_BUCKET plus S3 access to
pending/* and wo/* only. Nothing on this page has been executed
against any stage; every JSON body below is an illustrative example,
derived from the schema/handler code — none is a captured response. The
machine-readable contract is docs/openapi.yaml in cse-http-be.
:::
:::caution Lifecycle v2 (ADR 0023) — deployed on dev, backfill not run yet
This page describes lifecycle v2, the console's "Work Order Lifecycle v2"
request (tickets LC-1 … LC-17), recorded in ADR 0023 in cse-http-be. It is
on main and deployed on dev (batches A, B and C, as the web console
observed on 2026-11-10). Its data backfill has not run yet. Dev is the only
stage (Hard Rule 4).
Two 2026-11-10 follow-up fixes are committed but not deployed yet:
Crown-wide reads returned no rows, and
operatorOrgId answered 403; and E13 now
lists a plant's Installers for Crown staff.
What changes for the console (breaking):
- Statuses are real enum values now: there are 11 (
ACCEPTED,VERIFIED,CLOSED,REJECTEDandREOPENEDare new). :startneeds:acceptfirst.- The Installer loses
:wait/:resumeand gets:request-hold. Holding and resuming are Business actions. - The Business must
:verify(new) before:close. It can send a completion back with:reject-completion(new). - A decline goes to
REJECTED, notNEW. COMPLETEDis no longer the end. The order closes, and releases its alert, atCLOSED.:reopenworks only fromCLOSED/CANCELLEDand lands inREOPENED, unassigned.- Reassigning after acceptance goes back to
ASSIGNED, and needs areason. - Hold reasons are renamed. The old input values are accepted for one release.
- E02
metrics.inProgresscountsIN_PROGRESSonly. On Hold isonHold. - The service-request routes are removed (below).
After the deploy, a human runs the lifecycle v2 backfill once to migrate existing orders. Until it runs, older orders are read in v2 terms (below). :::
Feature 006 (Service / O&M) gives operators a work-order queue per
operator org. Source of truth: specs/006-service-om/contracts/http-api.md
as amended by ADR 0019 and ADR 0023, the Zod schemas in
packages/core/src/schemas.ts (search for WorkOrder), the transition table in
packages/core/src/service/work-order-state.ts, and the code cited per
section. Types are listed on
Types & schemas.
Common rules
| Topic | Rule |
|---|---|
| Auth | Cognito JWT (HttpUserPoolAuthorizer) on every route; none is public |
| Request headers | Authorization (required); Content-Type: application/json on bodies (else 415); X-Org-Id optional selector — never widens access; X-Correlation-Id optional |
| Optimistic concurrency | If-Match: "<version>" on every mutation of an existing order (missing → 428 PRECONDITION_REQUIRED, stale → 409 VERSION_CONFLICT with details.currentVersion). Attachments are unversioned and need no If-Match |
| Idempotency | Idempotency-Key (1–128 [A-Za-z0-9_-]). R = required (missing → 428, details.header), O = optional. Replays return the same body with Idempotent-Replayed: true; same key with a different body → 422 IDEMPOTENCY_KEY_REUSED; concurrent same key → 409 IDEMPOTENCY_IN_PROGRESS |
| Response headers | X-Request-Id; ETag: "<version>" on single orders; Cache-Control: no-store |
| Non-disclosure | No access path to the plant/order → 404 NOT_FOUND; visible but level too low → 403 FORBIDDEN |
| Levels | service ≥ L @plant = effective service level on the order's plant, evaluated live from DynamoDB; @org = role level in {orgId} plus scope filtering |
| Pagination | limit 1–50 (default 25), opaque cursor bound to the query; bad/foreign cursor → 400 INVALID_CURSOR. Since 2026-12-01 (F7) E01 reads up to 4 index pages per request to fill a short page, moving on to the next phase (e.g. -cost → orders with no cost), so an empty page with a nextCursor is rare; a page can still be short, so keep paging while nextCursor is present |
| Unknown query params / unservable sort | 400 VALIDATION_FAILED with details.allowed |
| Bodies | strict (unknown keys → 422); JSON > 256 KB → 413; malformed → 400 MALFORMED_REQUEST |
| Always possible | 401 (gateway) / 401 SESSION_REVOKED, 403 ACCOUNT_SUSPENDED, 429 RATE_LIMITED, 503 DEPENDENCY_UNAVAILABLE, 500 INTERNAL |
Audience: internal vs customer view
Every order-bearing response is projected by audience
(packages/core/src/service/projection.ts). Omitted fields are absent,
not null.
INTERNAL(operator and partner staff): the fullWorkOrderview — costs, parts, internal notes, warranty claim ref, all attachments and events,viewer.capabilities.CUSTOMER(customer-org members; customers have no service access by default): an explicit allow-list —workOrderId, code, title, status, priority, workType, plant, device, plannedVisitAt, respondedAt, closedAt, completion {resolution, result, completedAt, signature {signerName, signedAt}}, technician {displayName}, operator {orgId, name?}, onlyCUSTOMER-visibility events (eventdatalimited tofrom,to,plannedVisitAt,result) and attachments, andviewer. AnINTERNALattachment fetched by a customer answers404, like an unknown id. For a v2 completion,completion.resolutioncarries the Installer'sworkPerformed. The customer never seesdiagnosis,completionNotes, the verification, a rejected completion or a hold request.
viewer: {audience, capabilities[]} tells the UI which actions to show
(e.g. workOrder.edit, workOrder.assign, workOrder.complete,
workOrder.cancel). There is one workOrder.<action> per E06 action that is
allowed from the order's current status and that the caller may perform
(see who may act):
assign,wait,resume,reject-completion,verify,close,cancelandreopenneed MANAGE. The order's Installer never getsworkOrder.verify, even with MANAGE.accept,declineandrequest-holdare only for the assigned Installer.request-holdis hidden while a request is pending.schedule,startandcompleteneed EDIT, or come with being the assignee.workOrder.noteandattachneed EDIT or being the assignee.workOrder.edit(E05) needs EDIT. Neither appears on aCLOSEDorCANCELLEDorder.
A read-only order (plant deleted) has no capabilities.
Responsible Business (WO-6)
Every order belongs to its plant's operator org (orgId). Responses also
carry it as operator: {orgId, name?}; the name is read live and is absent
if the org no longer exists. You find operator on:
- the E04 internal and customer views;
- E01 and E10 rows;
- E12 history rows.
Internal views and rows also carry technician.orgName.
SLA (response target)
packages/core/src/service/sla.ts. Wall-clock hours from createdAt, no
working-hours calendar, WAITING never pauses the clock:
| Priority | Target |
|---|---|
CRITICAL | 4 h |
HIGH | 24 h |
MEDIUM | 72 h |
LOW | 240 h |
PLAN-sourced orders have no target (sla.state: NO_TARGET). A priority
change recomputes responseTargetAt from the original createdAt. sla is
derived on read, never stored. Orders where the Installer's work is still
pending (NEW, REJECTED, ASSIGNED, ACCEPTED, IN_PROGRESS, WAITING, REOPENED)
are NO_TARGET | ON_TARGET | PAST_TARGET. Every other order — COMPLETED
and VERIFIED included, although they are still open — is NO_TARGET | MET | MISSED, so it never counts as past target or overdue. An order that never
recorded respondedAt is judged on closedAt (default applied, Q24).
In the queue order, COMPLETED and VERIFIED orders sort after every order
with a target (queue key sentinel 9999999997).
Status model (ADR 0023 D1)
| Status | Console label | Open? | Meaning |
|---|---|---|---|
NEW | Draft | open | Created, not assigned |
REJECTED | Rejected | open | The Installer declined the assignment; unassigned, awaiting reassignment |
ASSIGNED | Assigned | open | Awaiting the Installer's answer |
ACCEPTED | Accepted | open | The Installer accepted |
IN_PROGRESS | In Progress | open | The Installer is working |
WAITING | On Hold | open | Put on hold by the Business or Crown |
COMPLETED | Completed | open | Submitted for verification |
VERIFIED | Verified | open | The Business confirmed the work |
REOPENED | Reopened | open | A closed or cancelled order, waiting to be assigned again |
CLOSED | Closed | closed | Formally closed by the Business |
CANCELLED | Cancelled | closed | Cancelled |
- Open set = every status except
CLOSEDandCANCELLED.COMPLETEDandVERIFIEDstay open because the Business still has work to do (owner decision O2, recommended default). closedAtis set atCLOSEDorCANCELLED, no longer at:complete. The alert's open guard is released, andworkorder.completed.v1is emitted, at the same moment.- The
acceptanceandbusinessClosurefields stay as the record of who accepted or closed, and when. The status is the state. SCHEDULEDis retired (WO-1). A planned visit is theplannedVisitAtfield, and scheduling never changes the status. StoredSCHEDULEDvalues are read asASSIGNED, and E01 acceptsstatus=SCHEDULEDasASSIGNED.
Orders stored before v2
Until the backfill
rewrites them, older orders are read in v2 terms (foldLegacyLifecycle in
schemas.ts):
| Stored | Returned as |
|---|---|
ASSIGNED with acceptance | ACCEPTED |
COMPLETED with businessClosure | CLOSED |
hold reason PART / APPROVAL / SITE_ACCESS | PARTS_UNAVAILABLE / AWAITING_APPROVAL / SITE_INACCESSIBLE |
Status conditions and filters also match the stored value, so actions work on these orders before the backfill. Three things only the backfill fixes:
- a
COMPLETEDorder the Business never closed still sits in the closed queue, withclosedAt; - a declined order (
NEW+lastDecline) still readsNEW, notREJECTED; - older orders have no list entry, so the Crown-wide list
and the
createdAtsorts miss them, and the E02 counters and E01qsearch tokens of older orders are missing or stale.
State machine (ADR 0023 D2)
TRANSITION_TABLE in packages/core/src/service/work-order-state.ts. Anything
not in this table → 409 INVALID_STATE with details: {from, action, allowed}, plus details.reason where one applies (below). The state is
checked before the body is validated. A read-only order (plant deleted,
readOnlyReason: "PLANT_DELETED") answers 409 INVALID_STATE with
details.reason: "PLANT_DELETED" for every mutation.
| Action | From | To | Who |
|---|---|---|---|
| assign | NEW, REJECTED, REOPENED | ASSIGNED | MANAGE |
| assign to another person (reassign) | ASSIGNED, ACCEPTED, IN_PROGRESS | ASSIGNED (the new Installer must accept) | MANAGE, reason required |
| assign to the same person | ASSIGNED, ACCEPTED, IN_PROGRESS | unchanged | MANAGE |
| assign (reassign while on hold) | WAITING | WAITING; :resume then returns to ASSIGNED | MANAGE, reason required when the person changes |
unassign (technicianSub: null) | ASSIGNED, ACCEPTED | NEW | MANAGE, reason optional |
| accept | ASSIGNED | ACCEPTED | assignee only |
| decline | ASSIGNED | REJECTED (unassigned, lastDecline recorded) | assignee only |
| schedule / reschedule | every open status except COMPLETED, VERIFIED | unchanged (sets plannedVisitAt) | EDIT or assignee |
| start | ACCEPTED | IN_PROGRESS | EDIT or assignee |
| request-hold | ASSIGNED, ACCEPTED, IN_PROGRESS | unchanged (holdRequest recorded) | assignee only |
| wait (hold) | ASSIGNED, ACCEPTED, IN_PROGRESS | WAITING (waiting.holdFrom stored) | MANAGE |
| resume | WAITING | waiting.holdFrom (IN_PROGRESS for a pre-v2 hold) | MANAGE |
| complete | IN_PROGRESS | COMPLETED | EDIT or assignee |
| reject-completion | COMPLETED | IN_PROGRESS (same Installer) | MANAGE |
| verify | COMPLETED | VERIFIED | MANAGE, never the order's Installer |
| close | VERIFIED | CLOSED | MANAGE |
| cancel | NEW, REJECTED, ASSIGNED, ACCEPTED, IN_PROGRESS, WAITING, REOPENED | CANCELLED | MANAGE, reason required |
| reopen | CLOSED, CANCELLED | REOPENED (unassigned) | MANAGE, reason required |
Any status change also ends a pending hold request (holdRequest is removed).
details.reason values on a 409 INVALID_STATE:
| Reason | When |
|---|---|
NOT_ASSIGNED | :start on an unassigned order (NEW, REJECTED, REOPENED). :start never assigns the caller |
NOT_ACCEPTED | :start on an ASSIGNED order: the Installer must :accept first (LC-2) |
ALREADY_ACCEPTED | :accept on an ACCEPTED order |
ON_HOLD | :complete on a WAITING order: resume first (owner decision O4, recommended default) |
NOT_VERIFIED | :close on a COMPLETED order: :verify first (LC-5) |
ALREADY_CLOSED | :close on a CLOSED order |
HOLD_ALREADY_REQUESTED | :request-hold while a request is pending |
CLOSED | E05 patch, E08 note or E09 attachment write on a CLOSED or CANCELLED order. Only :reopen works there |
PLANT_DELETED | any mutation of a read-only order |
403 FORBIDDEN with details.reason: "SELF_VERIFY" answers :verify when
the caller is the order's Installer (technician.sub) or the person who
submitted the completion (completion.completedBy.sub), whatever their
level (LC-3).
Hold (ADR 0023 D2, D3)
Only the Business or Crown (MANAGE) put an order on hold and resume it. The
Installer asks with :request-hold.
:waitstoreswaiting {reason, note?, since, holdFrom, heldBy}.holdFromis the status the hold started from.:resumerestores it and writesRESUMEDwith the reason,heldSinceandheldBy.:request-hold {reason, note?}recordsholdRequest {requestedAt, requestedBy, reason, note?}and notifies the Business. The status does not change. Like every E06 action it needsIf-Matchand bumps the version, so the console can show "hold requested". A second request while one is pending →409 INVALID_STATEreason: HOLD_ALREADY_REQUESTED. The request ends at the next status change (for example:wait) or reassignment.- An order on hold cannot be completed (
409reason: ON_HOLD).
Hold reasons (WaitingReason): CUSTOMER_UNAVAILABLE, PARTS_UNAVAILABLE,
INSTALLER_UNAVAILABLE, AWAITING_APPROVAL, SITE_INACCESSIBLE,
INVESTIGATION_REQUIRED, OTHER. For one release the old input values are
accepted and mapped: PART → PARTS_UNAVAILABLE, APPROVAL →
AWAITING_APPROVAL, SITE_ACCESS → SITE_INACCESSIBLE. Responses always
carry the new values.
Completion, verification and closure (ADR 0023 D2, D4)
- The Installer completes (
:complete, fromIN_PROGRESS). The order becomesCOMPLETED, still open. The full submission is kept in theCOMPLETEDevent. - The Business verifies (
:verify) →VERIFIED, recordingverification {result: VERIFIED, verifiedAt, verifiedBy, notes?}. Or it sends the completion back (:reject-completion) →IN_PROGRESS, same Installer: the currentcompletionmoves into theCOMPLETION_REJECTEDevent, andlastCompletionRejection {rejectedAt, rejectedBy, reason, instructions?}tells the Installer what to fix. The next:completestarts clean. - The Business closes (
:close, fromVERIFIED) →CLOSED, recordingbusinessClosure {closedAt, closedBy, note?}andclosedAt. The linked alert is released here.
awaitingClosure: true on views and internal rows marks VERIFIED orders
that are not closed yet.
Reopen (:reopen, from CLOSED or CANCELLED) lands in REOPENED with
the technician, acceptance and assignment cleared. The previous completion,
verification, closure, cancellation and actual cost move into the REOPENED
event, and reopenCount goes up by one. From REOPENED the Business
:assigns again (the same Installer is fine) or :cancels (owner decision
O3, recommended default). If the order has an alert, reopening takes the
alert's open guard again (409 ALREADY_EXISTS if another open order holds
it).
Who may act (ADR 0023)
-
The responsible Business is anyone with service ≥ MANAGE on the plant: the Business role, or a platform member intervening. Platform interventions are written to the org's access log as
PLATFORM_ACCESS, and every event they write carriesdata.platformIntervention: true. The Business:- assigns, reassigns, unassigns and bulk-assigns;
- puts orders on hold and resumes them;
- verifies or rejects completions, and closes;
- cancels and reopens;
- writes
instructionsandactualCost(E03 / E05).
Only it may send
technicianSub/teamIdon E03. -
The assigned Installer (
technician.subis the caller) may:- accept or decline;
- request a hold;
- schedule, start and complete;
- add notes (E08) and attachments (E09).
This works at any visible service level, so the seeded Installer role (
service: VIEW) can work its own orders. The Installer never assigns, never holds or resumes, never verifies their own work, and cannot use E05 atservice: VIEW. -
Others with service ≥ EDIT keep the EDIT actions (schedule, start, complete, E05, notes, attachments) on orders they can see. Under the visibility rule below, that means only their own orders unless they are MANAGE.
-
Crown staff. The Administrator system role equals Super Admin for work orders: both hold
service: FULLwith scopeALL. A per-Business limit (ADR 0014 R-3a) lowers the roles of the Business's own members only. It does not cap a Crown Administrator (owner decision O1, decided 2026-11-10: no cap).
Installers see only their own orders (WO-4). This applies to a caller who reaches the plant through an operator-org membership at service below MANAGE, with no platform membership:
| Route | What that caller gets |
|---|---|
| E04, E05, E06, E08, E09 | 404 for an order that is not assigned to them |
| E01 | Only their own orders (technicianSub=me is forced). Asking for someone else or quick=unassigned returns an empty page |
| E02 | Counts over their own orders |
| E10 | Their own orders, with counts over this page |
Partner-org and customer-portal callers keep their existing share-based visibility.
Crown-wide reads (ADR 0023 D9)
E01, E02 and E12 called with the caller's own PLATFORM org as {orgId}
and no operatorOrgId cover every Business (LC-11). This applies to an
ACTIVE PLATFORM member with scope ALL and service ≥ VIEW there (Super Admin,
Administrator and Viewer by default; isCrownWideRead in
packages/core/src/service/assignee-scope.ts). operatorOrgId stays
available to read one Business.
- Rows are read from a per-order list entry (
WO#<w>/LISTALL), because every index slot on the order itself is taken. One shard today. - Every row is listed, whatever the Business's state (suspended, missing from
the Businesses list) and whether the caller is also a member of that
Business. Passing the Crown-wide check above is the access decision, so E01
lists every order the E02 Crown-wide counters count. Each Business read is
noted in that Business's access log (
PLATFORM_ACCESS). Fixed 2026-11-12, not deployed yet: earlier builds re-checked each Business through the platform fallback and dropped the rows it refused. On dev, E02 counted 4 open orders while E01 listed 1: 3 of the 4 belong to a Business the check refused. The 2026-11-10 build first dropped every row, andoperatorOrgIdfrom the PLATFORM org answered403. plantIdnarrows to that plant's orders, read from the plant's own partition, whatever its Business. One Business withoperatorOrgIdstill goes through the platform fallback and can answer403.qis checked page by page: there is no search index across Businesses, so pages may be short or empty whilenextCursoris present.- E02 returns counter-backed
metrics,facetsandtabs.openOrdersonly: nobyTechnician, plans or history tab.plantIdortechnicianSubthere needsoperatorOrgId(422 VALIDATION_FAILED). - E12 computes its tiles over at most the tiles read budget (
truncated: truebeyond).
Creating an order on behalf of a Business needs nothing new: E03 takes the Business from the plant, and a platform member with MANAGE acts through the audited platform fallback.
E01 — GET /v1/orgs/{orgId}/work-orders
Work-order table. AuthZ: service ≥ VIEW @org (operator org) or a
share-based caller. Paginated.
| Param | Type | Rules |
|---|---|---|
orgId (path) | ULID | caller is an ACTIVE member, or platform. Crown staff read one Business by passing that Business's orgId, or by calling with their PLATFORM org and operatorOrgId (WO-8; audited PLATFORM_ACCESS). Their PLATFORM org without operatorOrgId lists every Business (Crown-wide reads) |
operatorOrgId | ULID | WO-8: accepted only when {orgId} is the PLATFORM org the caller belongs to; lists that Business instead. From any other org → 422 VALIDATION_FAILED (field operatorOrgId). Also on E02 and E12 |
quick | open (default) | overdue | unassigned | progress | completed | closure | all | open = the open set (COMPLETED and VERIFIED included); progress = IN_PROGRESS + WAITING; completed = COMPLETED, VERIFIED or CLOSED; closure = VERIFIED (awaiting Business closure) |
status | repeatable WorkOrderStatus (all 11) | intersected with quick; SCHEDULED is accepted as ASSIGNED |
awaitingClosure | true | false | kept for one release: true = only VERIFIED orders not yet closed (same as status=VERIFIED); false = excludes them |
awaitingAcceptanceSince | ISO-8601 UTC | LC-16: ASSIGNED orders assigned at or before this instant (not yet answered). No automatic reassignment |
createdFrom, createdTo | ISO-8601 UTC | LC-13: inclusive bounds on createdAt; createdTo before createdFrom → 400 (field createdTo) |
plannedFrom, plannedTo | ISO-8601 UTC | LC-13: inclusive bounds on plannedVisitAt; orders with no planned visit are excluded; plannedTo before plannedFrom → 400 (field plannedTo) |
priority, workType, source | repeatable enums | |
issueCategory | repeatable IssueCategory | ADR 0023 D6: orders with any of these reported issues; orders without one are excluded. Internal rows carry issueCategory |
technicianSub | repeatable sub, unassigned or me | |
plantId | ULID | must be visible (else 404) |
planId | ULID | |
overdue | true | same as quick=overdue |
q | 2–64 chars | with the default sort: the search index; with any other sort: that sort's order, words matched page by page (2026-11-25) |
sort | queue (default) | dueAt | -createdAt | createdAt | planned | priority | status | plant | technician | device | cost (each also with -) | see below; unservable → 400 VALIDATION_FAILED + details.allowed |
limit, cursor |
The date and awaitingAcceptanceSince filters are checked on each page read,
so a page may come back short with a nextCursor, as with the other filters.
Search. q matches the order code (and its numeric tail), title words,
plant name and code, customer name, device serial, technician name and alert
id/code. Since ADR 0023 D10 the search tokens are written on the request
path, right after each order write (see counters and search),
so search works without the stream-router. Orders written before that only
appear after the backfill with --counters.
Sort (ADR 0023 D11).
queue(default): open orders by SLA, then priority, then age; closed orders newest closed first.-createdAt/createdAt: newest / oldest created first, with or withoutplantId, per Business or Crown-wide, also withq. Share-based callers get both on one plant and on their merged plants (2026-11-25).dueAt/-dueAt(2026-11-25): on open ordersdueAtis the queue order (response target first). On closed or mixed sets (quick=completed|closure|all), withplantId, and-dueAteverywhere, orders sort byresponseTargetAt, with orders that have no target last in both directions. Before 2026-11-25dueAtwas refused on closed sets.- Column sorts (2026-11-24, ADR 0030 in
cse-http-be/docs/adr/, console item 4.12).planned(planned visit; orders without one last),priority(CRITICAL first),status(lifecycle order NEW → ASSIGNED → ACCEPTED → IN_PROGRESS → WAITING → COMPLETED → VERIFIED → CLOSED → CANCELLED),plant(plant name),technician(technician name; unassigned last). A leading-reverses (so-plannedputs unplanned first). Ties: oldest created first. Every filter still applies, checked page by page, so a page can be short with anextCursor. Served from one small sort entry per order and column, written after each order change (no table scan, no new index). Orders written before the change appear only afternpm run backfill:wo-console-indexes. - More column sorts (2026-11-25, console request W1–W6, ADR 0030 addendum).
device(device label, else serial; orders without a device last ascending) andcost(the row'scostDisplayamount: actual cost, else estimate; currencies are not converted or compared; orders without a cost last in both directions). Every column sort now also works withq(words matched page by page; pages may be short) and on the Crown-wide list (every Business, withoutoperatorOrgId). Share-based callers (a partner or customer seeing the orders through plant shares) can usequeue,createdAt/-createdAt(one plant or their merged plants) anddueAt(with onetechnicianSub) only; any other sort →400+details.allowed. Re-runbackfill:wo-console-indexesonce after deploying this: existing sort entries lack the Crown-wide copy and the new columns, so those sorts miss older orders until it runs. Run on dev 2026-11-25 (4 orders, 32 entries, 0 failures).
Invalid combinations are rejected with 400 VALIDATION_FAILED (Zod issue on
the named field): overdue=true with any quick other than open
or overdue (field overdue); the reversed date ranges above. Before ADR 0023,
sort=-createdAt required plantId; it no longer does.
Known default (Q28): on the plantId path and the shared-plant merge
path, sort=queue is accepted but rows are served newest-first (no index
carries the queue key per plant). Don't render a "queue order" label there.
Response 200: { items: WorkOrderRow[], nextCursor?, access? }. access is on
the first page only (no cursor, 2026-11-25): member (the org's own list,
scoped or not), shared (plant shares; limited sorts, see above) or
crownWide (every Business). Use it to disable the sorts a shared caller
cannot use. Rows carry
operator, and internal rows also awaitingClosure, acceptedAt? and
businessClosedAt?. For an Installer-tier caller the list holds only their
own orders (see who may act).
| Status | Code | When |
|---|---|---|
| 200 | — | ok (empty → items: []) |
| 400 | VALIDATION_FAILED / INVALID_CURSOR / ORG_CONTEXT_REQUIRED | bad params / cursor |
| 403 | FORBIDDEN | not a member / service NONE |
| 404 | NOT_FOUND | plantId not visible |
| 422 | VALIDATION_FAILED | operatorOrgId from a non-PLATFORM org |
| 422 | SCOPE_TOO_BROAD | share-based caller: tag/region share, no plant shares, or > 10 shared plants (see details below) |
422 SCOPE_TOO_BROAD details (E01 and E02, B-2). Only share-based
callers (partner/customer orgs) get it. Body:
// illustrative example, derived from shareScopeTooBroad() in packages/core/src/services/work-order-service.ts
{ "error": { "code": "SCOPE_TOO_BROAD", "message": "Filter by plant or technician to list these work orders",
"details": { "reason": "TOO_MANY_PLANTS", "maxPlants": 10, "narrowBy": ["plantId", "technicianSub"] }, "requestId": "<id>" } }
reason | When |
|---|---|
NON_PLANT_SHARE | one of the caller's active shares is a tag/region share (its plants cannot be listed) |
NO_PLANT_SHARES | a customer org with no plant shares |
TOO_MANY_PLANTS | more shared plants than maxPlants — 10 on E01, 50 on E02 |
The message says summarise instead of list on E02. Narrow with plantId
or technicianSub and retry.
E02 — GET /v1/orgs/{orgId}/work-orders/summary
Metric strip, drawer facets, group-by-technician and tab counts. AuthZ
service ≥ VIEW @org, or a share-based caller.
| Param | Type | Rules |
|---|---|---|
include | repeatable, max 4: metrics (default), facets, byTechnician, tabs | |
plantId | ULID | optional; parsed as on E01 |
technicianSub | repeatable (max 20) sub, unassigned or me | optional; parsed as on E01 |
operatorOrgId | ULID | WO-8: from the PLATFORM org only — summarise this Business. Omitted from the PLATFORM org → every Business (Crown-wide reads) |
// illustrative example, derived from the schema/handler code (counter-backed, whole Business)
{ "metrics": { "pastTarget": 6, "criticalOpen": 3, "unassigned": 9, "inProgress": 11, "completedLast30d": 71,
"awaitingClosure": 4, "open": 61, "total": 348,
"draft": 7, "rejected": 2, "awaitingAcceptance": 8, "accepted": 6, "onHold": 3,
"awaitingVerification": 5, "verified": 4, "reopened": 1, "closed": 270, "cancelled": 17 },
"facets": { "status": { "NEW": 7, "ASSIGNED": 8, "COMPLETED": 5 }, "priority": { "CRITICAL": 3 } },
"byTechnician": [{ "sub": "<sub>", "displayName": "Hina R.", "open": 5, "pastTarget": 1 }],
"tabs": { "openOrders": 61, "plans": 5, "historyLast90d": 142 },
"approximate": true, "truncated": false, "asOf": "2026-11-10T09:20:00.000Z" }
facets count open orders only (owner decision 2026-12-01, report F3). Every facet (status,
priority, workType, source, technician) and byTechnician count the open set (every status except
CLOSED and CANCELLED), not the rows of the list the console is showing. With quick=all the facets therefore sum to
the open orders, and a CLOSED order is in no facet. Label these counts "open" in the console (for example
"Open by status"). Crown-wide (the PLATFORM org, no operatorOrgId) facets.technician holds only UNASSIGNED and
byTechnician is not returned. A status count that disagrees with the list (for example ACCEPTED: 1 for an order
that is already CLOSED, seen on dev 2026-12-01) is counter drift from the v1 → v2 lifecycle change; a human rebuilds the
counters with npm run backfill:wo-lifecycle-v2 -- --counters over every org (dry-run first).
Metrics (ADR 0023 D10, LC-12).
| Metric | Counts |
|---|---|
draft | NEW |
rejected | REJECTED |
awaitingAcceptance | ASSIGNED |
accepted | ACCEPTED |
inProgress | IN_PROGRESS only. Breaking: before v2 it also counted WAITING |
onHold | WAITING |
awaitingVerification | COMPLETED |
verified | VERIFIED |
awaitingClosure | VERIFIED (kept for one release; same as verified) |
reopened | REOPENED |
closed, cancelled | CLOSED, CANCELLED — counter-backed summaries only (a whole Business, or every Business) |
open, total | the open set (COMPLETED and VERIFIED included); every order |
pastTarget | open orders past their response target (never COMPLETED / VERIFIED) |
criticalOpen, unassigned | open orders with priority CRITICAL; open orders with no technician |
completedLast30d | orders closed (CLOSED) in the last 30 days |
The metrics are scoped to the caller: an Installer gets their own orders, a
Business gets its org counters, and Crown gets every Business's counters (or
one Business's with operatorOrgId). The per-status counts come from
COUNT#WOSTATUS#<status> counters that, since ADR 0023 D10, are written on
the request path (see below).
Unfiltered ALL callers get counter-based counts (approximate: true).
Any filter (plantId or technicianSub), and every scoped or
share-based caller, gets counts over the visible open set with
approximate: false: facets, completedLast30d, closed and cancelled
are omitted there. The read is capped at 2,000 rows read / 40 pages / 2,000
visible, then truncated: true. Share-based callers with up to 50 shared
plants are counted (E01 still merges only up to 10). An Installer-tier caller
is always counted over their own assigned orders, through the computed path.
A SCHEDULED counter left by old orders is added to ASSIGNED.
Status: 200, 400 VALIDATION_FAILED, 403 FORBIDDEN, 404 NOT_FOUND
(plantId not visible), 422 VALIDATION_FAILED (Crown-wide with plantId or
technicianSub but no operatorOrgId), 422 SCOPE_TOO_BROAD (details as on
E01, maxPlants: 50).
E03 — POST /v1/work-orders
Create. AuthZ service ≥ EDIT @plant; sending technicianSub, teamId or
instructions needs service ≥ MANAGE (403 FORBIDDEN otherwise — WO-3,
ADR 0023 D6). End users never create orders: they phone their Business, which
creates the order in the console. Idempotency R.
| Field | Type | Req | Rules |
|---|---|---|---|
plantId | ULID | yes | visible; lifecycle ACTIVE |
| (currency) | — | — | Cost fields are in the Business currency: read currency / localisation.currency from GET /v1/orgs/{orgId} (N-38). That route needs settings ≥ VIEW, so a creator without it cannot read the currency — open owner question (2026-10-29) |
title | string 3–160 | yes* | *optional when alert.title is given |
source | SERVICE | PLANT | DEVICE | ALERT | no | default SERVICE; ALERT needs alert; DEVICE needs deviceSerial; PLAN (plan worker) and SERVICE_REQUEST (only on orders created from a now-retired service request) are rejected |
deviceSerial | string 1–64 | no | ADR 0012: a serial bound to the plant (binding), as typed or normalised; else 422 VALIDATION_FAILED (details.reason = DEVICE_NOT_ON_PLANT, details.field = deviceSerial). The order stores a device snapshot {serial, label?, model?} |
deviceId | string ≤ 64 | no | Deprecated alias of deviceSerial (it always carried the serial). Sending both → 422 |
alert | {alertId, code?, title?, severity?, deviceKey?} | no | format only — see alert link |
description | string ≤ 4000 | no | a default sentence is stored when omitted |
priority | WorkOrderPriority | no | default MEDIUM / alert-derived |
workType | WorkType | no | default CORRECTIVE_REPAIR. This is the job type (repair, inspection …), not the reported issue |
customerOrgId | ULID | no | ADR 0023 D6: must be the plant's customer (422 VALIDATION_FAILED, details {field: customerOrgId, reason: CUSTOMER_PLANT_MISMATCH}) and a customer of the Business (reason: CUSTOMER_NOT_LINKED). Omitted → taken from the plant, as before |
instructions | string 1–4000 | no | ADR 0023 D6: instructions for the Installer; MANAGE only |
preferredDate | YYYY-MM-DD | no | ADR 0023 D6: the customer's preferred visit day (a real calendar date). Separate from plannedVisitAt, which stays an ISO-8601 UTC instant |
issueCategory | IssueCategory | no | ADR 0023 D6 (LC-9): the issue the customer reported. Unknown value → 400/422 validation error |
technicianSub | string | null | no | a sub needs MANAGE and must be an eligible Installer of the operator org; the order starts ASSIGNED. Omitted on a Business (MANAGE) create → the plant's assigned Installer (R-5) when eligible (WO-5); otherwise, or below MANAGE, unassigned. null → always unassigned (NEW, shown as Draft) |
teamId | ULID | no | caller needs MANAGE; team of the operator org |
plannedVisitAt | ISO UTC | no | now − 7 d … now + 366 d; never changes the status |
costEstimate | Money | no | org currency |
internalNotes | string ≤ 4000 | no | |
warrantyClaimRef | string ≤ 40 | no |
:::caution Provisional issueCategory values
issueCategory (LC-9) is built with a provisional list (owner decision O5),
which product has not confirmed yet: NO_GENERATION, LOW_GENERATION, INVERTER_FAULT, BATTERY_ISSUE, COMMUNICATION_LOSS, PANEL_DAMAGE, WIRING_ELECTRICAL, GRID_OR_METER, CLEANING_REQUEST, OTHER. The list may change before the
console relies on it.
:::
Response 201 + Location: /v1/work-orders/{id} + ETag, body WorkOrder.
An assigned create also sets assignedBy and assignedAt. Attachments are
added afterwards via E09.
| Status | Code | When |
|---|---|---|
| 201 | — | created (replay: same body + Idempotent-Replayed) |
| 403 | FORBIDDEN | service < EDIT; or technicianSub / teamId / instructions sent below MANAGE |
| 404 | NOT_FOUND | plant not visible |
| 409 | INVALID_STATE | plant archived/deleting (details.lifecycle), or details.reason: "PLANT_NOT_ORG_MANAGED" — the plant has no operator org + customer org (e.g. a legacy consumer plant) |
| 409 | ALREADY_EXISTS | the alert already has an open order (details.workOrderId) |
| 409 | IDEMPOTENCY_IN_PROGRESS | concurrent same key |
| 422 | VALIDATION_FAILED | field errors; device not on plant; ineligible assignee (see below); CUSTOMER_PLANT_MISMATCH / CUSTOMER_NOT_LINKED; currency mismatch |
| 422 | IDEMPOTENCY_KEY_REUSED | same key, different body |
| 428 | PRECONDITION_REQUIRED | missing Idempotency-Key |
Ineligible assignee (E03, :assign, bulk).
The response is 422 VALIDATION_FAILED, message "assignee is not an eligible
Installer for this plant", with details:
{ "field": "technicianSub", "reason": "INELIGIBLE_ASSIGNEE", "cause": "<cause>" }
cause is one of:
cause | Meaning |
|---|---|
NOT_MEMBER | not a member of the plant's operator org (partner technicians fall here) |
MEMBERSHIP_INACTIVE | the membership is not ACTIVE |
SERVICE_LEVEL | the scope does not cover the plant, or the role is neither service ≥ EDIT nor an Installer role |
PROFILE_INACTIVE | the person has a roster profile marked inactive |
Before 2026-11-04 the message was "assignee lacks service access" and these
values were in details.reason.
Codes are WO-YYYY-NNNN, allocated per operator org; they resolve via
GET /v1/lookup.
E04 — GET /v1/work-orders/{workOrderId}
Drawer. AuthZ service ≥ VIEW @plant; an Installer-tier caller gets 404
for an order not assigned to them. 200 WorkOrder (first 50 timeline
events, all non-deleted attachments' metadata) + ETag. 403, 404.
Fields of the internal view beyond the stored basics:
| Field | Meaning |
|---|---|
operator | the responsible Business |
awaitingClosure | VERIFIED and not yet closed by the Business |
assignedBy?, assignedAt? | who made the current assignment, and when (assignedAt is new in v2; cleared by unassign, decline and reopen) |
acceptance? | when and by whom the Installer accepted |
lastDecline? | the last decline and its reason |
holdRequest? | the Installer's pending hold request {requestedAt, requestedBy, reason, note?} |
waiting? | {reason, note?, since, holdFrom?, heldBy?} while on hold |
completion? | the current submission: {diagnosis, workPerformed, completionNotes?, resolution, result, hoursOnSite?, downtimeMinutes?, completedAt, completedBy, signature?}. Pre-v2 completions carry only resolution |
lastCompletionRejection? | the last :reject-completion {rejectedAt, rejectedBy, reason, instructions?}; cleared by :verify, reassignment or reopen |
verification? | {result: VERIFIED, verifiedAt, verifiedBy, notes?} |
businessClosure? | when and by whom the Business closed it |
instructions?, preferredDate?, issueCategory? | ADR 0023 D6 |
completions[] | every :complete submission found on the loaded timeline page, newest first, at most 20. Each entry is {submittedAt, submittedBy, submission, actualCost?, outcome, rejection?, verifiedAt?}; outcome is PENDING, REJECTED, VERIFIED or SUPERSEDED |
assignments[] | assignment periods found on the loaded timeline page, newest first, at most 20: {technician, assignedAt, assignedBy, reason?, endedAt?, endedBy?, outcome?}; outcome is REASSIGNED, UNASSIGNED, DECLINED or REOPENED |
serviceRequestId? | the (retired) service request an older order came from |
technician.orgName | the assignee's org name |
completions[] and assignments[] are derived from the same first 50
timeline events the drawer loads. History older than that page is not
included; page through E08 for it. A suspended assignee shows
assigneeStatus: "SUSPENDED"; a deleted plant shows readOnlyReason: "PLANT_DELETED". Open orders past target carry a synthetic PAST_TARGET
timeline item (eventId: "sla-past-target", synthetic: true, internal
only).
// illustrative example, derived from the schema/handler code (trimmed)
{ "workOrderId": "01JB7Y3R8Q2V6K1M9N4P5S7T0W", "code": "WO-2026-0499", "version": 7,
"plant": { "name": "Regal Textiles Rooftop", "code": "PL-0231" },
"source": "ALERT",
"alert": { "alertId": "8f0c-…", "code": "CRN-GRD-002", "severity": "CRITICAL", "clientSupplied": true, "linkedAt": "2026-11-08T09:12:00.000Z" },
"title": "Grid over-voltage trip", "priority": "CRITICAL", "workType": "CORRECTIVE_REPAIR",
"status": "COMPLETED", "technician": { "sub": "<sub>", "displayName": "Hina R.", "orgId": "01J…", "orgName": "Crown Solar Lahore" },
"operator": { "orgId": "01J…", "name": "Crown Solar Lahore" }, "awaitingClosure": false,
"assignedBy": { "kind": "USER", "sub": "<sub>", "displayName": "Bilal A.", "orgId": "01J…", "role": "Business" },
"assignedAt": "2026-11-08T09:20:00.000Z",
"acceptance": { "acceptedAt": "2026-11-08T09:30:00.000Z", "acceptedBy": { "kind": "USER", "sub": "<sub>", "displayName": "Hina R." } },
"instructions": "Call the site manager before arriving.", "preferredDate": "2026-11-09",
"completion": { "diagnosis": "Loose AC terminal on phase L2.", "workPerformed": "Re-terminated and torqued L2.",
"resolution": "Re-terminated and torqued L2.", "result": "RESOLVED",
"completedAt": "2026-11-09T12:05:00.000Z", "completedBy": { "kind": "USER", "sub": "<sub>", "displayName": "Hina R." } },
"completions": [{ "submittedAt": "2026-11-09T12:05:00.000Z", "submittedBy": { "kind": "USER", "sub": "<sub>", "displayName": "Hina R." },
"submission": { "…": "as completion" }, "outcome": "PENDING" }],
"assignments": [{ "technician": { "sub": "<sub>", "displayName": "Hina R.", "orgId": "01J…" }, "assignedAt": "2026-11-08T09:20:00.000Z",
"assignedBy": { "kind": "USER", "sub": "<sub>", "displayName": "Bilal A." } }],
"responseTargetAt": "2026-11-08T13:12:00.000Z", "sla": { "state": "MET", "pastTarget": false },
"viewer": { "audience": "INTERNAL", "capabilities": ["workOrder.edit", "workOrder.note", "workOrder.attach", "workOrder.reject-completion", "workOrder.verify"] } }
E05 — PATCH /v1/work-orders/{workOrderId}
AuthZ service ≥ EDIT @plant; If-Match required. Body: ≥ 1 of title, description, priority, workType, deviceSerial (null = whole plant; deprecated alias deviceId, not both), costEstimate, internalNotes, warrantyClaimRef, parts[] (≤ 50), actions[]
(≤ 50; new entries get an actionId, existing ones are immutable except
removal), checklist[] (≤ 30, {itemId?, text, done}), preferredDate
(YYYY-MM-DD), issueCategory (null clears), and two fields that need service ≥ MANAGE (403
otherwise):
instructions(1–4000): instructions for the Installer;actualCost(Money, org currency): the Business enters or corrects the cost until the order is closed. Since v2:completeno longer requires it.
null clears an optional field. status, technicianSub, plantId,
source, alert, code, version are rejected as unknown keys (422).
Over-cap arrays → 422 LIMIT_EXCEEDED (details {limit, field}).
E05 works on every open order, COMPLETED and VERIFIED included. A CLOSED
or CANCELLED order → 409 INVALID_STATE with details.reason: "CLOSED"
(reopen it first). The Installer cannot change title, description, customer
or plant: at service: VIEW they have no E05 at all.
200 WorkOrder · 403 · 404 · 409 VERSION_CONFLICT · 409 INVALID_STATE (CLOSED, or read-only) · 422 · 428. Appends one
FIELDS_CHANGED event {fields, previous?, next?}: previous / next hold
the before and after values of the scalar fields among fields (title,
description, priority, workType, deviceId, costEstimate, actualCost,
warrantyClaimRef, instructions, preferredDate, issueCategory, responseTargetAt); an absent
value is null. List fields (parts, actions, checklist) are only named.
E06 — POST /v1/work-orders/{workOrderId}:{action}
All need If-Match; Idempotency O. Response 200 WorkOrder. Every
body is strict (unknown keys → 422). Transitions are in the
state machine.
| Action | Body | Who | Notes |
|---|---|---|---|
:assign | {technicianSub: string | null, teamId?: ULID | null, reason?: 1–1000} | MANAGE | null unassigns (from ASSIGNED / ACCEPTED only). The assignee must be eligible. reason is required when the order already has a different assignee (422 VALIDATION_FAILED, details.field: reason), optional otherwise; it is stored in the REASSIGNED / UNASSIGNED event. A new assignee clears acceptance, holdRequest and lastCompletionRejection and sets assignedBy / assignedAt |
:accept | {} or no body | assignee only | ASSIGNED → ACCEPTED; records acceptance; ACCEPTED event (internal) |
:decline | {reason 1–1000} | assignee only | ASSIGNED → REJECTED, unassigned; records lastDecline; DECLINED event (internal — the reason is for the Business) |
:schedule | {plannedVisitAt} | EDIT or assignee | sets the date only (now − 7 d … now + 366 d); SCHEDULED / RESCHEDULED event (customer-visible) |
:start | {onSiteAt?} | EDIT or assignee | ACCEPTED only (NOT_ACCEPTED from ASSIGNED, NOT_ASSIGNED when unassigned). onSiteAt defaults to now, not in the future, not before createdAt; the first start sets respondedAt |
:request-hold | {reason: WaitingReason, note?: 1–1000} | assignee only | status unchanged; records holdRequest; HOLD_REQUESTED event (internal); notifies the Business. HOLD_ALREADY_REQUESTED while one is pending |
:wait | {reason: WaitingReason, note? ≤ 1000, warrantyClaimRef? ≤ 40} | MANAGE | from ASSIGNED, ACCEPTED, IN_PROGRESS; stores waiting.holdFrom and heldBy; WAITING event (shown as On Hold) |
:resume | {} | MANAGE | back to waiting.holdFrom; RESUMED event with the hold's reason, start and heldBy |
:complete | {diagnosis 1–4000, workPerformed 1–4000, completionNotes?: 1–4000, result, actualCost?, hoursOnSite? 0–999.9, downtimeMinutes? 0–525600, signature?: {attachmentId, signerName ≤ 120}} | EDIT or assignee | IN_PROGRESS only (ON_HOLD from WAITING). diagnosis and workPerformed are required: one 422 lists every missing one (below). resolution is accepted as an alias of workPerformed for one release. actualCost is optional and must be in the org currency. signature must be a READY SIGNATURE attachment on this order |
:reject-completion | {reason 1–1000, instructions?: 1–4000} | MANAGE | COMPLETED → IN_PROGRESS; moves completion into the COMPLETION_REJECTED event (internal); sets lastCompletionRejection; notifies the Installer |
:verify | {notes?: 1–1000} or no body | MANAGE, never the Installer | COMPLETED → VERIFIED; records verification; VERIFIED event (customer-visible). notes is also appended as an internal NOTE event. The Installer → 403 reason: SELF_VERIFY |
:close | {remarks?: 1–1000} or no body | MANAGE | VERIFIED → CLOSED (NOT_VERIFIED from COMPLETED); records businessClosure (remarks is stored as its note) and closedAt; releases the alert; CLOSED event (customer-visible). note is accepted as an alias of remarks for one release |
:cancel | {reason: DUPLICATE|WITHDRAWN|NOT_A_FAULT|OTHER, note? ≤ 1000, duplicateOfWorkOrderId?} | MANAGE | not from COMPLETED / VERIFIED; duplicate-of must be a visible order of the same org (not itself); sets closedAt; releases the alert |
:reopen | {reason 1–1000} | MANAGE | CLOSED / CANCELLED → REOPENED, unassigned; see reopen |
:complete with missing fields.
// illustrative example, derived from planTransition() in packages/core/src/service/work-order-state.ts
{ "error": { "code": "VALIDATION_FAILED", "message": "Validation failed",
"details": { "fields": ["diagnosis", "workPerformed"],
"issues": [{ "path": "diagnosis", "message": "diagnosis is required" },
{ "path": "workPerformed", "message": "workPerformed is required" }] },
"requestId": "<id>" } }
| Status | Code | When |
|---|---|---|
| 403 | FORBIDDEN | not the Business for a MANAGE action; not the assignee for :accept / :decline / :request-hold; below EDIT and not the assignee otherwise; details.reason: SELF_VERIFY on :verify by the Installer |
| 404 | NOT_FOUND | not visible (incl. an Installer-tier caller on someone else's order); unknown action |
| 409 | INVALID_STATE | not allowed from the current status (details {from, action, allowed}, plus reason NOT_ASSIGNED / NOT_ACCEPTED / ALREADY_ACCEPTED / ON_HOLD / NOT_VERIFIED / ALREADY_CLOSED / HOLD_ALREADY_REQUESTED) or read-only (PLANT_DELETED) — checked before body validation |
| 409 | VERSION_CONFLICT | stale If-Match |
| 409 | ALREADY_EXISTS | reopen while another open order holds the alert |
| 422 | VALIDATION_FAILED | field errors; reassign without reason (details.field: reason); :complete missing diagnosis / workPerformed (details.fields); ineligible assignee (details.reason: INELIGIBLE_ASSIGNEE); bad dates; decline / reopen / reject-completion reason; currency mismatch |
| 428 | PRECONDITION_REQUIRED | no If-Match |
Close and cancel emit workorder.completed.v1 (outcome COMPLETED /
CANCELLED) and reopen emits workorder.linked.v1 when an alert is linked.
Automatic cancel on detach (RBAC v2, 2026-11-14):
when a Business detaches an End User, each of its open, writable orders on the plants that move back is cancelled
by the system through this same transition — reason: WITHDRAWN, note starting END_USER_DETACHED, actor
{ kind: SYSTEM } — with the usual event, alert release and workorder.completed.v1. Finished orders are untouched.
:complete no longer emits anything.
Activity history (WO-9, ADR 0023 D8)
Every create, assign, reassign, unassign, accept, decline, schedule, start, hold request, hold, resume, complete, completion rejection, verify, close, cancel and reopen writes timeline events in the same transaction as the change. No route edits or deletes an event.
- Each event carries
actor {kind, sub, displayName, orgId?, role?, viaPlatform?}andat.role(new) is the name of the role the actor held in the acting org at the time; it is absent on older events. viaPlatform: true(2026-11-12) marks an actor who is Crown staff acting through platform access. A reader with no Crown membership gets that actor as{kind, displayName: "Crown Support", viaPlatform: true}— nosub,orgIdorrole. Applies to events, notes and attachments written since then; older ones are shown as stored (Role boundaries).- Assignment events,
SCHEDULED/RESCHEDULEDandFIELDS_CHANGEDcarrydata.previousanddata.next.REASSIGNEDandUNASSIGNEDcarryreasonwhen one was given. COMPLETEDcarries the full submission indata.completion(anddata.actualCostwhen sent).COMPLETION_REJECTEDcarries the rejected submission,reasonandinstructions.REOPENEDcarries the closing facts it cleared.- New kinds:
VERIFIED,COMPLETION_REJECTED,HOLD_REQUESTED.
| Visibility | Events |
|---|---|
| Customer-visible | events that change the status (including VERIFIED); SCHEDULED / RESCHEDULED; CLOSED |
| Internal | REASSIGNED without a status change, ACCEPTED, DECLINED, COMPLETION_REJECTED, HOLD_REQUESTED, field/attachment/checklist changes, and notes unless posted as CUSTOMER |
Customers only see from, to, plannedVisitAt and result of an event's
data. An event written by a platform member acting in a Business they do not
belong to carries data.platformIntervention: true.
Notifications (WO-10, ADR 0023 D8)
These go to the in-app inbox (notifications). "The
Business" means the user who made the current assignment (assignedBy) and
the order's creator. Nobody is notified about their own action.
| Kind | When | Recipient |
|---|---|---|
WORK_ORDER_ASSIGNED | assigned or reassigned | the new assignee |
WORK_ORDER_UNASSIGNED | reassigned or unassigned | the previous assignee |
WORK_ORDER_ACCEPTED, WORK_ORDER_DECLINED | accept, decline | the Business |
WORK_ORDER_STARTED | ACCEPTED → IN_PROGRESS | the Business |
WORK_ORDER_PROGRESS | the assignee adds a note (E08) | the Business; at most one per order per recipient per hour |
WORK_ORDER_HOLD_REQUESTED | :request-hold | the Business |
WORK_ORDER_COMPLETED | :complete | the Business |
WORK_ORDER_COMPLETION_REJECTED | :reject-completion | the Installer |
WORK_ORDER_VERIFIED | :verify | the Business |
WORK_ORDER_ON_HOLD, WORK_ORDER_RESUMED | :wait, :resume | the Installer and the Business |
WORK_ORDER_CLOSED, WORK_ORDER_CANCELLED | :close, :cancel | the Installer and the Business |
WORK_ORDER_STATUS | any other status change | the creator, unless one of the items above already reached them |
There is no _REASSIGNED kind: a reassignment sends WORK_ORDER_UNASSIGNED to
the previous Installer and WORK_ORDER_ASSIGNED to the new one. Crown staff
monitor through the activity history and the Crown-wide list,
not their inbox: fanning every Business's events out to every platform member
would cost one write per event per member.
These items are written on the request path right after the change
(best-effort, since 2026-11-05), so they arrive even though no stage deploys
the stream-router yet (KI-43). The ids are
deterministic, so when the stream-router does run, its copy of the same
change is a no-op. WORK_ORDER_PROGRESS ids embed the hour, so later notes in
the same hour create nothing.
Counters and search on the request path (ADR 0023 D10)
The E02 counters (per Business, and Crown-wide under ORG#ALL), the
COUNT#WOSTATUS#<status> per-status counters and the E01 q search tokens
used to be written only by the stream-router, which no stage deploys
(KI-43). Since v2 they are applied right after
each order write (create, action, E05, and orders a maintenance plan
creates), by the same projector code
(packages/core/src/service/wo-projection-bridge.ts), with one dedup id per
order version. Plan-created orders were not counted before 2026-11-12 (fixed,
not deployed yet), so counters can be low after a plan run; the backfill with
--counters corrects them. This is best-effort: a failure is logged and never fails the
request. If the stream-router is deployed later, its copy is a no-op. Counters
of orders written before v2 are rebuilt by the backfill with --counters.
E07 — Bulk: POST /v1/work-orders:bulk-assign · :bulk-reschedule · :bulk-cancel · :bulk-create
The URL the client calls is exactly as shown. API Gateway cannot register a : in a route key (CR-2), so these are served by the shared POST /v1/{collection} route (PlantsCollectionAction), which splits work-orders:<verb> out of the path; any other collection or verb is 404.
AuthZ service ≥ MANAGE @plant for every affected plant, checked
before any write. Idempotency R.
| Verb | Body |
|---|---|
bulk-assign | {workOrderIds: ULID[1..50], technicianSub, teamId?, reason?: 1–1000}. reason follows :assign: an item that already has another assignee fails with 422 without it |
bulk-reschedule | {workOrderIds, plannedVisitAt} |
bulk-cancel | {workOrderIds, reason, note?} |
bulk-create | {items: [{plantId, deviceSerial?, alert, title?, priority?, workType?}] (1..50), technicianSub?} (deviceId = deprecated alias) |
200 { results: [{id|index, ok: true, workOrder} | {id|index, ok: false, error: {code, message, details?}}] } even when some items fail. 403 FORBIDDEN with details.deniedPlantIds (≤ 20) means nothing was applied.
422 LIMIT_EXCEEDED (> 50) / VALIDATION_FAILED (incl. duplicate ids).
Per-item codes: NOT_FOUND, INVALID_STATE, VERSION_CONFLICT,
VALIDATION_FAILED, ALREADY_EXISTS.
E08 — Timeline: POST / GET /v1/work-orders/{workOrderId}/events
-
POST (progress note):
service ≥ EDIT @plantor the assigned Installer at any level, Idempotency R, 300 notes/hour/user (429 RATE_LIMITED). Body:Field Rules text1–2000, required visibilityINTERNAL(default) |CUSTOMERkindADR 0023 D5: GENERAL(default, the pre-v2 note),FINDING,DIAGNOSIS,WORK_PERFORMED,MATERIAL,ISSUE,INSTRUCTION_REQUESTmaterialonly with kind: MATERIAL(422otherwise):{name 1–200, quantity? > 0 (≤ 100000), serialNumber? 1–64, replacedSerialNumber? 1–64}201with theNOTEevent. A typed note stores{kind, material?}in the event'sdata; aGENERALnote keeps the pre-v2 shape. A note by the assigned Installer sendsWORK_ORDER_PROGRESSto the Business (at most once per order and recipient per hour).409 INVALID_STATEon aCLOSEDorCANCELLEDorder (details.reason: CLOSED) or a read-only one;422 LIMIT_EXCEEDED(> 1,000 events).// illustrative example request body, derived from AddWorkOrderNoteInput in packages/core/src/schemas.ts{ "text": "Replaced the AC surge protector.", "kind": "MATERIAL","material": { "name": "AC SPD Type 2", "quantity": 1, "serialNumber": "SPD-2291", "replacedSerialNumber": "SPD-0457" } } -
GET:
service ≥ VIEW @plant;limit(default 15 on the first page, 10 with acursor),cursor; chronological ascending; customer audience seesCUSTOMERevents only.{items: WorkOrderEvent[], nextCursor?}.
E09 — Attachments
Bytes never pass through the API. Flow:
POST /v1/work-orders/{id}/attachments—service ≥ EDITor the assigned Installer, Idempotency R, 120 presigns/hour/user. Body{kind: PHOTO|DOCUMENT|SIGNATURE, contentType: image/jpeg|image/png|application/pdf, sizeBytes ≤ 20 MiB, label? ≤ 120, visibility?}. ASIGNATUREmust beimage/pngand ≤ 1 MiB.201with aPENDINGattachment and a presignedPUT(≤ 15 min).- Client
PUTs the bytes toupload.urlwith exactly the returned headers. POST …/attachments/{attachmentId}:confirm— EDIT or the assignee, Idempotency O. ServerHEADs the object, copies it to its final key and flips itREADY(+ATTACHMENT_ADDEDevent).409 INVALID_STATE(OBJECT_MISSING, or notPENDING);422 VALIDATION_FAILED(SIZE_MISMATCH/TYPE_MISMATCH— the object is deleted, start again).GET …/attachments/{attachmentId}— VIEW;{attachment, download: {url, expiresAt}}(≤ 5 min).404forPENDING/DELETEDand, for the customer audience,INTERNALattachments.DELETE …/attachments/{attachmentId}— EDIT or the assignee, noIf-Match;204.409 INVALID_STATE(SIGNATURE_OF_COMPLETED_ORDER) for the signature of an order that has a completion, or for a read-only order. Soft delete;ATTACHMENT_REMOVEDevent.
// illustrative example, derived from the schema/handler code; URL is a placeholder
{ "attachment": { "attachmentId": "01J…", "status": "PENDING", "kind": "PHOTO", "contentType": "image/jpeg", "sizeBytes": 812334 },
"upload": { "method": "PUT", "url": "https://<presigned-url>", "headers": { "Content-Type": "image/jpeg", "Content-Length": "812334" }, "expiresAt": "…" } }
Limits: 30 attachments per order (422 LIMIT_EXCEEDED); type/size errors
422 VALIDATION_FAILED. Create, confirm and delete answer 409 INVALID_STATE on a CLOSED or CANCELLED order (details.reason: CLOSED,
ADR 0023) and on read-only orders. Unconfirmed uploads expire from the
bucket's pending/ prefix after 1 day. Without the bucket configured
(SERVICE_FILES_BUCKET unset) every E09 call answers 503 DEPENDENCY_UNAVAILABLE before any write.
Service requests (retired)
ADR 0023 D12 (LC-17) removed the service-request routes that ADR 0019 (WO-7) added on 2026-11-04. End users no longer submit anything: they phone their Business, which creates the order with E03. Removed from the API stack:
POST /v1/plants/{plantId}/service-requestsGET /v1/orgs/{orgId}/service-requestsGET /v1/me/service-requestsGET /v1/service-requests/{requestId},:accept,:declinePOST /v1/service-requests/{requestId}/attachmentsand…/attachments/{attachmentId}(:confirm,GET)
SERVICE_REQUEST_SUBMITTED and SERVICE_REQUEST_DECIDED inbox items are no
longer produced; older ones stay readable until their 90-day expiry. Nothing
is deleted: existing SR#… items stay in the table, and orders created from a
request keep source: SERVICE_REQUEST and serviceRequestId. The handler and
core service remain in the code tree, unreachable. Until the next deploy,
dev still serves these routes.
Related
- Plans, history, roster and plant service tab (E10–E13)
- Lifecycle v2 backfill (operations)
- Infrastructure: planned service resources
Web console additions
See Web console additions (N-37 … N-51) for the newer, not-yet-deployed fields and routes on this area.