Access Policies (Entity, Record & Field)
The full reference for object-level access policies: how access_policy and access_rule records restrict a role per schema entity, per record (owner-scope), and per field, with no application code.
Overview
- Entity-level — can this role create, read, update, or delete a given schema type at all?
- Record-level (owner-scope) — of the rows that exist, which ones can this role see or touch?
- Field-level — within a row it can see, which fields are hidden on read, and which are locked on write?
Who this applies to
Which roles are affected
| Role | Scope | Subject to access policies? | Can configure them? |
|---|---|---|---|
| domain_admin | domain | No — always full access | Yes |
| domain_user | domain | Yes | Read-only |
| project_admin | project | No — always full access | Yes |
| project_user | project | Yes | Read-only |
| developer | project | Yes | Read-only |
| tenant_admin | tenant | Yes | Read-only |
| tenant_user | tenant | Yes | Read-only |
| viewer | tenant | Yes | Read-only |
tenant_admin is restricted like any other role
Data Model
access_policy — parent: project
| Field | Type | Description |
|---|---|---|
| role | string, required | The role this policy applies to, e.g. tenant_user, viewer, or a registered custom role. |
| default_access | string, required | The fallback for any entity with no matching access_rule: full, read, or none. |
| is_active | bool, required | Only active policies are resolved; a row with is_active=false is ignored, same as if it didn't exist. |
| description | string, optional | Free-text note for your own admin UI. |
| priority | integer, optional | Stored on the record for your own bookkeeping. |
access_rule — parent: access_policy
| Field | Type | Description |
|---|---|---|
| entity | string, required | The schema name this rule applies to, e.g. "appointment". Matched case-insensitively against the bare name, so CartItem matches cartitem. Namespace-qualify it (myapp:appointment) whenever two namespaces in the project define a schema with the same bare name — see the warning below. |
| can_create | bool, required | Whether this role can create new records of this entity. |
| can_read | bool, required | Whether this role can read/list/query records of this entity. |
| can_update | bool, required | Whether this role can update records of this entity. |
| can_delete | bool, required | Whether this role can delete records of this entity. |
| filter_field | string, optional | The field name used for record-level owner-scope (see below). Omit for no record-level restriction. |
| filter_match | string, optional | One of $user.email, $user.uuid, or $user.name — required if filter_field is set. |
| hidden_fields | string (comma-separated), optional | Field names to strip from every read response for this role. |
| readonly_fields | string (comma-separated), optional | Field names to silently drop from create/update payloads for this role. |
An ambiguous entity name makes the rule silently not apply
Both objects also carry the standard system fields
Level 1: Entity Access
| default_access | Effective permissions for entities with no rule |
|---|---|
| full | Create, read, update, and delete all allowed. |
| read | Only read/list/query allowed; create, update, delete denied. |
| none | Create, update, and delete are denied (403) unless an access_rule grants them. Reads of an entity with no rule are still allowed (and logged); see the note below. |
Restricting reads reliably
Reading back a record you just wrote
Default Behavior When No Policy Exists
The default is permissive, not deny
| Role (no access_policy row configured) | Effective default_access |
|---|---|
| viewer | read |
| tenant_user, tenant_admin, developer, project_user, domain_user (or a custom role based on one of these) | full |
| domain_admin, project_admin | not applicable — policies do not apply to these roles; they always have full access |
Level 2: Record Access (Owner-Scope)
| filter_match | Resolves to |
|---|---|
| $user.email | The calling user's email address |
| $user.uuid | The calling user's UUID |
| $user.name | The calling user's username |
- List and query reads automatically add customer_email=<caller's email> to the filters, so the role only ever sees its own rows.
- A create automatically stamps customer_email to the caller's own email — a client-supplied value for that field is overridden, not merely validated.
- A get, update, or delete by UUID on a row belonging to someone else returns 404, not 403, so the response doesn't confirm the row even exists.
Owner-scope is opt-in, per entity
Level 3: Field Access
Hiding fields on read — hidden_fields
Locking fields on write — readonly_fields
readonly_fields is not implied by owner-stamping
Comma-separated or a list
Configuring Policies
Create the policy — one per role, per project
curl -X POST https://api.supero.dev/api/v1/crud/acme-corp/access_policy \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "tenant-user-appointments",
"parent_type": "project",
"parent_uuid": "<project-uuid>",
"role": "tenant_user",
"default_access": "none",
"is_active": true
}'Add a rule scoping one entity
curl -X POST https://api.supero.dev/api/v1/crud/acme-corp/access_rule \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "tenant-user-appointment-rule",
"parent_type": "access_policy",
"parent_uuid": "<access-policy-uuid>",
"entity": "appointment",
"can_create": true,
"can_read": true,
"can_update": true,
"can_delete": false,
"filter_field": "customer_email",
"filter_match": "$user.email",
"hidden_fields": "internal_notes",
"readonly_fields": "status"
}'Python SDK
import supero
org = supero.login(domain_name="acme-corp", email="[email protected]", password="...")
policy = org.crud.create(
"access_policy",
name="tenant-user-appointments",
parent_type="project",
parent_uuid=project_uuid,
role="tenant_user",
default_access="none",
is_active=True,
)
org.crud.create(
"access_rule",
name="tenant-user-appointment-rule",
parent_type="access_policy",
parent_uuid=policy["uuid"],
entity="appointment",
can_create=True, can_read=True, can_update=True, can_delete=False,
filter_field="customer_email", filter_match="$user.email",
hidden_fields="internal_notes", readonly_fields="status",
)Reading the resolved policy
GET /api/v1/crud/{domain}/access-policy/me
Authorization: Bearer <jwt>{
"success": true,
"policy": {
"role": "tenant_user",
"default_access": "none",
"has_policy": true,
"is_admin": false,
"entities": {
"appointment": {
"entity": "appointment",
"can_create": true,
"can_read": true,
"can_update": true,
"can_delete": false,
"filter_field": "customer_email",
"filter_match": "$user.email",
"hidden_fields": ["internal_notes"],
"readonly_fields": ["status"]
}
}
}
}GET /api/v1/crud/{domain}/access-policy/roles?parent_id={project_uuid}
Authorization: Bearer <jwt>| Field | Description |
|---|---|
| role | The role identifier, e.g. "tenant_user". |
| label / scope / description | Human-readable display metadata for an admin UI. |
| is_admin | True for roles that policies do not apply to; they always have full access (no row, no default applies). |
| configured | True iff an active access_policy row exists for this role in this project. |
| default_access | The row's default_access if configured; otherwise the backward-compatible default (see Default Behavior above). |
| policy_uuid | The access_policy uuid, present only when configured is true. |
How quickly a change takes effect
Worked Example
// access_policy
{
"role": "tenant_user",
"default_access": "none",
"is_active": true
}
// access_rule (parent = the policy above)
{
"entity": "appointment",
"can_create": true, "can_read": true, "can_update": true, "can_delete": false,
"filter_field": "customer_email", "filter_match": "$user.email",
"hidden_fields": "internal_notes",
"readonly_fields": "status"
}- Creating an appointment auto-stamps customer_email to their own email address, ignoring any value they send for that field.
- Listing or querying appointments only ever returns rows where customer_email matches their own email.
- Fetching, updating, or deleting another user's appointment by UUID returns 404.
- internal_notes never appears in any response returned to them.
- A PUT that attempts to change status has that key silently dropped; the stored value is unchanged.
- Deleting any appointment — even their own — is denied, since can_delete is false.
- Any other entity in the project with no matching access_rule is denied for writes, because the policy's default_access is none. It is still readable, because only a rule with can_read: false refuses reads. See the warning below.
access "none" does not make records unreadable
Next Steps
- Access Control (RBAC) — the coarse, role-permission layer that access policies sit on top of
- Users & Roles — assigning built-in and custom roles to accounts
- Managing Data — the CRUD and query endpoints access policies enforce
- Permissions that leak through ORDER BY — why masking a field in the response does not protect it, and where our own coverage ends
On this page