Delete Vehicle by ID

View as Markdown
# Delete Vehicle by ID Permanently removes a registered vehicle record from the database by its unique ID. --- ### Endpoint Overview - **Method:** `DELETE` - **Route:** `/api/v1/vehicles/:id` - **Authentication:** `None (Public)` - **Content-Type:** `N/A` --- ### Path Parameters | Parameter | Data Type | Required | Description | | --- | --- | --- | --- | | `id` | `string` | **Yes** | Unique vehicle ID to delete (prefixed with `veh_`, e.g. `veh_1a2b3c4d5e`) | #### Example Request URL ``` http DELETE {{baseUrl}}/api/v1/vehicles/veh_1a2b3c4d5e ``` --- ### Request Body Schema _None (DELETE request)_ --- ### Response Body Schema (`200 OK`) | Top-Level Key | Data Type | Description | | --- | --- | --- | | `message` | `string` | Confirmation message (`"Vehicle deleted successfully"`) | | `vehicle` | `object` | The deleted vehicle record | #### `vehicle` Object Fields | Field | Data Type | Nullable | Allowed Values / Constraints | Description | | --- | --- | --- | --- | --- | | `id` | `string` | No | Prefixed with `veh_` | Unique vehicle ID | | `driverId` | `string` | Yes | Prefixed with `drv_` | ID of previously linked driver | | `name` | `string` | No | String | Vehicle make / brand | | `model` | `string` | No | String | Vehicle model | | `color` | `string` | Yes | String | Vehicle color | | `number_plate` | `string` | Yes | String | License registration plate number | | `created_at` | `string` | No | ISO 8601 Timestamp | Creation timestamp | | `updated_at` | `string` | No | ISO 8601 Timestamp | Last update timestamp | --- ### Response Examples #### 1\. `200 OK` — Vehicle Deleted Successfully ``` json { "message": "Vehicle deleted successfully", "vehicle": { "id": "veh_1a2b3c4d5e", "driverId": "drv_8a7b6c5d4e", "name": "Maruti Suzuki", "model": "Swift Dzire", "color": "White", "number_plate": "KA-01-AB-1234", "created_at": "2026-09-21T05:40:00.000Z", "updated_at": "2026-09-21T05:40:00.000Z" } } ``` #### 2\. `404 Not Found` — Vehicle Does Not Exist ``` json { "error": "Vehicle not found" } ``` #### 3\. `500 Internal Server Error` ``` json { "error": "Failed to delete vehicle" } ``` --- ### Status Codes Reference | HTTP Status Code | Condition | | --- | --- | | **`200 OK`** | Vehicle record located, deleted, and returned. | | **`404 Not Found`** | No vehicle found with the given ID. | | **`500 Internal Server Error`** | Server or database deletion error. |

Authentication

AuthorizationBearer

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