check-active-driver-session

View as Markdown
# Check Active Driver Session (Heartbeat) Verifies if the current driver's access token and session are active and valid. Specifically used as a heartbeat check to detect if the session was invalidated because the driver logged in on another device (Single-Device Login Enforcement). --- ### Endpoint Overview - **Method:** `GET` - **Route:** `/api/v1/driver/auth/session/check` - **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`) | Field | Data Type | Description | | --- | --- | --- | | `status` | `string` | Current session state (`"active"`) | | `driverId` | `string` | Unique driver ID (prefixed with `drv_`) | | `sessionVersion` | `integer` | Active session counter version in the database | --- ### Response Examples #### 1\. `200 OK` — Session Active ``` json { "status": "active", "driverId": "drv_8a7b6c5d4e", "sessionVersion": 2 } ``` #### 2\. `401 Unauthorized` — Session Revoked (Logged In on Another Device) Enforced via single-device policy. When this error is returned, the mobile app should immediately log out the driver and redirect to the login screen: ``` json { "error": "SESSION_REVOKED", "message": "Your session has been terminated because your driver account logged in on another device." } ``` #### 3\. `401 Unauthorized` — Token Expired or Invalid ``` json { "error": "Unauthorized", "message": "Invalid or expired driver access token." } ``` #### 4\. `401 Unauthorized` — Missing Token ``` json { "error": "Unauthorized", "message": "Driver access token is missing. Header format must be &#x27;Bearer <token>&#x27;." } ``` #### 5\. `403 Forbidden` — Account Blocked / Deactivated ``` json { "error": "Forbidden", "message": "Driver account is blocked or deactivated." } ``` --- ### Status Codes Reference | HTTP Status Code | Condition | | --- | --- | | **`200 OK`** | Session is valid, active, and belongs to the currently authenticated device. | | **`401 Unauthorized`** | Token is missing, expired, or was revoked because another device signed in (`SESSION_REVOKED`). | | **`403 Forbidden`** | Driver account has been blocked or deactivated. |

Authentication

AuthorizationBearer

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