External applications bring their own hierarchy

Some applications do not exist inside a single account — they are shaped like an organization chart of their own. A retail platform (call it Broit Portal) runs area companies, cities, and stores; a factory suite runs plants, lines, and cells. DotID lets such an application own its hierarchy and map it onto the organization structure, instead of flattening the business into one account per subsidiary with hand-managed grants.

The model

Your application’s hierarchy

DotID object

The application itself

an organization (/organizations/v1)

Top-level grouping (headquarters)

root OU of the organization

Region / area company

OU under the root

City / district

OU under the area

Store / plant / site

OU under the city

Each store’s identity on the platform

an account inside the store OU

The account is the only object your application creates for its sites; the hierarchy above it is entirely OUs. Grants are OU-scoped assignments: a permission set assigned to an OU reaches every account under that OU. Reach is decided at assignment time by looking up the account’s OU ancestry — there is no stored foreign key from the account to a grant, so moving an account between OUs changes what it can do with no grant bookkeeping.

See hierarchical-access for the OU-assignment mechanics and the policy simulator for how the PDP resolves an account’s OU chain. The full design rationale is DID-0069.

When to use this pattern

  • Your application has a stable, hierarchical shape (areas → cities → stores).

  • Access to platform resources should follow the hierarchy: everyone in a store shares the store’s capabilities, managers in an area see all its stores.

  • You want to delegate administration of a subtree to a regional company without handing over the whole organization.

Per-account assignments still make sense for one-off grants; the OU-scoped model replaces the bulk of per-account work, not the exceptional case.

What the example proves

The runnable example at examples/external-app-own-hierarchy drives this whole pattern against the live platform through the published API and the fgai CLI only — no internal endpoints, no privileged shortcuts:

  • the application creates its own org with a root OU and a full area → city → store subtree, and an account per store;

  • a store staff principal (workforce user) can operate only inside the store’s account;

  • an area-company workforce principal manages every account under the area OU through one OU-scoped assignment;

  • the application hands a delegated administrator to an area company — the delegatee account is placed in a sibling subtree (not inside the delegated subtree, which the platform refuses), scoped to the delegated permission sets, and capped by a permission boundary;

  • every grant is verified end-to-end with the CLI’s authorize check, including the IC-session path where the credential was minted for an OU-assigned permission set.

Status: the delegated-administrator leg authors inside an org member account by first assuming the OrganizationAccountAccessRole bootstrap role that account materialization provisions (DotID#291 — landed and deployed): fgai identity sts assume-role --body '{"role_frn":"frn:<account>:iam:role/OrganizationAccountAccessRole","role_session_name":"…"}' (snake_case on the wire), then runs the account-scoped commands under the minted ASIA credential. The example exercises the leg adaptively: it completes when the role is live, and otherwise records the observed gap and reports the affected checks as skipped.

Reconciling grants from your backend

Your application moves stores between companies. Every move has to add one delegation and remove another, and it does that from a backend service identity, unattended. This section is the contract that reconciler can rely on.

Which identity to use

Use an access key (AK/SK) bound to the delegating store’s own account — or a temporary credential your backend mints for that account. That is the least-privileged identity that works: it can author and revoke edges from the account it is bound to, and from no other account. It needs no organization-management authority, and it cannot reach a sibling or a parent store.

The only other accepted caller is the organization’s management account, which may author edges for any member account. Treat that as the break-glass path, not the reconciler’s identity.

Any other caller is refused with 403. Every delegation route is scoped this way, including the reads.

Revocation checks ownership, and says nothing else

DELETE on an edge is refused unless both hold: the caller satisfies the scope above, and the edge actually delegates from the account in the path.

When the ownership half fails you get the same 404 a wrong id produces — the endpoint is deliberately not an oracle for which edge ids exist. A retrying reconciler must therefore read 404 as “this edge is not mine, or is already gone” and treat it as success, not as an error to escalate.

Two consequences worth knowing before you write the retry loop:

  • Revoking an already-revoked edge is that same 404 — DELETE is not 204-forever.

  • An edge whose delegator is an OU rather than an account cannot be revoked from this account-scoped route at all. Revoke it from the organization’s delegation route, which is where it was created.

One active edge per pair

A (delegator account → delegatee account) pair may hold at most one active edge. Revocation is a soft revoke — the row is kept, marked revoked — so once an edge is revoked you may create the same pair again, and the new edge is a new id.

Re-running a create that already succeeded, while its edge is still active, is not a defined success today: the one-active-edge rule is enforced, but the surface does not yet answer a repeated create with a named, retry-safe error. Make your reconciler read back (GET …/delegations) before creating, rather than relying on create being idempotent.

What is attributed

  • Create records the authoring caller on the edge.

  • Revoke publishes an audit event naming the caller who revoked it, on both the account-scoped and the organization-scoped routes.

An AK/SK caller has no interactive user subject, but the edge is still attributed: it names the principal the credential belongs to — the service user you minted the key for — not a person’s subject and not the account. The literal string unknown appears only when no caller can be resolved at all, which for a key bound to a real service user does not happen, so treat unknown on your own edge as an anomaly worth reporting. Attribute the reconciliation run on your side if you need per-run provenance.

Ordering rules that hold

  • A delegatee account must not sit inside the subtree being delegated to it — create the delegatee account in a sibling subtree at the same level.

  • A permission set used in an OU-scoped assignment must exist before the assignment references it.

  • Accounts are materialized when you grant them an operator; until then they are placeholders. Placeholder hierarchy can be torn down freely; a materialized account must be closed (terminal state) before it disappears.