Vehicles
Account-wrapped fleet vehicles and nested rental vehicle assignments.
Vehicles API
Vehicles are fleet accounts — rows on the universal accounts table with account_type = vehicle. They carry plate, payload, volume, and dimension fields alongside every account capability (custom fields, files, activities, and warehouse scoping), and are served through the same AccountData serialiser.
Because vehicles are accounts, API responses are account-wrapped: a single vehicle is returned under the account key and collections under the accounts key. Vehicles are excluded from the default /api/v1/accounts index by a bleed guard; query them either through the dedicated endpoints below or by widening the accounts index with ?q[account_type_eq]=vehicle.
Endpoints
| Method | URL | Description |
|---|---|---|
| GET | /api/v1/vehicles |
List vehicles |
| POST | /api/v1/vehicles |
Create a vehicle |
| GET | /api/v1/vehicles/{vehicle} |
Show a vehicle |
| PUT/PATCH | /api/v1/vehicles/{vehicle} |
Update a vehicle |
| DELETE | /api/v1/vehicles/{vehicle} |
Delete (soft-delete) a vehicle |
| GET | /api/v1/vehicles/{vehicle}/assignments |
List a vehicle's rental assignments |
Rental vehicle assignments
Vehicles are assigned to rentals as plain relational side-records with an advisory window and a list-entry role. Assignments are nested under the rental.
| Method | URL | Description |
|---|---|---|
| GET | /api/v1/rentals/{rental}/vehicles |
List vehicle assignments on a rental |
| POST | /api/v1/rentals/{rental}/vehicles |
Assign a vehicle to the rental |
| PATCH | /api/v1/rentals/{rental}/vehicles/{rentalVehicle} |
Update role, window, or notes |
| DELETE | /api/v1/rentals/{rental}/vehicles/{rentalVehicle} |
Unassign the vehicle |
Authentication
Requires a Sanctum bearer token with vehicles:read (GET) or vehicles:write (POST/PUT/PATCH/DELETE). Read routes check vehicles.view; assignment writes check vehicles.assign; vehicle CRUD checks vehicles.create, vehicles.edit, and vehicles.delete as applicable. Warehouse-restricted users see only vehicles whose member_stores intersect their accessible warehouses; vehicles with no warehouse rows remain globally visible.
List vehicles
GET /api/v1/vehicles
Returns vehicles under the accounts key with pagination meta. Standard account Ransack filters apply (q[name_cont], q[cf.field_name_eq], and so on), plus vehicle spec fields. live filters apply with ?filter_id=.
Create / update
Create and update accept vehicle-specific fields (plate, payload, volume, dimensions, vehicle type) via CreateVehicleData / UpdateVehicleData. A generic account create cannot set account_type = vehicle — use these endpoints instead. Create returns 201.
Delete
Soft-deletes the vehicle. Rejected with 422 when the vehicle still has rental assignments.
Assign a vehicle
POST /api/v1/rentals/{rental}/vehicles
| Field | Type | Required | Description |
|---|---|---|---|
vehicle_id |
int | Yes | Account ID of a vehicle-type account |
role_id |
int | No | list entry from the Vehicle Assignment Role list |
starts_at |
datetime | No | Advisory start of the assignment window |
ends_at |
datetime | No | Advisory end of the assignment window |
notes |
string | No | Free-text note |
Assigning the same vehicle twice is allowed and returns duplicate_warning: true rather than an error. A non-vehicle account is rejected with 422 on vehicle_id. Cross-warehouse access to the rental is enforced (404 on mismatch for restricted users).
Response shape
Vehicles serialise through AccountData; monetary and decimal fields follow the account format. Collection key: accounts; singular: account. Vehicle assignments serialise through VehicleAssignmentData.
Webhooks
Vehicle lifecycle uses the canonical account.created, account.updated, and account.deleted events (no separate vehicle.* events). Assignments fire vehicle.assigned, vehicle.assignment_updated, and vehicle.unassigned — see Webhooks.