Skip to main content

Invitations API (B11/B12)

Feature 003 (Organisations, Team & Access), user story 4. Invites a person into an organisation by email, lists/resends/revokes pending invitations, and lets the invitee accept.

:::caution Code-complete, not yet captured against a real deployment All five routes (lib/routes.ts, packages/api/src/handlers/ invitations.ts/invitation-accept.ts, packages/core/src/repositories/ invitations.ts) are landed and unit-tested as of 2026-10-02. Every request/response example below is still illustrative — derived from the schemas and handler source, not a captured execution against a running dev stack. :::

Overview​

OpMethod + path (real wire route)AuthIdempotency
CreatePOST /v1/orgs/{orgId}/invitationsteam ≥ MANAGE, or delegated (see below)Required
ListGET /v1/orgs/{orgId}/invitationsteam ≥ MANAGE—
ResendPOST /v1/orgs/{orgId}/invitations/{inviteId} (verb :resend embedded in the {inviteId} path value — see Edge cases)team ≥ MANAGENone (see Edge cases)
RevokeDELETE /v1/orgs/{orgId}/invitations/{inviteId}team ≥ MANAGE—
EditPATCH /v1/orgs/{orgId}/invitations/{inviteId}as create— (versioned)
PreviewPOST /v1/invitations:previewAny signed-in callerNone
AcceptPOST /v1/invitations:accept (the bare POST /v1/invitations is a backward-compatible alias — see Edge cases)Any signed-in caller — no org context, no team/role checkNone
DeclinePOST /v1/invitations:declineAny signed-in caller (verified email must match)None
My invitationsGET /v1/me/invitationsAny signed-in caller with a verified email—
Accept / decline mine by idPOST /v1/me/invitations/{inviteId}:accept / :declineAny signed-in caller (only their own invitations)None
Account checkPOST /v1/orgs/{orgId}/account-checks (2026-11-30)per purpose (see the section)None

Resend, revoke and edit are versioned (If-Match/ETag), same mechanism as Team's PATCH .../members/{sub}. Create, resend and accept are strict routes (CR-13).

Authentication and authorization​

Create/list/resend/revoke all require an {orgId}-scoped caller with team ≥ MANAGE in that org — same boundary as Team, driven through the same requireOrgLevel primitive, so the same role table applies (Super Admin, Administrator and Business reach it; the Installer template does not). Inviting with the retired Viewer role is 422 VALIDATION_FAILED, details.reason: "ROLE_RETIRED" (field roleId), on create and on PATCH. A Super Admin skips the escalation check (R-0). The delegated-invite cap (no category above Administrator) now admits the Business role, because Administrator holds at least every Business level since 2026-11-03.

Installer path (ADR 0021 §3, IO-7.2). A member whose role was minted from the Installer template may invite End Users into its Business org without team:

  • the role must be the built-in End User (roleId 01M6R61YX1RZXDSYWBKTRYPKKR), else 403 FORBIDDEN details.reason: "INSTALLER_END_USER_ONLY";
  • the scope must be PLANTS, else 422 VALIDATION_FAILED details.reason: "INSTALLER_SCOPE_PLANTS_ONLY"; since ADR 0033 (2026-11-27) the target list may be empty, because the End User's own plants join the scope on accept;
  • every plant must be inside the Installer's own scope or assigned plants, else 403 FORBIDDEN details.reason: "INSTALLER_SCOPE" with details.invalidTargets;
  • the escalation check still applies.

Business user (ADR 0033, fixed 2026-11-27). A team ≥ MANAGE member of the Business (the Business role) may also invite the End User role — the End User join request. Only email, roleId and scope are needed (displayName is optional). The scope must be PLANTS (targets may be empty, or Business plants), else 422 VALIDATION_FAILED details.reason: "END_USER_SCOPE_PLANTS_ONLY". Before this fix the call was 403 ROLE_NOT_ASSIGNABLE. A member role change to End User is still refused for a Business user.

The same Installer may resend, revoke and edit only End User invitations it created itself; any other invitation reads 404. There is no other role-based allow-list: the level rule (team ≥ MANAGE plus escalation) is the contract (IO-6). So a Business user with team = MANAGE can still invite another Business-level member.

End User join request (ADR 0033, 2026-11-27). A Business user or one of its Installers asks an End User to join by creating an invitation with the End User role. The End User sees it in GET /v1/me/invitations and gets an INVITATION_RECEIVED inbox item and push whose body reads "Accepting shares all your plants with Business name. This request expires in 24 hours."

  • Consent: nothing changes until POST /v1/me/invitations/{inviteId}:accept. :decline changes nothing.
  • All plants: on accept, every plant of the End User's personal org moves into the Business (ADR 0026 D5). The End User does not pick plants.
  • Expiry: 24 hours after create or resend (then EXPIRED).
  • One Business: if the invited address belongs to an account (verified or not) already in another Business, create and resend return 409 CONFLICT details.reason: "ALREADY_IN_BUSINESS" (the other Business is not named). Crown staff are refused with details.reason: "CROWN_STAFF". An address with no account is checked when it is accepted instead.

Not executed against dev yet (not deployed); the rules above are read from packages/core/src/repositories/invitations.ts.

Personal orgs (ADR 0021 §5, IO-8) never take a member invitation, from anyone, Super Admin included: 422 UNSUPPORTED_OPERATION details.reason: "PERSONAL_ORG" on create, edit and resend. Share invitations (EXTERNAL, B13) out of a personal org are unaffected.

Delegated invitations (FR-045) are the other exception: a member of an operator organisation with customers ≥ MANAGE in their own org may invite someone into a CUSTOMER or PARTNER organisation related to it (an operator↔customer/partner relationship must already exist — an unrelated target org is 403 FORBIDDEN), as long as the granted role holds no category level above Administrator (canDelegateInvite, packages/core/src/access/policy.ts) — granting, say, a role with firmware: FULL via a delegated invite is 403 FORBIDDEN details.reason: "ESCALATION". A normal (non-delegated) invite is instead checked against the FULL FR-031 rule: no category above the caller's OWN current role, Super Admin exempt (wouldEscalate, same function Team uses for PATCH .../members/{sub}).

POST /v1/invitations:accept is different in kind: it needs no org context, team level, or role at all. Authorization IS the email match (below) — any signed-in Cognito identity may call it, and the response depends only on whether their account's email matches the invited address.

POST /v1/orgs/{orgId}/invitations​

