Skip to navigation

driver-device-token

View as Markdown

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

HeaderTypeRequiredDescription
AuthorizationstringYesFormat: Bearer
Content-TypestringYesMust be application/json

Request Body Schema

FieldData TypeRequiredDefaultAllowed Values / ConstraintsDescription
fcm_tokenstringYes—Min length 1Firebase Cloud Messaging push token string
platformenumYes—"ANDROID""IOS"Mobile operating system platform

Example Request Body

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

Response Body Schema (200 OK)

Top-Level KeyData TypeDescription
messagestringConfirmation message ("Driver device token registered successfully")
device_tokenobjectRegistered/updated device token record in database

device_token Object Fields

FieldData TypeNullableAllowed Values / ConstraintsDescription
idstringNoPrefixed with ddtok_Unique device token record ID
driverIdstringNoPrefixed with drv_ID of the driver who owns this token
fcm_tokenstringNoStringRegistered FCM push token
platformenumNo"ANDROID", "IOS"Device platform
is_activebooleanNotrue, falseWhether token is currently active
created_atstringNoISO 8601 TimestampRegistration timestamp
updated_atstringNoISO 8601 TimestampLast update timestamp

Response Examples

1. 200 OK — Success (Registered / Updated)

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

{
"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

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

4. 403 Forbidden — Account Blocked / Deactivated

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

5. 500 Internal Server Error

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

Status Codes Reference

HTTP Status CodeCondition
200 OKDevice token successfully inserted or refreshed in database.
400 Bad RequestMissing fcm_token or platform is not "ANDROID" or "IOS".
401 UnauthorizedMissing, invalid, expired token or session revoked.
403 ForbiddenDriver account is deactivated or blocked.
500 Internal Server ErrorServer or database error during token upsert.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.