// CONTENTS Part 08 · APIs and contracts

// PART 08

REST API

Chapter 33 / 56 2 min read English Part 08 of 14

Base URL

http://localhost:8080/api

Every local route starts with /api. The single exception is the legacy sandbox endpoint POST /api/v1/sandbox/exec (botserver/crates/botagent/src/lib.rs) — it is the only local /api/v1 route in the tree; do not treat /api/v1 as a versioned base URL.

Authentication

Authorization: Bearer <token>

The auth layer, the anonymous allow-list (/ws, health, public catalog) and the rate-limit classes are applied in botserver/src/main_module/server/run_axum_server.rs and botserver/src/main_module/routes/security_setup.rs. Endpoints that need no token are listed in the generated reference with public.

Rate limiting uses the governor crate with per-class profiles (botsecurity-auth/src/rate_limiter.rs): the default HTTP class is 100 requests/s (burst 200), and authentication surfaces use the strict profile at 10 requests/s (burst 10) to absorb legitimate retries while stopping brute-force attempts.

Two exemptions exist, both deliberate: Bearer-token API calls are stateless and skip CSRF, and internal service calls present a short-lived signed assertion — never a caller-supplied header.

Endpoint families

Family Prefix Example routes
Users / profile /api/user/*, /api/users/* GET /api/users
Admin /api/admin/* GET /api/admin/dashboard/stats
Drive files /api/files/* GET /api/files/list, POST /api/files/write
Apps / catalog /api/apps/* GET /api/apps/catalog, POST /api/apps/install
CRM / people /api/crm/*, /api/contacts/* see generated reference
Products / billing /api/products/*, /api/billing/* see generated reference
Analytics /api/analytics/* GET /api/analytics/usage
Office events /api/events/*, /ws/events* POST /api/events/publish, GET /ws/events/stream
Approvals /api/approvals/* POST /api/approvals, POST /api/approvals/:id/decide

/chat/* is not a REST prefix: chat runs over the WebSocket pipeline at /ws (see WebSocket protocol). The only /api/chat* routes are the history/session helpers in botserver/src/main_module/routes/chat_handlers.rs.

Response and error conventions

  • Handlers return JSON for APIs and HTML fragments for HTMX surfaces (/api/ui/*, /cloud/partials/*) — botserver never returns a complete HTML page.
  • Errors are sanitized before they leave the process (log_and_sanitize): the log carries the detail, the client gets a safe message. Raw error strings from internals are forbidden.
  • Mutating endpoints expect a CSRF token unless they are Bearer-token calls.

The full inventory is generated

The complete, code-derived route table (method, path, summary, registered-in file, public flag) is generated by scripts/gen_api_reference.py from the route sources and the catalog. Regenerate or check drift:

python3 scripts/gen_api_reference.py            # write
python3 scripts/gen_api_reference.py --check    # fail on drift

Treat the generated pages as the source of truth for what exists; this page explains how the surface behaves.

Integration checklist

Concern Practice
Base URL http://localhost:8080/api (see Network contract for ports)
Auth Bearer token; public endpoints listed in the generated reference
Rate limits 100 req/s general, 10 req/s on auth surfaces
Mutations CSRF token unless Bearer
Errors expect sanitized messages; detail is server-side
New endpoints register in the API command catalog if chat should reach them

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move