Purpose: Invite a person by email with a role, scope and optional department/display name.

  • Side effects: one atomic transaction writes the INVITE item, an EMAIL# guard (which doubles as the "already a member or already invited" check — a conditional-write failure on it is the 409 ALREADY_EXISTS below), and one MEMBER_INVITED access-log entry. There is no daily invitation limit since RBAC v2 (ADR 0026, 2026-11-13).
  • Invitation notification: after the transaction, the invitee may get an INVITATION_RECEIVED inbox item and web push (only when the address belongs to an account with that email verified).
  • In-app only, no email (2026-11-17). Invitations are never emailed. The invitee sees pending invitations in the app with GET /v1/me/invitations (matched by their verified email) and answers with POST /v1/me/invitations/{inviteId}:accept or :decline. delivery is kept in the response for compatibility and is always { status: "NOT_SENT", attempts: 0 }.
  • acceptUrl: the response returns acceptUrl once, only in non-production stages, and only when the INVITE_LINK_BASE environment variable is set on the Lambda. It is a client deep link of the form <INVITE_LINK_BASE>#token=<token>: the token is in the URL fragment, which browsers never send to a server, so it cannot reach an access log (audit C2). The client reads the fragment and calls POST /v1/invitations:accept with { "token": … }. Never returned again on a later list/read.
  • Where INVITE_LINK_BASE comes from (as of 2026-11-03): CDK sets it on the invitations function to <shareLinkBaseUrl>/accept-invite, the web console's accept page, whenever the shareLinkBaseUrl context is set (see Operations). Unset, there is no acceptUrl; the invitee still accepts in-app. The variable holds one value per stage; it cannot point at both a deployed console and localhost.

Request​

Headers

HeaderRequiredValue
AuthorizationYesBearer <token>
Idempotency-KeyYes[A-Za-z0-9_-]{1,128}. Missing → 428 PRECONDITION_REQUIRED with details.header: "Idempotency-Key" — never 400 (CR-7).
Content-TypeYesapplication/json

Path parameters: orgId (ULID).

Request body

FieldTypeRequiredNotes
emailstringYesNormalised server-side (trimmed, lower-cased) before storage/guard use; ≤ 254 chars.
displayNamestringNo≤ 120 chars.
departmentIdULIDNoMust be a department of this organisation, else 422 VALIDATION_FAILED, message departmentId must be a department of this organisation, details: { field: "departmentId" }
roleIdULIDYesSubject to the escalation rules above.
scope{ kind, targets[] }YesSame shape and per-kind target caps as Team's PATCH body (≤10 REGION/TAG/CUSTOMER, ≤500 PLANTS). For an Installer-type role (a custom SCOPED role in a Business org) the value is ignored and NONE is stored (Role boundaries, 2026-11-12).

Strict (.strict() Zod): an unknown field is 422.

Response​

{
inviteId: string; // ULID
status: "PENDING";
expiresAt: string; // +7 days (internal/delegated) or +30 days (external — see Edge cases)
delivery: { status: "NOT_SENT" | "SENT" | "FAILED"; at?: string; attempts: number };
acceptUrl?: string; // non-production stages ONLY, this response only
}

Successful response — illustrative example (dev stage)​

{
"inviteId": "01J9Z6A1B2C3D4E5F6G7H8J9K0",
"status": "PENDING",
"expiresAt": "2026-10-09T09:00:00.000Z",
"delivery": { "status": "NOT_SENT", "attempts": 0 },
"acceptUrl": "<INVITE_LINK_BASE>#token=<43-char-base64url>"
}

Failure responses​

StatuscodeWhenFE action
401— (gateway)Missing/invalid tokenRe-authenticate
403FORBIDDENInsufficient team/customers level; no relationship to a delegated target org; or details.reason: "ESCALATION"Don't retry; the caller can't grant this
403FORBIDDENdetails.reason: "ROLE_NOT_ASSIGNABLE" — the role cannot be granted in this kind of org (Crown: Super Admin, Administrator, custom roles; Business: custom roles, plus End User on an invitation (Business user, Installer path or Super Admin; ADR 0033) — never on a member role change; customer/personal org: End User only — Role boundaries, 2026-11-12). Also on PATCH …/invitations/{inviteId}Offer only the roles GET …/roles lists for this org; in a Business org, offer End User on the add-customer / join-request flow
403FORBIDDENdetails.reason: "PLATFORM_PERSONAL_ORG" — a personal account opened only through the platform fallback; platform staff cannot create lasting access there (revalidation 2026-11-03)Don't retry; the action is not available to platform staff here
403FORBIDDENdetails.reason: "BUSINESS_ROLE_VIA_CREATE_ONLY" — the Business role in a Business org (2026-11-30, BR-4 / product decision D-3). A Business owner is invited only by POST …/businesses; applies to every caller, Crown staff included. Promoting an existing member (PATCH …/members/{sub}) is unchangedDon't offer the Business role in the invite drawer
409ALREADY_EXISTSThe email is already an ACTIVE/SUSPENDED member or has a PENDING invitation in this orgShow the existing member/invitation instead
409CONFLICTdetails.reason: "ALREADY_IN_BUSINESS" — the address belongs to an account (verified or not, since 2026-12-01) that already belongs to another live Business; details.reason: "CROWN_STAFF" — the address is Crown staff (target is a Business). Since 2026-11-30 (BR-3) for every role into a Business (Installer-type included), not only End User; also on :resendTell the inviter; the person must be removed by the other Business first
422VALIDATION_FAILEDBody shape, scope-kind-not-allowed-for-org, invalid scope targets — same reason set as Team's B05Depends on reason
422UNSUPPORTED_OPERATIONdetails.reason: "PERSONAL_ORG" — personal orgs never take a member invitationPick a Business
428PRECONDITION_REQUIREDIdempotency-Key missing (details.header: "Idempotency-Key")Generate a key, retry
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer/dependency errorRetry with backoff

Edge cases​

  • No daily limit: the 50-invitations/day bucket was removed by RBAC v2 (ADR 0026, deployed to dev 2026-11-13). Create, resend and Business create never answer 429 for this reason.
  • No department: omit departmentId; the member joins with no department.
  • Check first: the console checks the invitee with POST …/account-checks purpose: "INVITATION" before it creates the invitation. The create still runs every check itself.
  • Duplicate-email check is a single guard key, not a scan: EMAIL#<sha256(emailNorm)> under the org, conditionally created by this write and pointing at INVITE#<inviteId> until accept/revoke repoints or frees it.
  • Expiry: 24 hours for an End User invitation (ADR 0033, see "End User join request" below); otherwise 7 days for an INTERNAL invite (same org) or DELEGATED invite (operator inviting into a related org); 30 days for EXTERNAL (share-by-email — not creatable through this endpoint at all today, see below).
  • EXTERNAL invitations are not created here. The landed createInvitation only ever produces INTERNAL (when the caller's own org equals orgId) or DELEGATED (when it doesn't, via the FR-045 path) — never EXTERNAL. Share-by-email (B13) is a separate, not-yet-built code path.
  • The access-log entry's actor display name is currently the caller's sub, not a real profile lookup. Same simplification on resend's INVITATION_RESENT entry. Cosmetic only — doesn't affect authorization or the response body — but don't be surprised to see a sub where a human name is expected in the access log.

