QUICKSTART · ABOUT 10 MINUTES

SpiceDB Quickstart: Your First Permission Check in 10 Minutes

Run SpiceDB on your laptop, describe a small permission model, write a few relationships and ask "can Alice view the roadmap?". Every command and output below was run against a real SpiceDB server.

Tested with SpiceDB 1.57 and zed 1.2, November 2026.

What you will build

A tiny document-sharing model: documents live in folders, folders are shared with teams, and anyone who can view a folder can view the documents in it. By the end you will have checked permissions, listed everything a person can see, explained a decision and watched a revocation take effect immediately.

You need: macOS with Homebrew, or Docker on any platform. Nothing else.

1. Install SpiceDB and zed

spicedb is the server. zed is the command-line client you will use to talk to it.

brew install authzed/tap/spicedb authzed/tap/zed

On Linux, SpiceDB and zed are also available as APT and RPM packages, and every release is published as a container image.

2. Start SpiceDB

spicedb serve --grpc-preshared-key "somerandomkeyhere"

Or, with Docker:

docker run --rm -p 50051:50051 authzed/spicedb serve --grpc-preshared-key "somerandomkeyhere"

SpiceDB now listens for gRPC requests on port 50051. With no datastore configured it keeps everything in memory, which is perfect for learning and disappears when you stop it. In production you would point it at PostgreSQL, CockroachDB, Google Cloud Spanner or MySQL.

3. Point zed at your server

Leave SpiceDB running and open a second terminal.

zed context set local localhost:50051 "somerandomkeyhere" --insecure

Tip: on machines without a system keychain, zed asks you to create a passphrase the first time, to encrypt the stored token. Set ZED_KEYRING_PASSWORD in your environment to skip the prompt in scripts.

4. Describe your rules in a schema

Save this as schema.zed:

definition user {}

definition team {
  relation member: user
}

definition folder {
  relation owner: user
  relation viewer: user | team#member
  permission view = viewer + owner
}

definition document {
  relation parent: folder
  relation owner: user
  relation viewer: user | team#member
  permission edit = owner
  permission view = viewer + edit + parent->view
}

Two ideas carry the whole model. A relation is something you store, such as who owns a document. A permission is computed from relations and is never written directly. team#member lets you grant access to everyone in a team at once, and parent->view says "anyone who can view this document's folder can view the document".

zed schema write schema.zed

5. Write relationships

Relationships are the facts your application records as things happen:

zed relationship create team:engineering member user:alice
zed relationship create folder:specs viewer team:engineering#member
zed relationship create document:roadmap parent folder:specs
zed relationship create document:roadmap owner user:maya

Each write prints a ZedToken, a marker for the exact point that change landed, such as:

Gh8KEzE3OTUzODEwMTU1MTA3NzkzODYSCDM1ZTE3OTRl

You will use one of these in step 7.

6. Ask questions

zed permission check document:roadmap view user:alice
zed permission check document:roadmap edit user:alice
zed permission check document:roadmap edit user:maya
zed permission check document:roadmap view user:bob
true
false
true
false

Alice can view the roadmap because she is in Engineering, Engineering can view the Specs folder, and the roadmap lives in Specs. She cannot edit it; Maya, the owner, can. Bob has no relationship at all. Ask SpiceDB to show its reasoning:

zed permission check document:roadmap view user:alice --explain
true
✓ document:roadmap view
└── user:alice

Real applications also need the reverse questions, for lists, search and AI retrieval:

zed permission lookup-resources document view user:alice
zed permission lookup-subjects document:roadmap view user
roadmap

user:maya
user:alice

zed also prints a cursor after lookup results, which you can use to page through large result sets.

7. Watch a revocation take effect

Remove Alice from Engineering and keep the ZedToken the delete returns. Then ask again, requiring an answer at least as fresh as that delete:

TOKEN=$(zed relationship delete team:engineering member user:alice)
zed permission check document:roadmap view user:alice --consistency-at-least "$TOKEN"
false

This is how SpiceDB solves the new enemy problem: a person who was just removed never sees content added after the removal. Most checks can use fast, cached reads; the ones that must reflect a specific write pass its token.

8. Test your schema in CI

Put the schema, some relationships and the answers you expect in one file, such as validation.yaml:

schema: |-
  definition user {}
  # ...the rest of schema.zed, indented...
relationships: |-
  team:engineering#member@user:alice
  folder:specs#viewer@team:engineering#member
  document:roadmap#parent@folder:specs
  document:roadmap#owner@user:maya
assertions:
  assertTrue:
    - document:roadmap#view@user:alice
    - document:roadmap#edit@user:maya
  assertFalse:
    - document:roadmap#edit@user:alice
    - document:roadmap#view@user:bob
zed validate validation.yaml
Success! - 4 relationships loaded, 4 assertions run, 0 expected relations validated

Run it on every pull request and a schema change can never silently widen or remove access.

Where to go next

Want this modeled on your own product?

Send us your company name and we’ll build a custom permission schema and a live, clickable demo of how authorization would work in your application.

Get a custom demo · Explore SpiceDB demos