Skip to content

Collections API

Endpoints

  • POST /api/{collection}
  • GET /api/{collection}
  • GET /api/{collection}/{id}
  • PATCH /api/{collection}/{id}
  • DELETE /api/{collection}/{id}

Auth and roles

  • Read/list routes require valid auth.
  • POST, PATCH, DELETE require role owner or admin.

Create record

bash
curl -s -X POST http://127.0.0.1:3000/api/task \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"data":{"title":"Ship docs","done":false}}'

List records

bash
curl -s 'http://127.0.0.1:3000/api/task?limit=20&offset=0&done=false' \
  -H 'Authorization: Bearer <token>'

Query rules:

  • limit: default 20, max 100.
  • offset: default 0.
  • Additional query keys are exact-match filters on scalar fields (string, bool, int, float, datetime).
  • Unknown or invalid filter values return filter errors.

Patch record

bash
curl -s -X PATCH http://127.0.0.1:3000/api/task/<id> \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"data":{"done":true}}'

Patch payload data must contain at least one field.

What is generated when creating a new collection

When you run:

bash
zeptoz collection create Task title:string:required done:bool --id-strategy uuidv7

Zeptoz generates:

  • DB row in schema_collections (name, table_name, id_strategy)
  • DB rows in schema_fields (one per field definition)
  • Physical SQL table named col_<collection> (example: col_task)

Notes:

  • Collection create is DB-only by default (no hook files generated).
  • If you use --with-hook <event>:<lang>:<name>, hook files and hook DB rows are generated too.