Skip to main content
Cancel a ride by its ID. The server records the reason, the identity of who cancelled, and any applicable cancellation fee, then returns the updated ride object. Authentication required — include Authorization: Bearer <token> in the request header.

Request

POST /rides/cancel/{rideId}
rideId
number
required
The unique ID of the ride to cancel.
reason
string
An optional explanation for the cancellation. Stored in cancellationReason on the ride.

Response

id
number
Unique ride identifier.
status
string
Always CANCELLED after a successful cancellation.
cancellationReason
string
The reason provided in the request body, or an empty string if none was given.
cancelledBy
string
Identifier indicating who initiated the cancellation (rider or driver).
cancellationFee
number
Fee charged for the cancellation, or null if no fee applies.
riderId
number
ID of the rider.
driverId
number
ID of the assigned driver, or null.
fare
number
Original fare for the ride.
pickupLocation
string
Pickup address.
dropLocation
string
Drop-off address.
createdAt
string
ISO 8601 timestamp of ride creation.

Example

curl -X POST "http://localhost:8080/rides/cancel/1021" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Driver is taking too long"
  }'
A cancellationFee may be charged depending on how much time has elapsed since the ride was accepted. Check the cancellationFee field in the response to see the exact amount deducted.
You can send a cancellation request with no body — the reason field is entirely optional. If you omit the body, the cancellationReason on the ride will be stored as an empty string.