Skip to navigation

duty-status

View as Markdown

Toggles the real-time availability and duty state of the driver (ONLINE, OFFLINE, or ON_TRIP).

⚠️ Business Rule: A driver can only go ONLINE if their account status is APPROVED. If the account status is PENDING_ONBOARDING, PENDING_APPROVAL, REJECTED, or SUSPENDED, the backend rejects the request with HTTP 403 APPROVAL_REQUIRED.


Endpoint Overview

  • Method: PATCH

  • Route: /api/v1/driver/duty-status

  • 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
duty_statusenumYes—"ONLINE""OFFLINE""ON_TRIP"Target duty status

Example Request Body (Going Online)

{
"duty_status": "ONLINE"
}

Example Request Body (Going Offline)

{
"duty_status": "OFFLINE"
}

Response Body Schema (200 OK)

Top-Level KeyData TypeDescription
messagestringStatus confirmation (e.g. "Duty status updated to ONLINE")
duty_statusenumUpdated duty status ("ONLINE", "OFFLINE", "ON_TRIP")
driverobjectComplete updated driver profile

driver Object Fields

FieldData TypeNullableAllowed Values / ConstraintsDescription
idstringNoPrefixed with drv_Unique driver ID
namestringYesStringDriver full name
phonestringNoE.164 stringRegistered phone number
is_phone_verifiedbooleanNotrue, falsePhone verification status
emailstringYesValid emailRegistered email
is_email_verifiedbooleanNotrue, falseEmail verification status
genderenumYes"MALE", "FEMALE", nullDriver gender
date_of_birthstringYesISO 8601 TimestampDriver date of birth
profile_image_urlstringYesValid URLAvatar image URL
is_profile_completebooleanNotrue, falseProfile completion status
statusenumNo"APPROVED" (or current status)Onboarding & approval state
duty_statusenumNo"ONLINE", "OFFLINE", "ON_TRIP"Updated real-time duty state
rejection_reasonstringYesStringRejection reason if status is REJECTED
ratingstringNoDecimal string (e.g. "4.85")Driver rating
total_tripsintegerNo>= 0Completed trips count
wallet_balancestringNoDecimal string (e.g. "3250.00")Current wallet balance
service_categoryenumNo"BIKE", "CAB", "AMBULANCE", "LOGISTICS"Operational category
citystringNoStringOperating city
statestringYesStringOperating state
languagestringNoStringPreferred interface language
own_referral_codestringYesPrefixed with CAP_Unique referral code
referred_by_codestringYesStringInviter referral code
vehicle_namestringYesStringVehicle make/brand
vehicle_modelstringYesStringVehicle model
vehicle_colorstringYesStringVehicle color
number_platestringYesStringRegistration plate number
vehicleobjectYesSub-object or nullVehicle details
vehicle.idstringNoPrefixed with veh_Vehicle ID
vehicle.namestringNoStringVehicle name
vehicle.modelstringNoStringVehicle model
vehicle.colorstringNoStringVehicle color
vehicle.number_platestringNoStringPlate number
is_activebooleanNotrue, falseSystem active status
is_blockedbooleanNotrue, falseAccount blocked flag
last_login_atstringYesISO 8601 TimestampTimestamp of last login
created_atstringNoISO 8601 TimestampAccount registration timestamp
updated_atstringNoISO 8601 TimestampTimestamp of this update

Response Examples

1. 200 OK — Duty Status Updated (Online)

{
"message": "Duty status updated to ONLINE",
"duty_status": "ONLINE",
"driver": {
"id": "drv_8a7b6c5d4e",
"name": "Ravi Kumar",
"phone": "+919876543210",
"is_phone_verified": true,
"email": "ravi.kumar@example.com",
"is_email_verified": true,
"gender": "MALE",
"date_of_birth": "1992-05-15T00:00:00.000Z",
"profile_image_url": "https://example.com/profiles/ravi.jpg",
"is_profile_complete": true,
"status": "APPROVED",
"duty_status": "ONLINE",
"rejection_reason": null,
"rating": "4.85",
"total_trips": 142,
"wallet_balance": "3250.00",
"service_category": "CAB",
"city": "Bengaluru",
"state": "Karnataka",
"language": "en",
"own_referral_code": "CAP_8X9K2",
"referred_by_code": null,
"vehicle_name": "Maruti Suzuki",
"vehicle_model": "Swift Dzire",
"vehicle_color": "White",
"number_plate": "KA-01-AB-1234",
"vehicle": {
"id": "veh_1a2b3c4d5e",
"name": "Maruti Suzuki",
"model": "Swift Dzire",
"color": "White",
"number_plate": "KA-01-AB-1234"
},
"is_active": true,
"is_blocked": false,
"last_login_at": "2026-09-21T04:45:00.000Z",
"created_at": "2026-08-10T12:00:00.000Z",
"updated_at": "2026-09-21T05:15:00.000Z"
}
}

2. 403 Forbidden — Approval Required to Go Online

Returned when an unapproved driver (e.g. PENDING_ONBOARDING or PENDING_APPROVAL) attempts to set duty_status: "ONLINE":

{
"error": "APPROVAL_REQUIRED",
"message": "Driver status is currently 'PENDING_ONBOARDING'. Your profile and documents must be APPROVED by admin before going online."
}

3. 400 Bad Request — Validation Error (Invalid Duty Status)

{
"success": false,
"message": "Validation failed: duty_status: Invalid enum value. Expected 'OFFLINE' | 'ONLINE' | 'ON_TRIP', received 'BUSY'",
"errors": [
{
"field": "duty_status",
"message": "Invalid enum value. Expected 'OFFLINE' | 'ONLINE' | 'ON_TRIP', received 'BUSY'"
}
]
}

4. 401 Unauthorized — Missing / Expired Token / Session Revoked

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

5. 404 Not Found — Driver Not Found

{
"error": "Driver not found"
}

6. 500 Internal Server Error

{
"error": "Failed to update duty status"
}

Status Codes Reference

HTTP Status CodeCondition
200 OKDuty status updated successfully and returned with updated driver profile.
400 Bad RequestMissing duty_status or value not in ["OFFLINE", "ONLINE", "ON_TRIP"].
401 UnauthorizedMissing, invalid, expired token or session revoked.
403 ForbiddenDriver is not APPROVED while attempting to go ONLINE, or account is blocked.
404 Not FoundDriver ID in token does not match any record.
500 Internal Server ErrorServer or database update error.

Authentication

AuthorizationBearer

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