Nothing has happened yet
The CRM is empty and SpiceDB knows no relationships, so nobody can see anything. Run step 1 to create the first account.
The CRM saves its own record, then sends SpiceDB the relationship that changed. Run the six steps.
The CRM is empty and SpiceDB knows no relationships, so nobody can see anything. Run step 1 to create the first account.
-- nothing yet
// nothing yet
// SpiceDB's reply appears here
Crossed-out rows are deletes: stamped with deleted_xid, garbage-collected later. ... means the subject itself.
The CRM only sends a relationship when one changes: an owner, a team member, a share. Access to new deals comes for free, because the deal points at its account.
Several updates in one WriteRelationships call land in a single transaction. In step 6 the old owner is removed and the new one added together, so there is never a moment with two owners or none.
The reply includes a ZedToken. Store it with the record. A later check that passes it is guaranteed to see this write, even if caches haven’t caught up.
Commit the CRM record, then call SpiceDB. If that call fails, retry it: TOUCH is safe to repeat. Larger systems put the update in an outbox table and let a worker send it.
Written once. It tells SpiceDB how the relationships combine into permissions.
definition user {} definition team { relation member: user } definition account { relation owner: user relation team: team permission edit = owner permission view = edit + team->member // the owner, plus everyone on the account's team } definition deal { relation account: account relation viewer: user permission edit = account->edit // whoever can edit the account permission view = viewer + account->view // people it was shared with, plus the account's viewers }
ZedTokens and transaction IDs here are illustrative; real values are opaque and longer. The request uses SpiceDB’s HTTP API; the gRPC API and client libraries send the same fields.