Resources
Resources are the core building blocks of your Snaapi application. A resource represents a data entity — similar to a database table — that Snaapi automatically exposes as a fully functional REST API with role-based access control, validation, and event streaming.
Defining a Resource
To create a resource, send a POST request to the admin API with a name, at
least one field, and optionally permissions and a description.
{
"name": "posts",
"description": "Blog posts written by users",
"fields": [
{ "name": "title", "type": "string", "required": true },
{ "name": "body", "type": "text" }
],
"permissions": [
{ "role": "user", "action": "read", "fields": ["title", "body"] }
]
}
Resource names must start with a letter or underscore, contain only alphanumeric characters and underscores, and be at most 100 characters long.
System Fields
Every resource automatically includes three system-managed fields that you do not need to define:
| Field | Type | Description |
|---|---|---|
id |
uuid |
Unique identifier, generated automatically |
created_at |
datetime |
Timestamp set when the record is created |
updated_at |
datetime |
Timestamp updated on every modification |
System fields are always returned in API responses and can be referenced in permissions, filters, and sort operations. You cannot create custom fields with these reserved names.
Soft Delete
When enableSoftDelete is set to true, deleting a record does not remove it
from the database. Instead, a deleted_at timestamp is set on the row. Soft-
deleted records are excluded from normal queries but can be recovered or audited
later.
{
"name": "orders",
"enableSoftDelete": true,
"fields": [...]
}
By default, soft delete is disabled (false). You can toggle it when creating
or updating a resource.
Enabling and Disabling Resources
Resources have an enabled flag (defaults to true). When a resource is
disabled, its API endpoints stop accepting requests, effectively taking it
offline without deleting the resource definition or its data.
{
"name": "legacy_items",
"enabled": false,
"fields": [...]
}
Disabling a resource is useful for maintenance windows, staged rollouts, or deprecating endpoints while preserving the underlying data.