Skip to main content
Row policies decide which records an end user can access in a collection, after collection permissions decide whether they can access it at all. Policies filter queries inside the database, so a user can never reach a record their policies exclude.

The default: owner only

If none of a user’s roles has an allow policy on a collection, the user sees only records they created.
Records created through the API by a signed-in user are owned by that user. Users who register own their own user record, so they can read and update their profile out of the box.

Policy types

field_equals supports the operators =, !=, <>, >, >=, <, <=.

Allow and deny

Each policy has an effect:
  • allow: the record is visible if it matches at least one allow policy.
  • deny: the record is hidden if it matches any deny policy. Deny wins.
Policies also have a priority (higher first), an enabled switch, and the roles they apply to.

Create a policy

1

Open the guard's policies

Authentication → Guards → your guard → Row policies → Create policy.
2

Pick the collection and type

For example products, type field_equals.
3

Configure it

Field status, operator =, value published, effect allow.
4

Attach roles

Choose which roles the policy applies to, for example customer.

Recipes

Nothing to configure: this is the default. Make it explicit with an allow owner policy if you also add other allow policies.
allow field_equals status = published for role user on articles.
Two allow policies on articles: owner and field_equals status = published. A record matching either is visible.
Add a many_to_many relation between projects and users (members). Create an allow relation policy on projects using that relation.
deny field_equals archived = true. Applies on top of any allow policies.
Run admin tools on your own server with a platform key, which isn’t filtered by row policies. If admins must use an end_users key, give role admin an allow field_equals policy on a field every record has a value for, such as tenant = "acme".

What users see

Row policies apply to end_users keys. platform keys, hooks, and the dashboard aren’t filtered. Policies of type expression or custom aren’t supported and match nothing.