What it does
Every collection carries a rules object with an allowed-role list for list, view, create, update and delete, and an optional map from field name to the roles that may see that field. Reads are open by default and writes are restricted by default.
How it works
Each of the five operations holds a list of role names such as admin, editor and viewer, or the wildcard *. A request is allowed when its role is in the list or the list contains *. When a rule is omitted the defaults apply: list and view are *, which includes the anon role; create and update are admin and editor; delete is admin.
The check runs on the collection record routes under /v1/collections, on the table routes under /rest/v1, and on KynQL queries at /v1/query. A caller with a project service key acts as admin in its project. A rules object that is omitted entirely does not deny everything: it takes the defaults above.
field_visibility maps a field name to the roles that can see it. A role that is not listed has that field removed from responses, including when the record is returned through a relation embed. A field that does not appear in the map is visible to every reader.
A typed view over a collection inherits the source collection's role rules, field visibility and row-level policies and cannot widen them. Definitions are validated when they are saved: policy expressions must parse, and a collection name that collides with a reserved internal name is refused.
Where you reach it
- HTTP
POST /v1/collections (a definition that includes rules) - HTTP
GET|POST /v1/collections/:name/records, GET|PATCH|DELETE /v1/collections/:name/records/:id - HTTP
GET|POST|PATCH|DELETE /rest/v1/:table - HTTP
POST /v1/query
Example
{
"name": "orders",
"fields": [
{ "name": "customer_email", "type": "email", "required": true },
{ "name": "total", "type": "number" },
{ "name": "internal_note", "type": "long_text" }
],
"rules": {
"list": ["admin", "editor"],
"view": ["admin", "editor"],
"create": ["admin", "editor"],
"update": ["admin"],
"delete": ["admin"],
"field_visibility": { "internal_note": ["admin"] }
},
"created_at": 0,
"updated_at": 0
}Limits
- A new collection is readable by every role, including the anon key, until you restrict list and view. Set both explicitly for private data.
- Field visibility is applied on the table routes under /rest/v1, on KynQL and on typed views. The record routes under /v1/collections apply the role lists but do not remove hidden fields.
- Rules match the role name a request resolved to (admin, editor, viewer, anon, or an organisation role for console sessions) or the wildcard. For finer control use the permission overlay and row-level policies.
- The created_at and updated_at fields are required in a definition payload. The server sets updated_at itself.
Evidence
- On this siteDocs: collections and rules
- TestsSchema-crate tests for role rules, open-by-default deserialisation and field projection, and view tests showing that a view cannot bypass the source collection role rules or field visibility
Test coverage is listed as present in the engine repository at this edition. This page does not report test results.
KynetraDB is in private preview
Request a preview to try this against your own workload.