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 Authorization header. You get one through the magic-link flow below, and it’s good for 30 days.
  • Scoping: list endpoints take ?scope=me or ?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

MethodPathPurpose
POST/v1/auth/magic-linkRequest a sign-in email
POST / GET/v1/auth/verifyExchange a magic-link token for a session
POST/v1/auth/logoutInvalidate the current session
GET/v1/meCurrent user, organizations, and vehicles

Organizations, vehicles & drivers

MethodPathPurpose
POST/v1/orgsCreate an organization
GET/v1/orgs/:idOrganization details and members
POST/v1/orgs/:id/invitesInvite a teammate (admin)
POST/v1/vehiclesRegister a vehicle
GET/v1/vehiclesList vehicles (scope=me | org:id)
POST/v1/driversCreate a driver profile
GET/v1/driversList driver profiles
PATCH/v1/drivers/:idUpdate a driver profile
DELETE/v1/drivers/:idDelete a driver profile (rides are kept, unlinked)

Rides, telemetry & events

MethodPathPurpose
POST/v1/ridesCreate a ride (unit-minted UUID, offline-safe)
GET/v1/ridesList rides, newest first. Query: scope; limit (default 50, max 200); since (Unix ms, returns rides started after it)
GET/v1/rides/:idFull ride: stats, track, events, clips
GET/v1/rides/:id/track1 Hz track as columnar JSON arrays
PATCH/v1/rides/:idAttribute the ride to a driver / vehicle
PATCH/v1/rides/:id/finalizeClose the ride and compute stats
POST/v1/rides/:id/eventsBatch-insert driving events
POST/v1/rides/:id/samplesBatch-append 1 Hz telemetry
GET/v1/rides/:id/liveLive stream: WebSocket upgrade, or a plain GET for the latest sample

Audio clips & AI

MethodPathPurpose
POST/v1/rides/:id/clipsRegister a clip and receive an upload target
GET/v1/clips/:id/dataDownload the clip's WAV audio
POST/v1/ai/chatStreamed 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_level and on events per ride, then route them into your maintenance or dispatch system.
  • Live wallboard: subscribe to /v1/rides/:id/live for 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.

The dashboard itself is just a client of this exact API. There’s no private surface hiding anywhere. If the dashboard can show it, you can query it too.