Account suspension and removal (ADR 0036)
Status (2026-11-27): built on dev in cse-http-be, not deployed yet. Decision record:
docs/adr/0036-account-suspension-and-removal.md in cse-http-be. Where this page disagrees with
RBAC v2 or an older page, this page wins.
Every account has two actions: Suspend ⇄ Activate (reversible) and Remove (final). There is no Block, no Reopen, and no account action that stops a plant or its devices.
Suspend / Activate
| Who acts | On whom | Route | Rule |
|---|---|---|---|
| Super Admin, Administrator | End User | POST /v1/orgs/{orgId}/members/{sub}:suspend / :restore | Allowed. |
| Business owner | End User | same | Refused — 403 FORBIDDEN END_USER_CROWN_ONLY. A Business only attaches or detaches End Users. |
| Super Admin only | Administrator | same, in the Crown org | An Administrator acting on an Administrator → 403 FORBIDDEN SUPER_ADMIN_ONLY. |
| Super Admin | Super Admin | same | Allowed; the last ACTIVE Super Admin is protected (409 INVALID_STATE). |
| Super Admin, Administrator | Business | POST /v1/orgs/{crownOrgId}/businesses/{businessOrgId}:suspend / :restore | See below. |
The client labels :restore Activate.
Suspending a Business
:suspend: the Business becomes SUSPENDED and every ACTIVE Installer becomes SUSPENDED too, recorded assuspendedBy: { platform: true, byBusiness: true }(member rows showsuspendedByPlatform: true).- The Business owner is locked out by the Business status (
403 BUSINESS_SUSPENDED); their membership is not changed. - End Users are not changed. They, their plants and their devices keep running; they stay in the suspended Business.
:restore: the Business becomes ACTIVE and only the Installers suspended with it become ACTIVE. An Installer suspended on their own before the Business was suspended stays suspended.
Remove
| Who is removed | Route | What happens |
|---|---|---|
| Installer | members/{sub}:remove or installers/{sub}:detach | Membership REMOVED; they return to their personal org (plants they brought in go with them). The Business owner becomes the assigned Installer of every plant assigned to them and the assignee of their open work orders (system actor, reason INSTALLER_REMOVED). Plants they owned go to the owner. Their End Users stay in the Business. |
| End User | members/{sub}:detach or :remove | Every plant whose customer they are moves to their personal org — the ones they brought in and the ones the Business transferred to them. They stay the plant owner, the transfer link is removed, and they become independent. The Business and its Installers keep none of these plants. The Business's open work orders on them are cancelled. |
| Business | businesses/{businessOrgId}:close (label Remove business) | Every member is removed as above, so every End User takes their plants home. CLOSED is final. |
| Business owner, Administrator, Super Admin | members/{sub}:remove | Subject to the hard rule below. |
Hard rule: never-shared plants first
An account is not removed while it owns plants that no End User has (no customer on the plant):
- removing the Business owner (Business role) or a Crown Administrator / Super Admin checks the plants they own in that org;
:closeof a Business checks every plant in the Business.
Refusal: 409 CONFLICT, details.reason: "OWNS_UNSHARED_PLANTS", details.count, details.plantIds (at most
20). Delete those plants (their devices are released by the plant delete path) or transfer them to someone else
(POST /v1/orgs/{orgId}/plant-transfers), then retry.
There is no business-admin role: the Business owner is the Business's admin. Independent End Users have no account deletion route in this API.
Retired routes
| Route | Now |
|---|---|
POST /v1/orgs/{crownOrgId}/users/{sub}:block | 410 GONE, details.reason: "BLOCK_RETIRED". :unblock and GET …/users/{sub}/block remain only to release accounts blocked before. |
POST /v1/orgs/{crownOrgId}/businesses/{businessOrgId}:reopen | 410 GONE, details.reason: "REOPEN_RETIRED". |
Example error (illustrative, derived from the handler code; not a captured response — not deployed yet):
{ "error": { "code": "CONFLICT", "message": "2 plant(s) are not shared with any End User — delete them (with their devices) or transfer them to someone else first", "details": { "reason": "OWNS_UNSHARED_PLANTS", "count": 2, "plantIds": ["01J…", "01J…"] } } }
TCP side
No new event type. Moved plants emit plant.upserted.v1 with the new operatorOrgId; a reassigned plant emits
plant.upserted.v1 plus access.revoked.v1 (INSTALLER_REASSIGNED) for the removed Installer. Suspensions emit
access.revoked.v1 per affected user, as before. Plants frozen by an earlier Block B stay frozen until :unblock.
Known gaps
- No backfill: Installers of a Business suspended before this change are not marked SUSPENDED, and plants an earlier detach left in a Business stay there.
- Plant and work-order reassignment on Installer removal is best effort per item (logged and skipped on a race); fix a skipped item with the normal assign routes.