The Bookings API is the central workflow engine of KaroKar’s B2B2C mobility marketplace. A booking represents a corporate organisation’s request to reserve a vendor-owned vehicle for a named employee over a defined date range. Every state change is driven through a strict set of allowed transitions, guarded by per-permission decorators, and broadcasts a domain event so downstream modules — availability, assignment, and billing — can react without tight coupling. All endpoints live under theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Codefied-CodePix/Karokar-backend/llms.txt
Use this file to discover all available pages before exploring further.
PermissionGuard; callers must supply a valid JWT and hold the required permission for each operation.
All requests require an
Authorization: Bearer <token> header. Tokens are issued by the authentication service and encode the caller’s permissions.State Transitions
The table below shows every legal transition. Attempting any other transition returns aDomainException with code INVALID_BOOKING_TRANSITION.
| From \ To | REQUESTED | APPROVED | REJECTED | ASSIGNED | ACTIVE | COMPLETED | TERMINATED | CANCELLED |
|---|---|---|---|---|---|---|---|---|
| DRAFT | ✅ | |||||||
| REQUESTED | — | ✅ | ✅ | ✅ | ||||
| APPROVED | — | — | ✅ | ✅ | ||||
| ASSIGNED | — | — | — | ✅ | ✅ | |||
| ACTIVE | — | — | — | — | ✅ | ✅ |
COMPLETED, TERMINATED, REJECTED, and CANCELLED are terminal states — no further transitions are permitted.
POST /bookings
Create a new booking inDRAFT status. The draft is not yet visible to the vendor; call PATCH /bookings/:id/submit to send it.
Required permission: booking.create
Request Body
UUID of the vehicle being booked.
UUID of the vendor organisation that owns the vehicle.
UUID of the corporate organisation making the booking request.
UUID of the user (employee or fleet manager) who initiated the request.
Inclusive start date-time for the booking period, e.g.
"2025-09-01T08:00:00Z".Inclusive end date-time for the booking period, e.g.
"2025-09-30T17:00:00Z".Response
Returns the newly createdBooking with status: "DRAFT".
Unique identifier for the booking, auto-generated.
UUID of the booked vehicle.
UUID of the vendor organisation.
UUID of the corporate organisation.
UUID of the requesting user.
Booking start date-time.
Booking end date-time.
Always
DRAFT on creation.Record creation timestamp.
Last update timestamp.
Example
GET /bookings/:id
Retrieve a single booking by its UUID. No permission is required beyond a valid authentication token. Required permission: nonePath Parameters
UUID of the booking to retrieve.
Response
Returns theBooking object, or null if not found. Fields are identical to the POST /bookings response above.
Example
PATCH /bookings/:id/submit
Submit aDRAFT booking to the vendor for review. Transitions the status from DRAFT → REQUESTED and emits a BookingRequested domain event that notifies downstream listeners (e.g. the availability module).
Required permission: booking.create
Path Parameters
UUID of the booking to submit.
Request Body
No request body required.Response
Returns the updatedBooking with status: "REQUESTED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in DRAFT status |
Example
PATCH /bookings/:id/approve
Approve a booking that is inREQUESTED status. Transitions the status to APPROVED and emits a BookingApproved event. Downstream listeners create an availability record in RESERVED state.
Required permission: booking.approve
Path Parameters
UUID of the booking to approve.
Request Body
Optional free-text notes from the approver (e.g. conditions or references).
Response
Returns the updatedBooking with status: "APPROVED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.approve permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in REQUESTED status |
Example
PATCH /bookings/:id/reject
Reject a booking inREQUESTED status. Transitions to REJECTED, which is a terminal state. Emits a BookingRejected event.
Required permission: booking.approve
Path Parameters
UUID of the booking to reject.
Request Body
No request body required.Response
Returns the updatedBooking with status: "REJECTED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.approve permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in REQUESTED status |
Example
PATCH /bookings/:id/assign
Assign an employee to anAPPROVED booking. Transitions the booking from APPROVED → ASSIGNED, emits a BookingAssigned event, and triggers creation of an Assignment record. Availability transitions from RESERVED → ALLOCATED.
Required permission: booking.approve
Path Parameters
UUID of the booking to assign.
Request Body
UUID of the employee to be assigned to this booking.
Response
Returns the updatedBooking with status: "ASSIGNED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.approve permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in APPROVED status |
Example
PATCH /bookings/:id/activate
Activate anASSIGNED booking, marking the employee-vehicle handover as having taken effect. Transitions from ASSIGNED → ACTIVE and emits a BookingActivated event.
Required permission: booking.approve
Path Parameters
UUID of the booking to activate.
Request Body
No request body required.Response
Returns the updatedBooking with status: "ACTIVE".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.approve permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in ASSIGNED status |
Example
PATCH /bookings/:id/complete
Mark anACTIVE booking as successfully completed at end of the rental period. Transitions from ACTIVE → COMPLETED, emits a BookingCompleted event, and triggers release of the vehicle’s availability record.
Required permission: booking.approve
Path Parameters
UUID of the booking to complete.
Request Body
No request body required.Response
Returns the updatedBooking with status: "COMPLETED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.approve permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in ACTIVE status |
Example
PATCH /bookings/:id/cancel
Cancel a booking that has not yet reached an active or terminal state. Valid fromREQUESTED, APPROVED, or ASSIGNED. Emits a BookingCancelled event; any existing availability reservation is released.
Required permission: booking.cancel
Path Parameters
UUID of the booking to cancel.
Request Body
No request body required.Response
Returns the updatedBooking with status: "CANCELLED".
Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.cancel permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is in DRAFT, ACTIVE, COMPLETED, TERMINATED, REJECTED, or CANCELLED |
Example
PATCH /bookings/:id/terminate
Forcibly end anACTIVE booking before its natural completion date. This is the only route from ACTIVE to a non-COMPLETED terminal state. The call creates a BookingTermination record capturing the reason, actor, and timestamp, then emits a BookingTerminated event.
Required permission: booking.terminate
Path Parameters
UUID of the booking to terminate.
Request Body
The reason for early termination. Must be one of the
TerminationReason values listed below.UUID of the user or system actor performing the termination.
Optional free-text notes providing additional context for the termination.
TerminationReason Enum
| Value | Description |
|---|---|
VEHICLE_BREAKDOWN | The vehicle suffered a mechanical or technical failure. |
ACCIDENT | The vehicle was involved in an accident. |
VENDOR_RECALL | The vendor recalled the vehicle for operational reasons. |
CORPORATE_RECALL | The corporate organisation recalled the vehicle or the assignment. |
EMPLOYEE_EXIT | The assigned employee left the organisation or had their access revoked. |
COMPLIANCE_VIOLATION | A compliance or policy rule was breached. |
INSURANCE_EXPIRED | The vehicle’s or driver’s insurance lapsed during the booking. |
ADMIN_ACTION | An administrator terminated the booking for platform-level reasons. |
OTHER | None of the above categories apply; use notes to describe. |
Response
Returns the updatedBooking with status: "TERMINATED".
A BookingTermination record is created separately and contains the following fields:
Unique identifier of the termination record.
UUID of the booking that was terminated.
Enum value indicating why the booking was terminated.
UUID of the actor who triggered the termination.
Timestamp at which the termination was recorded.
Optional supplementary notes;
null if not provided.Errors
| HTTP | Code | Condition |
|---|---|---|
| 403 | — | Caller lacks booking.terminate permission |
| 404 | — | Booking not found |
| 422 | INVALID_BOOKING_TRANSITION | Booking is not in ACTIVE status |