> ## Documentation Index
> Fetch the complete documentation index at: https://rideshare.docs.sumit-dhondikar.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel Ride

> Cancel an active ride and receive the updated ride record.

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}`**

<ParamField path="rideId" type="number" required>
  The unique ID of the ride to cancel.
</ParamField>

<ParamField body="reason" type="string">
  An optional explanation for the cancellation. Stored in `cancellationReason` on the ride.
</ParamField>

## Response

<ResponseField name="id" type="number">
  Unique ride identifier.
</ResponseField>

<ResponseField name="status" type="string">
  Always `CANCELLED` after a successful cancellation.
</ResponseField>

<ResponseField name="cancellationReason" type="string">
  The reason provided in the request body, or an empty string if none was given.
</ResponseField>

<ResponseField name="cancelledBy" type="string">
  Identifier indicating who initiated the cancellation (rider or driver).
</ResponseField>

<ResponseField name="cancellationFee" type="number">
  Fee charged for the cancellation, or `null` if no fee applies.
</ResponseField>

<ResponseField name="riderId" type="number">
  ID of the rider.
</ResponseField>

<ResponseField name="driverId" type="number">
  ID of the assigned driver, or `null`.
</ResponseField>

<ResponseField name="fare" type="number">
  Original fare for the ride.
</ResponseField>

<ResponseField name="pickupLocation" type="string">
  Pickup address.
</ResponseField>

<ResponseField name="dropLocation" type="string">
  Drop-off address.
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp of ride creation.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  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"
    }'
  ```

  ```json Response theme={null}
  {
    "id": 1021,
    "status": "CANCELLED",
    "riderId": 42,
    "driverId": 7,
    "fare": 145.00,
    "pickupLocation": "MG Road, Bangalore",
    "dropLocation": "Indiranagar, Bangalore",
    "cancellationReason": "Driver is taking too long",
    "cancelledBy": "rider",
    "cancellationFee": 25.00,
    "createdAt": "2026-04-02T10:15:30Z"
  }
  ```
</CodeGroup>

<Warning>
  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.
</Warning>

<Note>
  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.
</Note>
