Create Vehicle
Register a new vehicle in Niyantha TMS.
Base Information
Base URL
https://api.niyantha.in/
Authentication
Bearer Token
Use the token returned by account login
Request
HTTP Request
POST /api/v1/session/vehicles
Host: api.niyantha.in
Authorization: Bearer <token>
Content-Type: application/json
{
"type": "scooter",
"make": "tvs",
"model_name": "speedo",
"year": 2023,
"registration_file_id": 22,
"registration_number": "KA20MD8198",
"current_location_latitude": 13.3409,
"current_location_longitude": 74.7421,
"transport_state_permissions": ["karnataka"],
"all_india_permit": false,
"is_commercial": true,
"status": "active"
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Vehicle type (car, truck, scooter, etc.) |
| make | string | Yes | Manufacturer of the vehicle |
| model_name | string | Yes | Model of the vehicle |
| year | integer | Yes | Manufacturing year |
| registration_file_id | integer | Yes | ID of the uploaded registration document file |
| registration_number | string | Yes | Vehicle registration number |
| current_location_latitude | float | Yes | Current latitude of the vehicle |
| current_location_longitude | float | Yes | Current longitude of the vehicle |
| transport_state_permissions | array | No | List of states where vehicle has transport permits |
| all_india_permit | boolean | No | Whether the vehicle has all-India permit |
| is_commercial | boolean | No | Whether the vehicle is used commercially |
| status | string | No | Initial status of the vehicle (active, inactive, maintenance) |
Response
Success Response (200 OK)
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 31,
"type": "scooter",
"make": "tvs",
"model": "speedo",
"year": 2023,
"registration_file_id": 22,
"registration_number": "KA20MD8198",
"current_location_latitude": 13.3409,
"current_location_longitude": 74.7421,
"current_location_measured_at": 1746260005,
"transport_state_permissions": ["karnataka"],
"all_india_permit": false,
"is_commercial": true,
"is_verified": false,
"status": "active",
"network_id": null
}Response Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier for the vehicle |
| current_location_measured_at | integer | Unix timestamp of when location was measured |
| is_verified | boolean | Verification status of the vehicle documents |
| network_id | integer | null | ID of the network this vehicle belongs to (if any) |
Error Responses
400 Bad Request
{
"error": "validation_error",
"message": "Validation failed",
"details": {
"registration_number": ["Invalid registration number format"]
}
}401 Unauthorized
{
"error": "unauthorized",
"message": "Invalid or missing authentication credentials"
}404 Not Found
{
"error": "not_found",
"message": "Registration file with ID 22 not found"
}Code Sample
fetch('https://api.niyantha.in/api/v1/session/vehicles', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: "scooter",
make: "tvs",
model_name: "speedo",
year: 2023,
registration_file_id: 22,
registration_number: "KA20MD8198",
current_location_latitude: 13.3409,
current_location_longitude: 74.7421,
transport_state_permissions: ["karnataka"],
all_india_permit: false,
is_commercial: true,
status: "active"
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));