Skip to content

API Overview ​

Base path: /api/v1

Transport: HTTPS. Format: JSON. Authentication: Bearer access token.

All authenticated endpoints use token-based authentication. Sensitive operations require authorization checks independent of frontend visibility.

Domain model ​

The API mirrors the domain, not a generic dispatch model:

text
Journey
    ↓
Ride Request
    ↓
Match
    ↓
Compliance
    ↓
Booking
    ↓
Journey Execution
    ↓
Contribution / Rating / Audit

There is deliberately no POST /rides resource. The platform is based on people sharing journeys they are already making, not on dispatching a driver to a demand signal. A rides or trips resource implies a supply-on-demand relationship the product does not have, and naming encourages building one.

Resources ​

text
/api/v1
├── auth
├── users
├── drivers
├── vehicles
├── journeys
├── ride-requests
├── matches
├── bookings
├── contributions
├── ratings
├── incidents
├── notifications
├── compliance
├── admin
└── regulatory

/admin and /regulatory are privileged namespaces and are never reachable from a consumer client. /regulatory is reserved for the agreed authority interface and remains undefined until that interface is agreed — see Regulatory Model.

Authentication ​

text
Authorization: Bearer <access-token>

Access token plus refresh token plus a revocable device session.

Access tokens are short-lived and are not stored server-side. Refresh tokens are held as hashes in user_sessions, so POST /auth/logout revokes the session immediately rather than waiting for a token to expire.

Common headers ​

text
Authorization: Bearer <token>
Content-Type: application/json
Accept: application/json
X-Request-ID: <uuid>
Idempotency-Key: <uuid>

Idempotency ​

Idempotency-Key is required for state-changing operations where a duplicate request would create a duplicate outcome:

  • create journey
  • accept match
  • create booking
  • confirm booking
  • start journey
  • complete journey
  • cancel journey
  • create contribution
  • emergency

These are exactly the operations where a mobile client retrying on a flaky connection would otherwise double-book a passenger.

Standard response ​

Single resource:

json
{ "data": {}, "meta": { "requestId": "req_123" } }

Paginated collection:

json
{
  "data": [],
  "pagination": { "nextCursor": "cursor", "hasMore": true }
}

Standard error ​

json
{
  "error": {
    "code": "JOURNEY_NOT_ELIGIBLE",
    "message": "The journey cannot currently accept this request.",
    "requestId": "req_123",
    "details": []
  }
}

details is an array. It is always present; it is empty when there is nothing field-level to report.

Error codes ​

CodeMeaning
AUTH_REQUIREDNo credentials supplied
AUTH_INVALIDCredentials present but invalid or expired
IDENTITY_NOT_VERIFIEDIdentity verification required or expired
DRIVER_NOT_ELIGIBLEDriver profile fails a mandatory rule
VEHICLE_NOT_VERIFIEDVehicle verification required or expired
JOURNEY_NOT_FOUNDJourney does not exist or is not visible to the caller
JOURNEY_NOT_ELIGIBLEJourney cannot currently accept this request
JOURNEY_FULLNo seats remain
NO_MATCH_FOUNDNo compatible journey exists
MATCH_EXPIREDOffer window elapsed
BOOKING_NOT_AVAILABLEBooking cannot be created from this match
BOOKING_ALREADY_CONFIRMEDBooking already confirmed
CONTRIBUTION_NOT_AVAILABLEContribution disabled or mode not approved by policy
ACCOUNT_RESTRICTEDAccount is restricted, suspended or blocked
COMPLIANCE_REVIEW_REQUIREDHeld for human review
COMPLIANCE_BLOCKEDBlocked by a mandatory policy rule
RATE_LIMITEDRate limit exceeded
VALIDATION_ERRORRequest failed validation
INTERNAL_ERRORUnexpected server failure

Compliance decisions are not error codes. A REVIEW outcome is returned as a normal response carrying the decision, not as an error, because the operation succeeded — it was held.

Pagination ​

Cursor-based:

text
GET /api/v1/journeys?cursor=<cursor>&limit=20
json
{
  "data": [],
  "pagination": { "nextCursor": "cursor", "hasMore": true }
}

Cursor pagination is used rather than offset pagination because journey and compliance lists grow continuously and offset pagination skips or repeats rows when rows are inserted mid-scroll — which for an auditable list is a correctness problem, not just a UX one.

Versioning ​

Current: /api/v1. Breaking changes: /api/v2.

The meaning of an existing field must never change silently. Adding an optional field, a new endpoint, or a new enum value that existing clients already tolerate is not a breaking change; renaming, removing, narrowing, or changing the semantics of a field is.

Security ​

Required controls on every endpoint:

  • TLS
  • Bearer authentication
  • RBAC
  • input validation
  • rate limiting
  • CORS restrictions
  • request IDs
  • idempotency on material mutations
  • audit logging
  • sensitive-data encryption
  • token rotation
  • session revocation
  • abuse detection

Role-based access ​

Administrative roles:

text
SUPER_ADMIN
COMPLIANCE_ADMIN
SAFETY_ADMIN
SUPPORT_AGENT
ANALYST
AreaMinimum role
Compliance rules and eventsCOMPLIANCE_ADMIN
Incidents and emergency reviewSAFETY_ADMIN
User restrictions, support actionsSUPPORT_AGENT
Reporting and analyticsANALYST
Role and policy assignmentSUPER_ADMIN

Internal risk scores, rule detail and evidence are available only to authorised administrative roles. Ordinary users see only what they need to make a booking decision — never a risk score, never an internal compliance reason code.

Realtime ​

Live journey state is delivered over WebSocket at /ws/v1/journeys/{journeyId}. See Realtime.

KHAWI — same route, go together.