GET /v1/orgs/{orgId}/invitations​

Purpose: The Invitations tab — every pending/past invitation for the org.

Request​

Query parameters

NameRequiredTypeNotes
statusNoPENDING|ACCEPTED|REVOKED|DECLINED|EXPIREDEXPIRED is derived at read time from expiresAt, never stored. DECLINED (IO-1) is final.
kindNoINTERNAL|EXTERNAL|DELEGATED
qNostring, 1–64 chars2026-11-25 (console review §4.2, deployed to dev). Any part of the invitee's email (lower-cased; a substring match since 2026-12-01, F8 — crown matches admin1@crowngroup.com) or a prefix of their name (the normalised name the People list sorts by). An accepted, revoked or declined invitation has dropped the name index, so only its email matches.
roleIdNoULID2026-11-25. Only invitations on this role.
departmentIdNoULID2026-11-25. Only invitations into this department.
limitNointeger 1–50; default 15 on the first page, 10 with a cursor (lazy loading)

Response​

{
items: Array<{
inviteId: string;
kind: "INTERNAL" | "EXTERNAL" | "DELEGATED";
emailMasked: string; // always masked — this list is team >= MANAGE only, no unmasked tier
displayName?: string;
role?: { roleId: string; name: string };
status: "PENDING" | "ACCEPTED" | "REVOKED" | "DECLINED" | "EXPIRED";
expiresAt: string;
delivery: { status: "NOT_SENT" | "SENT" | "FAILED"; at?: string; attempts: number };
sendCount: number; // 1 on create, +1 per resend
invitedBy: string; // NOTE: currently a bare identifier (sub), not {sub, displayName} — see Edge cases
version: number; // N-45: always present; the If-Match value for resend / revoke / PATCH
}>;
// no nextCursor today — see Edge cases
}

Failure responses​

StatuscodeWhen
401— (gateway)Missing/invalid token
403FORBIDDENteam < MANAGE
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer/dependency error

