Docs
Domain
Timeline
Timeline
This page defines the canonical Slice 4 Trip and Booking lifecycles. States and transitions below are authoritative for API resources, domain code, tests, and surface behavior.
1. Trip lifecycle
1.1 Trip states
State
Description
Actor / entry action
Allowed next states
scheduled
Trip is planned; Passengers may request Bookings and Managers may approve them.
Manager creates Trip.
in_transit, cancelled
in_transit
Assigned Driver has started the Trip.
Driver calls POST /api/driver/trips/{id}/start; sets started_at.
completed, cancelled
completed
Assigned Driver completed the Trip. Terminal.
Driver calls POST /api/driver/trips/{id}/complete; sets completed_at.
None
cancelled
Manager cancelled the Trip. Terminal; active Bookings are cancelled.
Manager calls POST /api/company/trips/{id}/cancel; sets cancelled_at.
None
stateDiagram-v2
[*] --> scheduled: Manager creates
scheduled --> in_transit: Assigned Driver starts
in_transit --> completed: Assigned Driver completes
scheduled --> cancelled: Manager cancels
in_transit --> cancelled: Manager cancels/interrupted
completed --> [*]
cancelled --> [*]
Planning fields can be fully updated only while scheduled.
Starting a Trip rejects its remaining pending Bookings. Manager booking approval is not allowed after start.
There is no separate boarding Trip state in Slice 4. Boarding is a later Live Ops action and does not alter this status vocabulary.
Invalid transitions return 422 errors.status; inaccessible/cross-company Trip IDs return 404.
2. Booking lifecycle
2.1 Booking states
State
Description
Who acts
Allowed next states
pending
Passenger requested a Trip seat; it does not occupy capacity yet.
Passenger creates Booking.
approved, rejected, cancelled
approved
Manager accepted the Booking; it occupies one Trip seat.
Manager approves; system rejects on Trip start if still pending.
cancelled
rejected
Manager rejected the Booking, or the system rejected it when the Trip started. Terminal.
Manager/system.
None
cancelled
Passenger cancelled, or Manager cancelled the Trip. Terminal; an approved seat is released.
Passenger/Manager/system.
None
stateDiagram-v2
[*] --> pending: Passenger requests
pending --> approved: Manager approves
pending --> rejected: Manager rejects / Trip starts
pending --> cancelled: Passenger or Trip cancellation
approved --> cancelled: Passenger or Trip cancellation
rejected --> [*]
cancelled --> [*]
Booking status is exactly pending | approved | rejected | cancelled; there is no requested, confirmed, boarded, or completed Booking status in Slice 4.
boarded_at is nullable operational data reserved for Live Ops; it does not change Booking status.
Only approved Bookings count against Trip capacity. pending Bookings do not hold seats.
A Passenger may have at most one active Booking (pending or approved) per Trip.
Request and approval require an active Passenger Membership and enforce the optional reservation deadline. Approval also enforces Trip capacity and Tier integrity while locking the Trip row.
Booking consumes no subscription Seat and carries no charge.
3. Lifecycle errors
Case
HTTP
Error field
Booking/Trip not found or cross-company
404
Message only
Wrong role on a role-specific endpoint
403
Message only
Suspended Company
403
Message only
Invalid status transition
422
status
Reservation deadline passed
422
reservation_deadline_at
Trip capacity reached
422
seats
Tier integrity exceeded
422
seats
Active Booking already exists
422
trip_id
Passenger Membership not active/approved
403
Message only
4. Deferred lifecycle concerns
Boarding/QR/GPS events and realtime state belong to Live Ops.
D2D eligibility, detours, and route-plan changes belong to the later D2D slice.
Trip duplication and extra-car dispatch have separate future contracts.
Post-trip Booking completion is not a separate status in Slice 4; the completed Trip is the participation record.