Bayline documentation
How people and AI agents read and update Bayline.
The API at a glance
- Base URL: your own Bayline. All routes are under
/api, JSON in and out. - Schema: the full OpenAPI 3.1 schema is served by your own installation to signed-in people and agent keys; the API reference lists every operation.
- Reference: every endpoint, generated from that schema.
- Errors are always
{"code", "message"}, for example404 not_foundor409 version_conflict.
Authentication
- Agent key:
Authorization: Bearer bk_<id>.<secret>. Also sendX-Agent-Name: <harness>/<version>; it is stored on the audit trail. - Browser session: the
bayline_sessioncookie; writes also need theX-CSRF-Tokenheader.
Create a key
Signed in as the person the agent works for: Menu → Agent keys → New key.
- Scopes: what the key may write, never more than the person’s role allows (for example
stock_move,items_write,service_run,gages_write,files_upload). No scopes means read-only. - Propose only (on by default): every change waits on the Pending page for a person.
- Expiry: 180 days by default. The token is shown once.
Roles
| Role | May |
|---|---|
admin | Everything, including managing people and backup export and import. |
superuser | Everything admin has except managing other people's accounts. |
crib | Stock, loans and issues, returns, use, locations; may finish service work. |
maintenance | Machines, service plans and events, meter readings; reads the rest. |
quality | Gauges, calibrations, gauge issues and returns; reads the rest. |
viewer | Read only. |
Every role except viewer may also put a gauge on hold with a comment.
Writing safely
- Idempotency: send a new
Idempotency-Key(a UUID) per intended change. With an agent key, a write without one is refused (428). The same key and body replays the first answer (Idempotent-Replayed: true); the same key with another body is refused (422). Keys are remembered for 48 hours. - Answers:
201applied,202 {"status": "pending", "proposal": …}waits for a person,403 propose_requiredfor a propose-only key (sendPOST /api/proposalsinstead). - What applies at once (default shop policy, keys that are not propose-only): small takes (up to 10 units or 20 % of what is on hand), returns, meter readings and gauge uses. Bigger takes, stock counts, calibrations, edits and deletes wait for a person, and so does anything sent with
confidencebelow 0.9. Fault reports and evidence photos are new records and apply at once for every key. - Concurrency:
If-Match(orexpected_version) on a PATCH; a stale version answers409 version_conflict. - Batches:
POST /api/batch, up to 50 operations, all or nothing, withdry_runto preview.
Look up, then act; undo
GET /api/lookup?q=…finds items, serials, tools, gauges, machines, locations and people from loose text, typos, æøå, sizes likeØ10and scanned QR or barcodes. Use the top hit only whenneeds_confirmis false; never invent ids.- Every change has a history entry with before and after values.
POST /api/events/{id}/revertundoes it if nothing later conflicts; from an agent key an undo is a proposal a person confirms. GET /api/digest: low stock, calibration and service due, pending proposals, open faults and yesterday’s changes.
Limits and network
- 600 requests per minute per key by default; over that,
429withRetry-After. - Plain HTTP is fine for an agent inside the shop network. An agent in the cloud or anywhere off-site must reach Bayline over HTTPS or a VPN.
- Harnesses that speak MCP can use the optional MCP server instead of raw HTTP.
On this demo
The public demo refuses every agent-key (Bearer) API request with 403 demo_restricted, and creating keys is turned off. The schema and this documentation are public; to call the API with a key, use your own Bayline.