> ## 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.

# Roles

> Understand the four user roles in the RideShare API and what each role can do.

The RideShare API uses role-based access control. Every authenticated request is scoped to the role you present at login. There are four roles: `USER`, `RIDER`, `DRIVER`, and `ADMIN`.

## Role overview

| Role     | Who it's for                           | Access level                                |
| -------- | -------------------------------------- | ------------------------------------------- |
| `USER`   | General authenticated users            | View rides and public data                  |
| `RIDER`  | Passengers booking rides               | Book rides, view history, submit feedback   |
| `DRIVER` | Drivers accepting and completing rides | Accept rides, update location and status    |
| `ADMIN`  | Platform administrators                | Full access to all `/api/admin/*` endpoints |

## What each role can do

### USER

The `USER` role provides general read access. You can view ride status and public ride data, but you cannot book rides or perform driver actions.

### RIDER

The `RIDER` role is for passengers. With this role you can:

* Book a new ride: `POST /rides/book`
* Get a fare estimate: `GET /rides/estimate`
* View your ride history: `GET /rides/history`
* Check the status of a specific ride: `GET /rides/status/{rideId}`
* Cancel a ride: `POST /rides/cancel/{rideId}`
* Submit post-ride feedback and a rating: `POST /rides/feedback/{rideId}`
* Browse nearby available drivers: `GET /rides/drivers/nearby`

### DRIVER

The `DRIVER` role is for drivers. With this role you can:

* View open ride requests: `GET /rides/requested`
* Accept a ride or update its status: `POST /rides/status/{rideId}`
* Update your live location during a ride: `POST /rides/location/{rideId}`
* Submit feedback on a rider: `POST /rides/feedback/{rideId}`

### ADMIN

The `ADMIN` role grants full access to all platform management endpoints under `/api/admin/*`, including user management, ride oversight, and reporting.

## Logging in with a role

You specify your role in the `role` field of your login request body. The token returned is scoped to that role for the duration of the session.

<CodeGroup>
  ```json Login as RIDER theme={null}
  {
    "email": "alice@example.com",
    "password": "secret",
    "role": "RIDER"
  }
  ```

  ```json Login as DRIVER theme={null}
  {
    "email": "bob@example.com",
    "password": "secret",
    "role": "DRIVER"
  }
  ```

  ```json Login as ADMIN theme={null}
  {
    "email": "admin@example.com",
    "password": "secret",
    "role": "ADMIN"
  }
  ```
</CodeGroup>

The response returns a bearer token. Include it in the `Authorization` header of every subsequent request:

```http theme={null}
Authorization: Bearer <token>
```

<Note>
  Your account has a default role stored on your profile, but you can request any valid role at login by setting the `role` field explicitly. The role you specify at login determines what you can do for that session.
</Note>
