Skip to main content

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:

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Records per page (max 100)
sortstringcreated_atField to sort by
orderstringDESCASC or DESC
<field>anyFilter 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:

CodeReason
404Record 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:

CodeReason
400Validation error (missing required fields, wrong types)
404Unknown 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:

CodeReason
400Validation error or no fields provided
404Record or table not found

DELETE /api/:table/:id

Delete a record.

Response: 204 No Content

Errors:

CodeReason
404Record or table not found