Dynamic CRUD Endpoints
These endpoints are available for every model defined in schema.json. Replace :table with the model's table name (e.g. products for a Product model).
GET /api/:table
List records with filtering, sorting, and pagination.
Auth: Optional
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 20 | Records per page (max 100) |
sort | string | created_at | Field to sort by |
order | string | DESC | ASC or DESC |
<field> | any | — | Filter by exact value on any model field |
Example: GET /api/products?sort=price&order=ASC&page=2&limit=10&in_stock=1
Response 200:
{
"data": [
{
"id": "uuid",
"name": "Widget",
"price": 9.99,
"in_stock": 1,
"created_at": "2026-03-06T12:00:00.000Z",
"updated_at": "2026-03-06T12:00:00.000Z"
}
],
"meta": {
"total": 42,
"page": 2,
"limit": 10,
"pages": 5
}
}
GET /api/:table/:id
Get a single record by ID.
Response 200:
{
"data": {
"id": "uuid",
"name": "Widget",
"price": 9.99
}
}
Errors:
| Code | Reason |
|---|---|
404 | Record not found or unknown table |
POST /api/:table
Create a new record.
Auth: Optional
Request Body: JSON object matching the model's field definitions.
{
"name": "Widget",
"price": 9.99,
"in_stock": true
}
Response 201:
{
"data": {
"id": "uuid",
"name": "Widget",
"price": 9.99,
"in_stock": 1,
"created_at": "2026-03-06T12:00:00.000Z",
"updated_at": "2026-03-06T12:00:00.000Z"
}
}
Errors:
| Code | Reason |
|---|---|
400 | Validation error (missing required fields, wrong types) |
404 | Unknown table |
PUT /api/:table/:id
Update a record (partial — only send fields to change).
Request Body:
{
"price": 14.99
}
Response 200:
{
"data": {
"id": "uuid",
"name": "Widget",
"price": 14.99
}
}
Errors:
| Code | Reason |
|---|---|
400 | Validation error or no fields provided |
404 | Record or table not found |
DELETE /api/:table/:id
Delete a record.
Response: 204 No Content
Errors:
| Code | Reason |
|---|---|
404 | Record or table not found |