Driver Logout (Single Device)

View as Markdown
# Driver Logout (Single Device) Logs out the driver from the current device by revoking the specified refresh token in the database and incrementing the driver's session version, immediately invalidating any associated access tokens. --- ### Endpoint Overview - **Method:** `POST` - **Route:** `/api/v1/driver/auth/logout` - **Authentication:** `None (Refresh Token in Body)` - **Content-Type:** `application/json` --- ### Request Headers | Header | Type | Required | Description | | --- | --- | --- | --- | | `Content-Type` | `string` | **Yes** | Must be `application/json` | --- ### Request Body Schema | Field | Data Type | Required | Default | Allowed Values / Constraints | Description | | --- | --- | --- | --- | --- | --- | | `refreshToken` | `string` | **Yes** | — | Min length 1 (prefixed with `drtok_`) | Active refresh token of the current session | #### Example Request Body ``` json { "refreshToken": "drtok_7f8e9d0c1b2a345678901234567890ab" } ``` --- ### Response Body Schema (`200 OK`) | Top-Level Key | Data Type | Description | | --- | --- | --- | | `message` | `string` | Logout confirmation (`"Driver logged out successfully"`) | --- ### Response Examples #### 1\. `200 OK` — Success ``` json { "message": "Driver logged out successfully" } ``` #### 2\. `400 Bad Request` — Validation Error (Missing `refreshToken`) ``` json { "success": false, "message": "Validation failed: refreshToken: Refresh token is required", "errors": [ { "field": "refreshToken", "message": "Refresh token is required" } ] } ``` #### 3\. `500 Internal Server Error` ``` json { "error": "Failed to log out" } ``` --- ### Status Codes Reference | HTTP Status Code | Condition | | --- | --- | | **`200 OK`** | Refresh token successfully revoked and session terminated. | | **`400 Bad Request`** | Missing or empty `refreshToken` in request body. | | **`500 Internal Server Error`** | Server or database error while updating token records. |

Authentication

AuthorizationBearer

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