DrootERP's public contracts are the REST API v1 (/api/v1/…), the domain events
(events.md) and the extension points (extension-points.md).
Internals behind them may change in any release; these do not, except as described here.
API v1
| Method | Path | Does |
|---|---|---|
| GET | /api/v1/models/{model}/records |
List records (filter, sort, cursor, field selection) |
| POST | /api/v1/models/{model}/records |
Create a record |
| GET | /api/v1/models/{model}/records/{id} |
Get a record |
| PATCH | /api/v1/models/{model}/records/{id} |
Update a record |
| DELETE | /api/v1/models/{model}/records/{id} |
Delete a record (soft delete) |
| POST | /api/v1/models/{model}/records/{id}/transitions/{transition} |
Run a flow transition |
| POST | /api/v1/views/{view}/bulk |
Start a bulk action (202, a job) |
| GET | /api/v1/bulk/{id} |
A bulk action's status |
The work around a record sits under its path, /api/v1/models/{model}/records/{id}/…, and works for every model:
| Method | Path | Does |
|---|---|---|
| GET | …/approval, …/approval/history, …/approval/preview |
The record's approval: its state, its decisions, the route it would take |
| POST | …/approval/start, …/approval/decision, …/approval/set-back, …/approval/forward, …/approval/withdraw |
Submit, approve or reject ({"decision":"approve"}), send back, forward, withdraw |
| GET | …/print, …/print/{template} |
The record's document as HTML (?format=json for JSON) |
| GET, POST | …/outputs |
Issued documents; issue one (needs documents.issue for an app) |
| GET | …/outputs/{output}/file |
An issued document's PDF |
| GET | …/timeline |
Comments, changes, stage changes and approvals, newest first (its own cursor) |
| POST, PATCH, DELETE | …/comments, …/comments/{comment} |
Comment; edit or delete one's own comment |
| GET, POST | …/activities |
The record's activities; schedule one |
| GET, POST | …/attachments |
Every file the caller may see on the record; upload one to its timeline (the body is the file, ?name=) |
| GET | …/attachments/{file} |
Download a timeline file |
| GET, PUT | …/followers |
Whether the caller follows the record; follow or unfollow ({"following":true}) |
And the caller's own work:
| Method | Path | Does |
|---|---|---|
| GET | /api/v1/approvals/inbox, /api/v1/approvals/counts |
Approvals waiting for the caller (tab, cursor, limit) |
| GET | /api/v1/activities/mine |
The caller's activities |
| GET, PATCH | /api/v1/activities/{activity} |
An activity; change it |
| POST | /api/v1/activities/{activity}/done, …/cancel |
Complete or cancel an activity |
| GET | /api/v1/search?q= |
Search every record type the caller can open |
| POST | /api/v1/views/{view}/actions/{action} |
Run a view's action (a toolbar, row or form button; {"recordIds":[…]}) |
| GET | /api/v1/me/notifications, …/unread-count |
The caller's notifications |
| POST | /api/v1/me/notifications/{notification}/read, …/read-all |
Mark read |
| GET, POST | /api/v1/me/push-devices |
The caller's push devices; register one (token, platform: android, ios or web, label) |
| DELETE | /api/v1/me/push-devices/{device} |
Remove a device by its id (a lost phone, from another device) |
A phone app signs its user in and calls these with the session's bearer token; a device's token is an FCM registration token (Android, or iOS through APNs), delivered by the Firebase connector like a browser's. The device list never returns a token. Comments, activities, notifications and devices need a person: an API key gets 403, and an OAuth app token reaches a record's work within its model family's scopes only.
Each v1 route runs the same handler and the same permission checks as the application's own route; v1 only
adds the conventions below. Authenticate with an API key (Authorization: Bearer …) or a session.
Conventions
- Responses:
{ "success": true, "data": … }. Lists addpage: { limit, total, nextCursor }; writes may addmeta(fields the write cleared, an approval it reset, a change held for approval). - Errors:
{ "success": false, "error": { "code", "message", "details", "requestId" } }.codeis stable and machine-readable (validation,not_found,forbidden,conflict,rate_limited,idempotency_key_reused, …);messageis for people and may change. QuoterequestId(also theX-Request-Idheader) to support. - Pagination:
limit(1–200, default 50) andcursor(the previous page'snextCursor, opaque). A cursor is bound to itsfilterandsort;nextCursor: nullis the last page. - Field selection:
fields=name,valuereturnsidplus those fields (lists, get and writes). - Filtering and sorting:
filter(JSON, the record query language) andsort(JSON, e.g.{"date":-1}). - Idempotency: send
Idempotency-Key(1–200 visible characters) on POST, PUT, PATCH and DELETE (not on an upload: its body is streamed, so it is refused). The first answer is kept for 24 hours and replayed for a retry with the same key and request (Idempotent-Replayed: true); the same key with a different request is a 422idempotency_key_reused; while the first is still running, a 409. Keys are per caller. A 5xx answer is not kept, so the retry runs again. - Rate limits: every answer carries
X-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Reset(Unix seconds). Above the limit (per caller, per minute; set by the operator) the answer is 429 withRetry-After. - Version header: v1 answers carry
API-Version: 1.
What counts as breaking
Breaking: removing or renaming a route, field, event, event field or extension point; changing a type or meaning;
making an optional input required; narrowing accepted values; changing an error code.
Not breaking (may happen in any release): new routes, new optional inputs, new response fields, new events, new extension points, new error codes for new situations, new enum values in responses (clients must ignore unknown values and fields).
Versions and the deprecation window
- A breaking API change ships as a new major version (
/api/v2/…) next to v1. A breaking event change ships as a new event version (record.updatedv2) delivered next to v1 to subscribers who choose it. - The old version is deprecated, not removed: it keeps working for at least 12 months after its successor
ships. Deprecated routes answer with
DeprecationandSunsetheaders and aLinkto the successor; the developer docs and the release notes announce it. betaevents and extension points may change in a minor release, announced in the release notes.- Every change to a published contract bumps its version in code; the contract test
(
kernel/test/contracts/contracts.test.ts) refuses a change that doesn't.