Edge cases​

  • No pagination yet. The landed listInvitations runs one bounded Query capped at limit with no cursor support — there is no nextCursor field at all today, unlike every other list endpoint in this API. Documented limitation (same shape Team's q-search path uses), not a bug — a follow-up once an org has enough invitations for it to matter.
  • invitedBy is a bare string (the inviter's sub), not the {sub, displayName} object the contract originally sketched — resolve a display name client-side via the People list if needed.
  • emailMasked here has no unmasked tier (unlike Team's People list at team ≥ MANAGE) — this whole route is already team ≥ MANAGE only, so masking is applied unconditionally.

POST /v1/orgs/{orgId}/invitations/{inviteId}:resend​

Purpose: Rotates the token (old one dies immediately), resets the expiry clock, and increments sendCount.

:::info Real wire route has no :resend in the URL template (CR-2) API Gateway can't register a path template containing a literal : segment, so the deployed route is POST /v1/orgs/{orgId}/invitations/{inviteId} — the SAME path+method as every other {inviteId} request. The verb travels as part of the path parameter's VALUE: send the request to POST /v1/orgs/{orgId}/invitations/<inviteId>:resend literally (colon and all, in the URL), and the server splits <inviteId>:resend on the first colon (parseActionSegment) before anything else runs. An unknown or missing verb (e.g. hitting the bare {inviteId} with POST and no verb at all) is 404 NOT_FOUND, same as any unmatched route — not a 400. :::

  • Side effects: one transaction overwrites tokenHash/the GSI1 token-lookup attrs/expiresAt/delivery (reset to NOT_SENT) and bumps sendCount, plus one INVITATION_RESENT access-log entry. No rate limit (removed by RBAC v2, ADR 0026). The web console labels this action "Renew invitation" — for an in-app invitation its effect is the new expiry.
  • Invitation notification: a renewal writes a NEW INVITATION_RECEIVED item for the invitee (when they have an account with that email verified) and marks the previous one read.

Request​

Headers: If-Match required (a stale value is 409 VERSION_CONFLICT, missing is 428, malformed is 400 — same as Team's PATCH). No Idempotency-Key behavior — despite the original spec contract listing it as optional, it is not wired through the idempotency mechanism for this route today (lib/routes.ts's idempotency: 'none'); a resend has no create-time duplicate-request hazard, only token rotation, so this was a deliberate simplification, not an oversight. Path: orgId, inviteId (ULID — the real request sends <inviteId>:resend as its value, see above).

Response​

Same shape as create above, with a NEW expiresAt/acceptUrl and the old token no longer resolving to anything (its GSI1 entry is overwritten, not merely marked dead — a lookup against it behaves exactly like an unknown token).

Failure responses​

StatuscodeWhen
401— (gateway)Missing/invalid token
403FORBIDDENteam < MANAGE
404NOT_FOUNDinviteId doesn't exist in this org
409VERSION_CONFLICT / INVALID_STATEStale If-Match, or the invitation is not PENDING (already accepted/revoked/concurrently resent)
428PRECONDITION_REQUIREDIf-Match missing
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer/dependency error

DELETE /v1/orgs/{orgId}/invitations/{inviteId}​

Purpose: Revoke a pending invitation.

  • Side effects: one transaction sets status: REVOKED (revokedAt/ revokedBy recorded) and deletes the EMAIL# guard, freeing the address to be re-invited immediately — plus one INVITATION_REVOKED access-log entry. The record is kept, never deleted.

Request​

Headers: If-Match required. Path: orgId, inviteId.

Response​

204 No Content.

Failure responses​

StatuscodeWhen
401— (gateway)Missing/invalid token
403FORBIDDENteam < MANAGE
404NOT_FOUNDinviteId doesn't exist in this org
409INVALID_STATEAlready accepted or revoked
428PRECONDITION_REQUIREDIf-Match missing
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer/dependency error

PATCH /v1/orgs/{orgId}/invitations/{inviteId}​

Edit the role, scope and/or department of a pending invitation (N-47). Handler patchInvitation in packages/api/src/handlers/invitations.ts, core patchInvitation in packages/core/src/repositories/invitations.ts. No execution captured; examples are illustrative.

  • AuthZ: same as create — team ≥ MANAGE on {orgId}, or the delegated operator path (FR-045), which may edit only invitations its own org sent (others → 404).
  • Headers: Authorization, X-Org-Id, If-Match (required: missing → 428, stale → 409 VERSION_CONFLICT). No Idempotency-Key — the version guards replays.
  • Body (strict, at least one field):
FieldTypeNotes
roleIdULIDSame role checks as create
scopeScopeSame scope checks as create. With an Installer-type role, a role or scope edit stores NONE; a department-only edit keeps the stored scope (2026-11-12)
departmentIdULID | nullnull clears the department (no check). A ULID must be a department of this organisation, else 422 VALIDATION_FAILED with details: { field: "departmentId" }
// illustrative example
{ "roleId": "01JB7R0000000000000000000R", "departmentId": null }

Response 200 + ETag:

{ inviteId: string; kind: "INTERNAL" | "DELEGATED"; status: "PENDING"; roleId: string; scope: Scope;
departmentId?: string; expiresAt: string; version: number }

Writes an access-log entry of type INVITATION_UPDATED.

StatuscodeWhen
401— (gateway)Missing/invalid token
403FORBIDDENNot allowed to invite here; or details.reason: "ESCALATION" — the new role/scope grants more than the caller holds (delegated: more than Administrator)
403FORBIDDENdetails.reason: "PLATFORM_PERSONAL_ORG" — personal account reached only through the platform fallback
403FORBIDDENdetails.reason: "BUSINESS_ROLE_VIA_CREATE_ONLY" — changing the role to Business (2026-11-30, BR-4). The owner invitation that POST …/businesses created keeps its Business role through a scope or department edit
404NOT_FOUNDUnknown invitation, another org's invitation on the delegated path, or unknown role
409INVALID_STATENot pending (accepted/revoked/expired), or an EXTERNAL (share) invitation — change the share instead
409VERSION_CONFLICTStale If-Match
422VALIDATION_FAILEDEmpty body, unknown field, bad scope for the role/org
428PRECONDITION_REQUIREDNo If-Match

POST /v1/invitations:preview​

Read-only look at an invitation before deciding (N-42, IO-2). Served by POST /v1/{collection} (packages/api/src/handlers/plants-write.ts → preview in invitation-accept.ts). No execution captured; examples are illustrative.

  • Auth: any signed-in caller. No X-Org-Id, no Idempotency-Key.
  • Body (strict): { "token": "<43 base64url chars>" } — the token from the invite link, never in the URL.
  • A live token (PENDING, not expired) previews for anyone holding it, with status: "PENDING". So a person signed in with another account still sees which Business invited them, and invitedEmailMasked tells them which account to use.
  • A used token (accepted, declined, revoked, expired) previews with its real status only when the caller's verified email is the invited one. Anyone else, and any unknown or resent-away token, gets the same uniform 404, so the endpoint can't be used to probe.
  • scope is a display-only summary, the same targetsLabel as the member scope summary. It is null for a share invitation.
  • Invitations are never emailed (2026-11-17). A resend rotates the token, so an earlier acceptUrl stops working; the in-app list is unaffected.

Response 200:

// illustrative example — derived from the schema, not a captured execution
{ "kind": "INTERNAL", "org": { "name": "Sunrise Solar" }, "role": { "name": "End User" },
"scope": { "kind": "PLANTS", "targetsLabel": "2 plants" },
"inviter": { "displayName": "Ayesha K." }, "invitedEmailMasked": "a***@example.com",
"expiresAt": "2026-11-13T10:00:00.000Z", "status": "PENDING" }

role, scope and inviter may be null. status is one of PENDING, ACCEPTED, DECLINED, REVOKED, EXPIRED.

StatuscodeWhen
401— / UNAUTHENTICATEDNot signed in
404NOT_FOUNDUnknown or resent-away token, or a used token previewed by anyone but the invitee
422VALIDATION_FAILEDMissing/malformed token or extra fields
429RATE_LIMITEDMore than 30 previews per minute per caller (Retry-After)

POST /v1/invitations:decline​

The invitee declines (IO-1, ADR 0021 §1). Served by POST /v1/{collection} (plants-write.ts → decline in invitation-accept.ts). Not yet executed against dev.

  • Auth: any signed-in caller, no X-Org-Id, no Idempotency-Key (a repeat is 409). Body (strict) { "token": "…" }, never in a URL.
  • Checks, in the same order as accept: 404 unknown or resent-away token; 409 INVALID_STATE no longer PENDING; 410 GONE expired; 403 FORBIDDEN the account's verified email is not the invited one (or is unverified), with the invitation left PENDING.
  • Side effects (one transaction):
    • the invitation becomes DECLINED (declinedAt, declinedBy) and leaves the People list;
    • the EMAIL# guard and the invitee inbox entry are deleted, so the inviter can send a new invitation;
    • one INVITATION_DECLINED access-log entry is written in the inviting org.
  • DECLINED is final: accept, resend or revoke afterwards is 409.
  • Decline never creates or changes a membership, the Cognito account or the personal org.
  • A share invitation (kind: EXTERNAL) is not declined here: 422 UNSUPPORTED_OPERATION, details.reason: "SHARE_INVITATION".
// illustrative 200
{ "inviteId": "01JC…", "status": "DECLINED", "org": { "name": "Sunrise Solar" } }

GET /v1/me/invitations​

The caller's own PENDING, unexpired INTERNAL/DELEGATED invitations, addressed to their verified email, newest first (IO-4, ADR 0021 §6). It lets a person who signed in without the link (lost email, another device) still find and decide their invitations.

  • Auth: any signed-in caller. No verified email → 403 FORBIDDEN.
  • Query: limit (1–50; default 15 on the first page, 10 with a cursor (lazy loading)) and cursor only.
  • Reads the invitee inbox (INVITEE#<sha256(email)>, one Query), then re-checks each invitation. Never returns a token.
  • An invitation created before this route existed appears once it is resent (:resend writes the inbox entry).
// illustrative 200
{ "items": [ { "inviteId": "01JC…", "kind": "INTERNAL",
"org": { "orgId": "01JB…", "name": "Sunrise Solar" }, "role": { "name": "End User" },
"scope": { "kind": "PLANTS", "targetsLabel": "2 plants" },
"inviter": { "displayName": "Ayesha K." }, "expiresAt": "2026-11-13T10:00:00.000Z", "status": "PENDING" } ] }

Invitation notification (INVITATION_RECEIVED)​

Added and deployed to dev 2026-11-23 (web console request R1). Since invitations are in-app only, the invitee is told through the HTTP inbox (GET /v1/me/notifications) and a web push.

When: right after an INTERNAL or DELEGATED invitation is created (POST …/invitations, or a Business owner's invitation from POST …/businesses) or renewed (:resend). Share invitations (EXTERNAL) get none.

Who: the one account whose email is the invited address and is verified (one Cognito ListUsers per create or renewal). No account, an unverified email, or more than one account with that email → no item; the person sees the invitation in GET /v1/me/invitations once they sign up and verify the address (KI-28). An admin inviting their own address gets nothing.

Item (illustrative, derived from the code — not a captured execution):

{
"notificationId": "01JD…",
"kind": "INVITATION_RECEIVED",
"title": "You're invited to join Sunrise Solar",
"body": "Role: End User",
"link": { "type": "INVITATION", "id": "01JC…" },
"actor": { "displayName": "Ayesha K." },
"invitation": { "inviteId": "01JC…", "org": { "orgId": "01JB…", "name": "Sunrise Solar" }, "role": { "name": "End User" } },
"createdAt": "2026-11-23T10:00:00.000Z"
}
  • link has no orgId — the invitee is not a member yet. Accept or decline with POST /v1/me/invitations/{inviteId}:accept|:decline.
  • invitation.org / invitation.role are the names when the invitation was sent; role is null if the role could not be read. actor is the inviter's display name when their profile has one.
  • Web push: same transaction as the item, under the normal push rules (Notifications): link: "/", tag: "invite-<inviteId>", data.inviteId. Web endpoints exist only for End Users, so staff invitees get the inbox item only.
  • Lifecycle: accepting, declining or revoking the invitation marks the item read; a renewal adds a new item and marks the old one read. The item's TTL is the invitation's expiresAt, so it leaves the list when the invitation expires (the unread count may over-count briefly until the next full list repairs it).
  • Best-effort: the invitation write never fails because of the notice. A failure is logged (invitation_notice_failed, no email or sub in the log) and the invitation still shows in GET /v1/me/invitations.
  • Small race: if the invitee accepts in the instant between the item's write and storing its address, the item may stay unread until the invitation's expiry hides it.

POST /v1/me/invitations/{inviteId}:accept|:decline​

Accept or decline one of your own invitations by id, with no token needed (IO-4). The invitation is found only through your verified email's inbox, so someone else's id is 404. Same checks, transaction, access-log entry and response as the token routes. No body (422 if one is sent), no Idempotency-Key. Real wire route: POST /v1/me/invitations/{inviteId} with <inviteId>:accept as the path value (CR-2).

POST /v1/invitations:accept​

Purpose: The invitee accepts — attaches the invitation to their signed-in account.

:::info POST /v1/invitations:accept is callable; the bare POST /v1/invitations is an alias API Gateway matches POST /v1/invitations:accept to the catch-all POST /v1/{collection} route, whose handler dispatches invitations:accept to this operation (audit C1, live from the next deploy). The bare POST /v1/invitations serves the same operation and stays for backward compatibility. Neither takes an Idempotency-Key. Two further points:

  • No {token} path parameter, ever. The blueprint originally sketched POST /v1/invitations/{token}:accept (token as a path segment). This spec's own deviation D-09 supersedes that: the token travels in the request body instead ({ "token": "…" }), specifically so it never appears in a URL, CloudFront access log, or browser history (07-security.md §5 logging hygiene).

  • No {id} at all for the action route itself (CR-2). Unlike resend (which has a real {inviteId} to hang the verb off), accept has no id — the verb is the whole invitations:accept segment. :::

  • Authentication: Required — any signed-in Cognito identity. No org context, no team/role check at all. MFA is not required to accept (an org's own MFA requirement applies starting with the next request IN that org, not to this call).

  • Side effects (internal/delegated): one transaction marks the invitation ACCEPTED, creates (or reactivates, see Edge cases) the MEMBER item, repoints the EMAIL# guard from INVITE#<id> to MEMBER#<sub>, and writes one INVITATION_ACCEPTED access-log entry in the inviting org.

  • External invitations are not acceptable through this endpoint today. The landed acceptInvitation fails closed with 422 UNSUPPORTED_OPERATION for kind: "EXTERNAL" rather than silently no-op'ing — that flow (share/portal activation, B13) isn't built yet.

Request​

Headers: Authorization: Bearer <token> only — no X-Org-Id.

Request body

FieldTypeRequiredNotes
tokenstringYesExactly 43 characters, base64url (^[A-Za-z0-9_-]{43}$) — 32 raw bytes. Single-use.

Response​

{
orgId: string;
kind: "INTERNAL" | "EXTERNAL" | "DELEGATED";
membership?: MembershipSummary; // internal/delegated accept
share?: { shareId: string; level: string; operatorOrgName: string }; // external accept (not reachable yet — see above)
}

Failure responses​

StatuscodeWhenFE action
401— (gateway)Missing/invalid tokenRe-authenticate
403FORBIDDENThe signed-in account's email doesn't match the invited email (case-insensitive)Sign in with the right account; the invitation is untouched and still acceptable by it (X12)
404NOT_FOUNDUnknown token — a constant-time GSI1 hash lookup finds nothing. Deliberately the SAME shape as any other invalid-token case, so a client can't distinguish "wrong token" from "right token, wrong account" by response shapeShow a generic "this invitation link isn't valid" message
409INVALID_STATEAlready ACCEPTED, DECLINED or REVOKEDDon't retry
410GONEexpiresAt has passedAsk the inviter to resend
422UNSUPPORTED_OPERATIONkind: "EXTERNAL" — not acceptable here yetn/a (shouldn't be reachable from a real share-by-email link yet)
422LIMIT_EXCEEDEDAccepting would put the account over the 50-membership capLeave another organisation first
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer/dependency errorRetry with backoff

Edge cases​

  • Concurrent accepts of the same token: the invitation-status conditional update (PENDING → ACCEPTED) ensures exactly one of two simultaneous accept attempts wins; the loser sees INVALID_STATE (or, rarely, NOT_FOUND if the GSI1 projection hadn't caught up to the winner's write yet).
  • Existing account, never re-created (X13): if the invited email's accepting sub already has a (e.g. REMOVED) membership row in the target org, that row is reused in place — the MEMBER write's own condition is "not exists OR status REMOVED", never a blind overwrite of an ACTIVE row.
  • Email match is case-insensitive and compares against IdentityProvider.getUserContact(sub)'s verified account email — not a client-supplied value.
  • 50-membership cap is enforced on write, not only on read — a 51st accept is refused rather than silently exceeding the cap enforced elsewhere (access/loader.ts's own read-side MAX_MEMBERSHIPS).

POST /v1/orgs/{orgId}/account-checks​

Purpose (2026-11-30, BR-1): one read-only email → account check for the web console's three flows — Share Plant (PLANT_TRANSFER), Create Business (BUSINESS_OWNER) and the invite drawer (INVITATION). It answers who the email belongs to and whether the matching create / transfer would accept them. It replaces plant-transfer-checks, which stays as an alias of purpose: "PLANT_TRANSFER" until the console has moved, then is retired.

Code: handler checkAccountRecipient (packages/api/src/handlers/invitations.ts), core packages/core/src/access/account-check.ts (BUSINESS_OWNER, INVITATION) and plants/transfer-check.ts (PLANT_TRANSFER). Built on dev 2026-11-30; not deployed and no request captured yet — the examples below are illustrative, derived from AccountCheckResponse in schemas.ts.

Headers: Authorization: Bearer <token>, Content-Type: application/json. No If-Match, no Idempotency-Key. Nothing is written except the caller's rate-limit counter.

Body (strict JSON — the email stays out of URLs and access logs)

FieldTypePLANT_TRANSFERBUSINESS_OWNERINVITATION
purposePLANT_TRANSFER | BUSINESS_OWNER | INVITATIONrequiredrequiredrequired
emailstringrequiredrequiredrequired — trimmed, lower-cased, ≤ 254
plantIdULIDrequired422 if sent422 if sent
businessOrgIdULIDoptional, Crown staff (as today)422 if sentoptional — the target Business, Crown staff only (anyone else: 422); absent = {orgId}
roleIdULID422 if sent422 if sentrequired — the role the invitation would grant

Authorization (thrown before the email is read)​

A caller who could not do the real action gets an error, never eligible: false, and learns nothing about the email.

  • PLANT_TRANSFER — exactly plant-transfer-checks: the transfer's caller, mode and plant checks.
  • BUSINESS_OWNER — {orgId} must be the Crown PLATFORM org (409 INVALID_STATE otherwise); customers ≥ MANAGE and team ≥ MANAGE there, as on POST …/businesses.
  • INVITATION — the caller could create this invitation in the target org: the same caller resolution as POST …/invitations (team ≥ MANAGE; Crown staff through the platform fallback when businessOrgId is sent; the Installer path), then the role checks: 422 PERSONAL_ORG, 403 SUPER_ADMIN_ONLY, 403 ROLE_NOT_ASSIGNABLE, 403 INSTALLER_END_USER_ONLY, 403 BUSINESS_ROLE_VIA_CREATE_ONLY, 403 ESCALATION, 404 unknown role. A businessOrgId that does not exist is 404; one that is not a Business is 422 NOT_A_BUSINESS. BUSINESS_OWNER and INVITATION never read a plant.

Eligibility (200, eligible: false + reason)​

reasonPLANT_TRANSFERBUSINESS_OWNERINVITATION
USER_NOT_REGISTERED (found: false, no recipient)as before✔✔
ACCOUNT_BLOCKEDas before✔✔
MOVE_IN_PROGRESS (the person's plants are being moved; not resumed by the check)as before✔✔
USER_IN_ANOTHER_ORG, NOT_AN_END_USER, ALREADY_OWNER, LIMIT_EXCEEDED, MEMBER_NOT_ACTIVEas before——
CROWN_STAFF (new) — active Crown membership—✔✔ when the target is a Business
ALREADY_MEMBER (new) — active or suspended member of the target org (a REMOVED member may be invited again)——✔
ALREADY_IN_BUSINESS — member or owner (any role, suspended included) of a live Business; a CLOSED one does not count—✔✔ when the target is a Business and it is another Business
INVITATION_PENDINGas beforea pending Business-owner invitation anywherea pending invitation to the target org

The checks run in this order: blocked, move in progress, then (BUSINESS_OWNER) Crown staff, other Business, pending owner invitation — or (INVITATION) already a member, Crown staff, other Business, pending invitation. The first match is returned.

Rate limit: one per-caller bucket shared by every purpose and plant-transfer-checks: 20 checks per minute and 200 per day → 429 RATE_LIMITED with Retry-After.

Privacy: recipient has only the display name (null when none is set) and the normalised email you typed — no sub, org id or name, or phone. message never names another Business.

Not a guarantee: the create or transfer re-checks everything; handle its errors as before.

Response 200​

{
found: boolean;
recipient?: { displayName: string | null; email: string }; // only when found
eligible: boolean;
reason: AccountCheckReason | null; // null when eligible
message: string | null; // null when eligible; safe to show as is
}

Illustrative examples (derived from the schema, not captured executions)​

// POST /v1/orgs/<platformOrgId>/account-checks
{ "purpose": "BUSINESS_OWNER", "email": "owner@example.com" }
// 200 — the owner already belongs to a Business
{
"found": true,
"recipient": { "displayName": "Ali Khan", "email": "owner@example.com" },
"eligible": false,
"reason": "ALREADY_IN_BUSINESS",
"message": "This person already belongs to a business. They can own a new business only after that business removes them."
}
// POST /v1/orgs/<platformOrgId>/account-checks — Crown staff, invite drawer for Business X
{ "purpose": "INVITATION", "email": "installer@example.com", "roleId": "<Business X Installer role id>", "businessOrgId": "<Business X id>" }
// 200
{ "found": true, "recipient": { "displayName": null, "email": "installer@example.com" }, "eligible": true, "reason": null, "message": null }

Failure responses​

StatuscodeWhen
400MALFORMED_REQUESTBody is not JSON
401(gateway)Missing or invalid token
403FORBIDDENThe caller may not do the real action (see Authorization; details.reason where one applies)
404NOT_FOUNDNo membership in {orgId} (or the picked Business); plant, role or picked Business not found
409INVALID_STATE / CONFLICTPLANT_TRANSFER plant-side refusals; BUSINESS_OWNER with a non-PLATFORM {orgId}
422VALIDATION_FAILEDStrict body; a field the purpose does not take or a missing required one; businessOrgId from a non-staff caller; NOT_A_BUSINESS
422UNSUPPORTED_OPERATIONdetails.reason: "PERSONAL_ORG" (INVITATION into a personal org)
429RATE_LIMITEDOver 20/minute or 200/day for this caller (Retry-After)

Edge cases​

  • Check vs create agree (since 2026-12-01): both resolve any account with the email, verified or not, and the create refuses ALREADY_IN_BUSINESS and CROWN_STAFF exactly as the check reports them.
  • Create Business race: the owner check runs just before the create, not inside its transaction; an owner who joins another Business in between is refused when they accept the owner invitation.

POST /v1/orgs/{orgId}/businesses​

Purpose: create a Business (an OPERATOR organisation) and invite its owner on the built-in BUSINESS role, in one call (ADR 0014; built 2026-11-02). Used by the web admin console's "Business Management" screen. Nothing on this route has been run against a deployed stage yet.

Authentication: Cognito ID token from the web-console app client, Authorization: Bearer <token>.

Authorization

  • {orgId} must be the Crown PLATFORM organisation. Any other org: 409 INVALID_STATE.
  • The caller needs customers ≥ MANAGE and team ≥ MANAGE in that PLATFORM org (Super Admin and Administrator by default; team added 2026-11-03 because the route invites the owner). Below that: 403 FORBIDDEN.
  • A caller with no ACTIVE membership in {orgId}: 404 NOT_FOUND.
  • Since 2026-11-03 (R-3b) creating a Business is an ordinary grant: a caller who is not Super Admin must hold at least every level of the (effective) Business role, lowered by permsLimit if one is sent, and every permsLimit value. Otherwise 403 FORBIDDEN, details.reason: "ESCALATION". Administrator passes by default (it holds at least every Business level). A Super Admin is never refused.

Side effects (one DynamoDB transaction; a failure leaves nothing behind):

  • the new OPERATOR org, including its five seeded role templates (Installer among them);
  • a DELEGATED invitation for owner.email in the new org, role BUSINESS, scope ALL, expiring in 7 days;
  • an ORG_CREATED access-log entry in both the new org and the PLATFORM org;
  • with permsLimit: the Business limit (version 1) and BUSINESS_LIMIT_CHANGED in both access logs.

Owner must be an existing, eligible account (2026-11-30, BR-2). Before anything is written, owner.email is resolved to its account (Cognito, by email) and checked with the BUSINESS_OWNER rules of POST …/account-checks. A refusal creates nothing — no org, no invitation — and error.details.reason names the rule (see the failure table). Request and response bodies are unchanged. The check is a read before the write, not part of the transaction: if the owner joins another Business in between, the invitation is still created and the accept-time one-Business rule refuses it.

There is no daily invitation budget since RBAC v2 (ADR 0026, 2026-11-13). No email is sent: the owner finds the invitation in-app (GET /v1/me/invitations) and, when the address belongs to an account with that email verified, gets an INVITATION_RECEIVED inbox item and web push. invitation.delivery is always NOT_SENT.

Request​

Headers

HeaderRequiredValue
AuthorizationYesBearer <token>
Idempotency-KeyYes[A-Za-z0-9_-]{1,128}. Missing: 428 PRECONDITION_REQUIRED.
Content-TypeYesapplication/json

Path parameters: orgId (ULID of the PLATFORM org).

Request body (strict: an unknown field is 422)

FieldTypeRequiredNotes
namestringYesTrimmed, 1 to 120 chars.
countryCodestringYesISO 3166-1 alpha-2, upper-cased server-side.
timezonestringYesIANA zone, at most 64 chars, e.g. Asia/Karachi.
localestringNoBCP 47, 2 to 35 chars. Default en-PK.
currencystringNoISO 4217, upper-cased. Default PKR.
contactOrgContactNoSame shape as the org profile's contact (legalName, businessType, address, phone, ...; each at most 200 chars).
owner.emailstringYesTrimmed and lower-cased; at most 254 chars.
owner.displayNamestringNoAt most 120 chars.
permsLimitPermsLimit or nullNoSince 2026-11-03. The Business limit to start with; null or {} = none.

Response: 201 Created​

{
org: Organisation; // the new OPERATOR org, same shape as GET /v1/orgs/{orgId}
invitation: {
inviteId: string; // ULID
roleId: string; // the BUSINESS system role id
status: "PENDING";
expiresAt: string; // +7 days
delivery: { status: string; attempts: number };
acceptUrl?: string; // non-production stages only, this response only
};
}

Illustrative example (derived from the schema, not a captured execution)​

{
"org": { "orgId": "01JBZ0000000000000000000AA", "kind": "OPERATOR", "name": "Sunrise Solar", "...": "..." },
"invitation": {
"inviteId": "01JBZ0000000000000000000BB",
"roleId": "<BUSINESS role id>",
"status": "PENDING",
"expiresAt": "2026-11-09T09:00:00.000Z",
"delivery": { "status": "NOT_SENT", "attempts": 0 },
"acceptUrl": "<INVITE_LINK_BASE>#token=<token>"
}
}

Failure responses​

StatuscodeWhenFE action
400MALFORMED_REQUESTBody is not valid JSONFix the client
401(gateway)Missing or invalid tokenRe-authenticate
403FORBIDDENcustomers or team below MANAGE in the PLATFORM org; or details.reason: "ESCALATION" (R-3b, above)Hide the action
403FORBIDDENdetails.reason: "ACCOUNT_BLOCKED" — the owner's account is blocked (BR-2)Pick another owner
404NOT_FOUNDNo ACTIVE membership in {orgId}Treat as no access
409INVALID_STATE{orgId} is not the PLATFORM orgCall with the PLATFORM org id
409CONFLICTBR-2, details.reason: ALREADY_IN_BUSINESS (the owner belongs to a live Business), INVITATION_PENDING (the owner already has a pending Business-owner invitation), CROWN_STAFF (active Crown membership), MOVE_IN_PROGRESS (the owner's plants are being moved — retry in a minute). Nothing createdShow error.message; pick another owner or resolve the conflict
422VALIDATION_FAILEDdetails.reason: "USER_NOT_REGISTERED" — no account uses owner.email (BR-2); nothing createdAsk the owner to sign up in the app first
409ALREADY_EXISTSowner.email already has a PENDING invitation in the new org. Practically impossible for a brand-new org, but the guard existsRetry with a new Idempotency-Key
422VALIDATION_FAILEDBody shape, unknown field, bad country/timezone/locale/currency/emailShow field errors
428PRECONDITION_REQUIREDIdempotency-Key missingGenerate a key, retry
500 / 503INTERNAL / DEPENDENCY_UNAVAILABLEServer or dependency errorRetry with the same Idempotency-Key

Edge cases​

  • Idempotent replay: the same Idempotency-Key and body returns the stored 201 with Idempotent-Replayed: true; no second org is created. If the earlier call committed but its response was never stored (crash or timeout), the retry returns 503 DEPENDENCY_UNAVAILABLE rather than rebuilding the response; the Business does exist, so check the Business list before using a new key.
  • Atomic: the org and the owner invitation commit together, so a Business never exists without its owner's invitation.
  • No email: the owner sees the invitation in-app. It can be resent (new token) with :resend on the new org.
  • acceptUrl is returned only outside prod, only on this response, and only when INVITE_LINK_BASE is set.
  • The owner is not a member yet: they join the new org on the BUSINESS role only when they accept through POST /v1/invitations:accept.

Business permission limits​

Purpose: an Admin decides what each Business can do (R-3a, owner decision 2026-11-03). Built 2026-11-03; not yet run against a deployed stage. All three routes are in the PLATFORM org, so a Business can never read or change its own limit: without a PLATFORM membership the route is 404 NOT_FOUND, and any other org in {orgId} is 409 INVALID_STATE.

Shape: a partial map of the 15 categories to a level, the same shape as a share's permsLimit. A missing key means no limit for that category; {} is the same as no limit (null).

type BusinessLimit = {
businessOrgId: string;
permsLimit: Partial<Record<Category, Level>> | null; // null = no limit
version: number; // 0 = never set; If-Match for PUT
updatedAt?: string;
updatedBy?: { sub: string; displayName: string };
};

Effect: per category, the effective level is the lower of the role level and the limit, for:

  • every membership in the Business org (the Business owner, Installers, any custom role), in every HTTP decision, GET /v1/me/context, realtime tickets and alert audiences. A Super Admin member is never limited;
  • every share and customer portal the Business granted, including ones made before the limit (the limit is combined with the grant's own permsLimit / portalPermsLimit);
  • every new grant from the Business: shares, portals, invitations and role edits are checked against the limited levels, so a Business cannot pass on what it no longer holds.

Changes apply on the next request (the limit is read consistently with the membership). Live realtime sessions of the Business's members get an access.revoked.v1 when a limit is lowered; End Users reached through its shares and portals pick it up on their next ticket (at most 600 s).

GET /v1/orgs/{orgId}/businesses​

  • Authorization: customers ≥ VIEW in the PLATFORM org.
  • Query: status (ACTIVE | SUSPENDED | CLOSED), q (2 to 64 characters; every word must start a word of the name or the code), limit (1–50; default 15 on the first page, 10 with a cursor (lazy loading)), cursor (opaque). Unknown parameter, or a q with no word of at least 2 characters: 400 VALIDATION_FAILED. status and q were added by issue #14 (2026-11-13, not deployed).
  • Response 200: { items: BusinessSummary[], nextCursor?: string }, sorted by name. Every non-personal OPERATOR org.
  • Paging: the cursor is tied to status and q. Reusing it with other filters → 400 INVALID_CURSOR. Before issue #14, personal orgs could make a page short or empty while it still had a nextCursor. A page now reads up to 5 times to fill itself, so this is rare. A page can still come back short; keep paging until nextCursor is absent.
  • Counts (issue #14): plantCount, customerCount and memberCount come from the Business's facet counters (approximate: true). They go stale while the stream-router is not deployed (KI-43), and a missing counter reads 0. Do not present them as exact. installerCount (2026-11-19) is the exception: it is counted on read (a Select: COUNT Query over the Business's ACTIVE members on an Installer-type role), so it is exact. The roleId facet counter is not used for it because it also counts REMOVED members.
type BusinessSummary = {
businessOrgId: string; code: string; name: string;
status: "ACTIVE" | "SUSPENDED" | "CLOSED";
owner: { sub: string; displayName: string } | null; // first ACTIVE Business-role member; null while the invitation is pending
creatorSub: string | null; // ADR 0026: the creator, a record only — since 2026-11-19 only Crown staff close a Business
permsLimit: PermsLimit | null;
version: number; // the Business LIMIT's version — If-Match of PUT …/limit
orgVersion: number; // ADR 0026: the Business org's version — If-Match of :suspend / :restore / :close / :reopen
plantCount: number; // issue #14: plants counter (COUNT#plants#ALL#ALL)
customerCount: number; // issue #14: ACTIVE customers
memberCount: number; // issue #14: ACTIVE members (End Users included)
installerCount: number; // 2026-11-19: ACTIVE members on an Installer-type role (any non-built-in role) — EXACT
approximate: true; // plantCount, customerCount and memberCount are approximate
};

GET /v1/orgs/{orgId}/businesses/{businessOrgId}/limit​

  • Authorization: customers ≥ VIEW in the PLATFORM org.
  • Response 200: BusinessLimit, with ETag: "<version>" ("0" when never set).
  • Errors: 404 NOT_FOUND unknown Business; 409 INVALID_STATE when {orgId} is not the PLATFORM org or {businessOrgId} is not a non-personal OPERATOR org.

PUT /v1/orgs/{orgId}/businesses/{businessOrgId}/limit​

  • Authorization: customers ≥ MANAGE in the PLATFORM org.
  • Headers: If-Match: "<version>" required ("0" for the first write). Missing: 428. No Idempotency-Key (the write is versioned).
  • Body (strict): { "permsLimit": { … } | null }.
  • Escalation rule (not for a Super Admin, R-0): each limit value may be at most the caller's own level in that category, and a category may only be raised (a higher value, or its key removed so it goes back to the Business role's level) up to the caller's own level. Lowering is always allowed. Otherwise 403 FORBIDDEN, details: { reason: "ESCALATION", category }.
  • Side effects (one transaction): the limit item; BUSINESS_LIMIT_CHANGED with per-category from/to (null = no limit) in the access logs of both the PLATFORM org and the Business org; and, when any category is lowered, one access.revoked.v1 (scope: "ORG", orgId = the Business, reason: "BUSINESS_NARROWED"). Sending the current limit again writes nothing and keeps the version.
  • Response 200: the new BusinessLimit, ETag = its version.
StatuscodeWhen
403FORBIDDENcustomers below MANAGE, or details.reason: "ESCALATION"
404NOT_FOUNDNo PLATFORM membership, or unknown Business
409INVALID_STATE{orgId} not the PLATFORM org, or the target is not a Business
409VERSION_CONFLICTStale If-Match; details.currentVersion
422VALIDATION_FAILEDUnknown category or level, unknown body field
428PRECONDITION_REQUIREDIf-Match missing

Illustrative request (derived from the schema, not a captured execution)​

PUT /v1/orgs/<platformOrgId>/businesses/<businessOrgId>/limit
If-Match: "0"
Content-Type: application/json

{ "permsLimit": { "firmware": "NONE", "commands": "VIEW" } }
{
"businessOrgId": "<businessOrgId>",
"permsLimit": { "firmware": "NONE", "commands": "VIEW" },
"version": 1,
"updatedAt": "2026-11-03T10:00:00.000Z",
"updatedBy": { "sub": "<adminSub>", "displayName": "<adminSub>" }
}

The Business owner's GET /v1/me/context then shows firmware: "NONE" and commands: "VIEW" for that org, and no Installer there can exceed them.

Accept rules (Audit wave 1 (2026-10-27))​

  • Accepting requires a verified email; otherwise 403 FORBIDDEN.
  • Only the current token works: after a resend, the old token returns 404.
  • The user pool keeps the original email until a change is verified (keepOriginal).

See also​

  • Team & Access API — the shared authorization model, scope shape and versioned-write conventions this API reuses
  • Known issues & gaps — KI-28 (in-app only, no invitation email; acceptUrl needs shareLinkBaseUrl set)