> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.driver.olycab.in/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.driver.olycab.in/_mcp/server.

# Get Driver Referral Network

GET https://driver/#get17

# Get Driver Referral Network (`/driver/referrals`)

Retrieves the authenticated driver's personal referral code, the total count of referees, and the detailed list of users and drivers who registered using their referral code.

***

### Endpoint Overview

* **Method:** `GET`

* **Route:** `/api/v1/driver/referrals`

* **Authentication:** `Bearer Token (Driver JWT)`

* **Content-Type:** `N/A`

***

### Request Headers

| Header          | Type     | Required | Description      |
| --------------- | -------- | -------- | ---------------- |
| `Authorization` | `string` | **Yes**  | Format: `Bearer` |

***

### Request Body Schema

*None (GET request)*

***

### Response Body Schema (`200 OK`)

| Top-Level Key    | Data Type | Description                                            |
| ---------------- | --------- | ------------------------------------------------------ |
| `referral_code`  | `string`  | Driver's own unique referral code (e.g. `"CAP_8X9K2"`) |
| `total_referred` | `integer` | Total count of registered referees                     |
| `referred_users` | `array`   | List of referees (both drivers and riders)             |

#### `Referee Item Fields`

| Field               | Data Type | Nullable | Allowed Values / Constraints   | Description                  |
| ------------------- | --------- | -------- | ------------------------------ | ---------------------------- |
| `id`                | `string`  | No       | Prefixed with `drv_` or `usr_` | Unique account ID of referee |
| `name`              | `string`  | Yes      | String                         | Full name of referee         |
| `phone`             | `string`  | No       | E.164 string format            | Registered phone number      |
| `profile_image_url` | `string`  | Yes      | Valid URL                      | Avatar image URL             |
| `type`              | `enum`    | No       | `"DRIVER"`, `"USER"`           | Platform role of referee     |
| `referred_at`       | `string`  | No       | ISO 8601 Timestamp             | Registration timestamp       |

***

### `Response Examples`

#### ``1. `200 OK` — Referrals Found``

```json
{
  "referral_code": "CAP_8X9K2",
  "total_referred": 2,
  "referred_users": [
    {
      "id": "drv_1a2b3c4d5e",
      "name": "Suresh Patel",
      "phone": "+919811122233",
      "profile_image_url": "https://example.com/profiles/suresh.jpg",
      "type": "DRIVER",
      "referred_at": "2026-09-15T10:30:00.000Z"
    },
    {
      "id": "usr_9z8y7x6w5v",
      "name": "Priya Sharma",
      "phone": "+919844455566",
      "profile_image_url": null,
      "type": "USER",
      "referred_at": "2026-09-18T14:15:22.000Z"
    }
  ]
}

```

#### ``2. `200 OK` — No Referrals Yet``

```json
{
  "referral_code": "CAP_8X9K2",
  "total_referred": 0,
  "referred_users": []
}

```

#### ``3. `401 Unauthorized` — Missing / Expired Token / Revoked Session``

```json
{
  "error": "Unauthorized",
  "message": "Invalid or expired driver access token."
}

```

#### ``4. `403 Forbidden` — Account Blocked / Deactivated``

```json
{
  "error": "Forbidden",
  "message": "Driver account is blocked or deactivated."
}

```

#### ``5. `404 Not Found` — Referral Code Not Found``

```json
{
  "error": "Referral code not found for driver"
}

```

#### `` 6. `500 Internal Server Error` ``

```json
{
  "error": "Failed to fetch referral data"
}

```

***

### `Status Codes Reference`

| HTTP Status Code                | Condition                                                        |
| ------------------------------- | ---------------------------------------------------------------- |
| **`200 OK`**                    | Successfully retrieved driver referral code and referee network. |
| **`401 Unauthorized`**          | Missing, invalid, expired token or session revoked.              |
| **`403 Forbidden`**             | Driver account has been deactivated or blocked.                  |
| **`404 Not Found`**             | Driver has no referral code assigned.                            |
| **`500 Internal Server Error`** | Database or query execution failure.                             |

Reference: https://docs.driver.olycab.in/oly-driver/referal/get-driver-referral-network

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Examples

**SDK Code**

```python
import requests

url = "https://driver/#get17"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://driver/#get17';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://driver/#get17"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://driver/#get17")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://driver/#get17")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://driver/#get17', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://driver/#get17");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://driver/#get17")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```