Platform
API reference
- Written for
- Integration and backend engineers.
- You need
- A dashboard account and an HTTP client such as curl. The first section shows how to get a session token.
Everything you see in the dashboard is also available over a REST and WebSocket API. Use it to pull rides, events, diagnoses, and driver data into your own systems, or to build directly on top of the platform.
Basics#
- Base URL:
https://mantai-api.mantai-backend.workers.dev/v1 - Format: request and response bodies are JSON, and audio downloads come back as WAV bytes.
- Authentication: pass a bearer session token in the
Authorizationheader. You get one through the magic-link flow below, and it’s good for 30 days. - Scoping: list endpoints take
?scope=meor?scope=org:<id>, and access is enforced by your organization membership and role.
Authenticate
# 1. Request a magic link for your email
curl -X POST https://mantai-api.mantai-backend.workers.dev/v1/auth/magic-link \
-H "Content-Type: application/json" \
-d '{"email": "you@yourfleet.com"}'
# 2. Verify the token from the email -> returns a session token
curl -X POST https://mantai-api.mantai-backend.workers.dev/v1/auth/verify \
-H "Content-Type: application/json" \
-d '{"token": "<token-from-email>"}'
# 3. Call the API
curl "https://mantai-api.mantai-backend.workers.dev/v1/rides?scope=me&limit=50" \
-H "Authorization: Bearer <session-token>"Endpoints#
Auth & account
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/auth/magic-link | Request a sign-in email |
| POST / GET | /v1/auth/verify | Exchange a magic-link token for a session |
| POST | /v1/auth/logout | Invalidate the current session |
| GET | /v1/me | Current user, organizations, and vehicles |
Organizations, vehicles & drivers
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/orgs | Create an organization |
| GET | /v1/orgs/:id | Organization details and members |
| POST | /v1/orgs/:id/invites | Invite a teammate (admin) |
| POST | /v1/vehicles | Register a vehicle |
| GET | /v1/vehicles | List vehicles (scope=me | org:id) |
| POST | /v1/drivers | Create a driver profile |
| GET | /v1/drivers | List driver profiles |
| PATCH | /v1/drivers/:id | Update a driver profile |
| DELETE | /v1/drivers/:id | Delete a driver profile (rides are kept, unlinked) |
Rides, telemetry & events
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/rides | Create a ride (unit-minted UUID, offline-safe) |
| GET | /v1/rides | List rides, newest first. Query: scope; limit (default 50, max 200); since (Unix ms, returns rides started after it) |
| GET | /v1/rides/:id | Full ride: stats, track, events, clips |
| GET | /v1/rides/:id/track | 1 Hz track as columnar JSON arrays |
| PATCH | /v1/rides/:id | Attribute the ride to a driver / vehicle |
| PATCH | /v1/rides/:id/finalize | Close the ride and compute stats |
| POST | /v1/rides/:id/events | Batch-insert driving events |
| POST | /v1/rides/:id/samples | Batch-append 1 Hz telemetry |
| GET | /v1/rides/:id/live | Live stream: WebSocket upgrade, or a plain GET for the latest sample |
Audio clips & AI
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/rides/:id/clips | Register a clip and receive an upload target |
| GET | /v1/clips/:id/data | Download the clip's WAV audio |
| POST | /v1/ai/chat | Streamed AI chatbox, the same endpoint the Ask MantAI page uses |
The request and response shapes, a curl example, and a JavaScript streaming example all live on the AI chatbox page.
Clip analysis kicks off on its own right after upload. Poll the clip’s analysis_status: it starts at none, becomes queued on upload, and ends as done, failed, or skipped (analysis is not configured on that deployment). Once it is done, read analysis_json for the structured findings described in Sound diagnosis.
Integration patterns#
- Sync rides nightly: pull
GET /v1/rides?since=<ts>into your warehouse. Each ride already carries its event counts and stats. - Mirror alerts: keep an eye on clips with an elevated
risk_leveland on events per ride, then route them into your maintenance or dispatch system. - Live wallboard: subscribe to
/v1/rides/:id/livefor active rides and render your own live view.
Example: sync rides into your own database
A nightly job that pulls everything that started since the last run and upserts it. GET /v1/rides returns a JSON array of ride rows, newest first, each with an event_count. Rides that are still active are left for the next run, and the checkpoint moves back to the oldest of them so none is skipped once it finalizes.
// Node.js 18+. sessionToken, orgId, loadCheckpoint, saveCheckpoint, and
// warehouse are yours; everything else is the public API.
const BASE = "https://mantai-api.mantai-backend.workers.dev/v1";
const since = await loadCheckpoint(); // Unix ms; 0 on the very first run
const url = BASE + "/rides?scope=org:" + orgId + "&since=" + since + "&limit=200";
const res = await fetch(url, { headers: { Authorization: "Bearer " + sessionToken } });
if (!res.ok) throw new Error("GET /rides failed: " + res.status);
const rides = await res.json(); // newest first
for (const ride of rides) {
if (ride.status !== "finalized") continue; // still active: pick it up next run
await warehouse.upsert("rides", ride.id, ride); // ids never change, so this is idempotent
}
// Next run starts just before the oldest ride that was still active, or at
// the newest ride if everything had finalized.
const active = rides.filter((r) => r.status === "active");
if (rides.length > 0) {
const oldestActive = Math.min(...active.map((r) => r.started_at));
await saveCheckpoint(active.length > 0 ? oldestActive - 1 : rides[0].started_at);
}The list is capped at 200 rides per call. Run the sync often enough that fewer than 200 rides start between runs; for most fleets, nightly is plenty.