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

# driver-device-token

GET https://driver/

# Register / Update Driver Device Token

Registers or updates the Firebase Cloud Messaging (FCM) device push notification token for the authenticated driver's mobile device (Android or iOS). Used to send dispatch alerts, new ride requests, and system notifications.

***

### Endpoint Overview

* **Method:** `POST`

* **Route:** `/api/v1/driver/device-token`

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

* **Content-Type:** `application/json`

***

### Request Headers

| Header          | Type     | Required | Description                |
| --------------- | -------- | -------- | -------------------------- |
| `Authorization` | `string` | **Yes**  | Format: `Bearer`           |
| `Content-Type`  | `string` | **Yes**  | Must be `application/json` |

***

### Request Body Schema

| Field       | Data Type | Required | Default | Allowed Values / Constraints | Description                                |
| ----------- | --------- | -------- | ------- | ---------------------------- | ------------------------------------------ |
| `fcm_token` | `string`  | **Yes**  | —       | Min length 1                 | Firebase Cloud Messaging push token string |
| `platform`  | `enum`    | **Yes**  | —       | `"ANDROID""IOS"`             | Mobile operating system platform           |

#### Example Request Body

```json
{
  "fcm_token": "fcm_eX9aK1L2mN3oP4qR5sT6uV7wX8yZ9aB0c1d2e3f4g5h6",
  "platform": "ANDROID"
}

```

***

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

| Top-Level Key  | Data Type | Description                                                            |
| -------------- | --------- | ---------------------------------------------------------------------- |
| `message`      | `string`  | Confirmation message (`"Driver device token registered successfully"`) |
| `device_token` | `object`  | Registered/updated device token record in database                     |

#### `device_token` Object Fields

| Field        | Data Type | Nullable | Allowed Values / Constraints | Description                          |
| ------------ | --------- | -------- | ---------------------------- | ------------------------------------ |
| `id`         | `string`  | No       | Prefixed with `ddtok_`       | Unique device token record ID        |
| `driverId`   | `string`  | No       | Prefixed with `drv_`         | ID of the driver who owns this token |
| `fcm_token`  | `string`  | No       | String                       | Registered FCM push token            |
| `platform`   | `enum`    | No       | `"ANDROID"`, `"IOS"`         | Device platform                      |
| `is_active`  | `boolean` | No       | `true`, `false`              | Whether token is currently active    |
| `created_at` | `string`  | No       | ISO 8601 Timestamp           | Registration timestamp               |
| `updated_at` | `string`  | No       | ISO 8601 Timestamp           | Last update timestamp                |

***

### Response Examples

#### 1. `200 OK` — Success (Registered / Updated)

```json
{
  "message": "Driver device token registered successfully",
  "device_token": {
    "id": "ddtok_1a2b3c4d5e",
    "driverId": "drv_8a7b6c5d4e",
    "fcm_token": "fcm_eX9aK1L2mN3oP4qR5sT6uV7wX8yZ9aB0c1d2e3f4g5h6",
    "platform": "ANDROID",
    "is_active": true,
    "created_at": "2026-09-21T05:25:00.000Z",
    "updated_at": "2026-09-21T05:25:00.000Z"
  }
}

```

#### 2. `400 Bad Request` — Validation Error (Invalid Platform or Missing FCM Token)

```json
{
  "success": false,
  "message": "Validation failed: platform: Invalid enum value. Expected 'ANDROID' | 'IOS', received 'WEB'",
  "errors": [
    {
      "field": "platform",
      "message": "Invalid enum value. Expected 'ANDROID' | 'IOS', received 'WEB'"
    }
  ]
}

```

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

```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. `500 Internal Server Error`

```json
{
  "error": "Failed to register driver device token"
}

```

***

### Status Codes Reference

| HTTP Status Code                | Condition                                                        |
| ------------------------------- | ---------------------------------------------------------------- |
| **`200 OK`**                    | Device token successfully inserted or refreshed in database.     |
| **`400 Bad Request`**           | Missing `fcm_token` or `platform` is not `"ANDROID"` or `"IOS"`. |
| **`401 Unauthorized`**          | Missing, invalid, expired token or session revoked.              |
| **`403 Forbidden`**             | Driver account is deactivated or blocked.                        |
| **`500 Internal Server Error`** | Server or database error during token upsert.                    |

Reference: https://docs.driver.olycab.in/oly-driver/singin/driver-device-token

## 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/"

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

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

print(response.json())
```

```javascript
const url = 'https://driver/';
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/"

	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/")

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/")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

var client = new RestClient("https://driver/");
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/")! 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()
```