Fleet API
Vehicles, drivers, meter readings, fuel, contracts, issues, outside services, expiry reminders and the admin repairs.
Base path: /fleet, behind @RequiresModule("fleet"). Every query is scoped to
the caller's organisation and tenant. Every route is a Concierge tool, and
every mutation accepts external_key: a retry with the same key returns the
first result instead of writing twice.
Two scopes: fleet manager and driver
fleet:<action>:all manages the fleet. fleet:<action>:assigned is the
driver: only the vehicles currently assigned to the caller's own driver
row (login → employee → driver → open assignment). A driver reads those
vehicles and their history, records readings, logs fuel, reports / starts /
resolves issues and runs checks. Any other vehicle answers 404, not 403.
Members get assigned by default; Admin and Manager get all.
Routes marked :all below are the fleet manager's. Two-segment routes
(fleet:read, fleet:create, fleet:update) are open to both, narrowed to
the driver's vehicles.
| Method | Path | Permission | Tool |
|---|---|---|---|
| GET | /vehicles | fleet:read | list_vehicles |
| GET | /vehicles/:id | fleet:read | get_vehicle |
| POST | /vehicles | fleet:create:all | create_vehicle |
| PATCH | /vehicles/:id | fleet:update:all | update_vehicle |
| DELETE | /vehicles/:id | fleet:delete:all | archive_vehicle |
| GET | /drivers | fleet:read:all | list_drivers |
| POST | /vehicles/:id/assignments | fleet:update:all | assign_driver |
| GET | /vehicles/:id/meter-entries | fleet:read | list_meter_readings |
| POST | /vehicles/:id/meter-entries | fleet:create | record_meter_reading |
| GET | /vehicles/:id/fuel-entries | fleet:read | list_fuel_entries |
| POST | /vehicles/:id/fuel-entries | fleet:create | log_fuel_entry |
| POST | /fuel-entries/import | fleet:create:all | import_fuel_entries |
| POST | /fuel-entries/:id/post | fleet:update:all | post_fuel_entry |
| GET | /contracts | fleet:read:all | list_vehicle_contracts |
| POST | /vehicles/:id/contracts | fleet:create:all | create_vehicle_contract |
| PATCH | /contracts/:id | fleet:update:all | update_vehicle_contract |
| POST | /contracts/:id/renew | fleet:update:all | renew_vehicle_contract |
| POST | /contracts/:id/cancel | fleet:delete:all | cancel_vehicle_contract |
| GET | /issues | fleet:read | list_vehicle_issues |
| POST | /vehicles/:id/issues | fleet:create | open_vehicle_issue |
| PATCH | /issues/:id | fleet:update | update_vehicle_issue |
| POST | /issues/:id/resolve | fleet:update | resolve_vehicle_issue |
| GET | /vehicles/:id/service-logs | fleet:read | list_vehicle_service_logs |
| POST | /vehicles/:id/service-logs | fleet:create:all | log_vehicle_service |
| DELETE | /service-logs/:id | fleet:delete:all | void_vehicle_service_log |
| GET | /compliance | fleet:read:all | list_fleet_compliance |
| POST | /alerts/run | fleet:update:all | run_fleet_expiry_alerts |
| GET | /cost-report | fleet:read:all | fleet_cost_report |
| POST | /repairs/legacy-dates | fleet:update:all | repair_fleet_legacy_dates |
| POST | /repairs/member-grants | platform:manage_role_templates:all | repair_fleet_member_grants |
Models, checks, the overview and the fuel log follow the same pattern (see
project-source-of-truth/modules/fleet.md for every route).
Money on the wire
Every amount is integer minor units with its currency beside it
(total_cost_cents + currency, cost_cents, vat_cents,
purchase_price_cents + value_currency). Amounts in different currencies
are never added together. A fuel entry's vat_cents is the VAT inside its
total, as printed on the receipt; it must not exceed the total.
Dates with one owner
insurance_expires_on and next_service_on / next_service_odometer on a
vehicle are read-only and derived: insurance from the vehicle's active
insurance contracts, the next service from Maintenance's preventive plans.
insurance_source / service_source say where the value came from
(contract, plan, or vehicle for an old value not yet moved — see
repair_fleet_legacy_dates). create_vehicle / update_vehicle no longer
accept them.
Contract lifecycle
status is active, expired, renewed or cancelled. expired is
derived on read (active, end date passed) — no job flips it. renew creates
the continuing contract (the day after the old end, same length, same vendor,
cost and responsible, unless given) and stores the old one renewed. A
second renew returns the first renewal.
Expiry reminders
A daily job, and run_fleet_expiry_alerts on demand, reminds the
responsible person before each insurance, registration, inspection, service,
licence and contract date — once per date. Contracts go to their
responsible_user_id, else the vehicle's manager_user_id; a licence goes to
the driver. Delivery is in-app and by e-mail, in the recipient's language.
The lead time is the org setting org.fleet.expiry_alert_days (default 30).
Fuel-card import
POST /fuel-entries/import takes the CSV text (csv) with a header row:
plate, date, quantity, amount and optionally unit, vat,
currency, odometer, vendor, reference. Comma or semicolon; decimals
with . or ,. Each row becomes a fuel entry keyed
<external_key>:<reference or line>, so importing the same statement twice
changes nothing. Lines that fail come back in failed with their line number.
Admin repairs
Both repairs default to dry_run: true and only report; send
dry_run: false to apply. Both are idempotent.
repair_fleet_legacy_dates— moves legacy vehicle dates into a yearly insurance contract / a maintenance plan (everyservice_interval_days, default 365; everyservice_interval_km, default 15 000), then clears them.repair_fleet_member_grants— moves the global Member role's fleet grants toassigned. Needed once per environment: role grants are not re-seeded frompermissions.yamlon boot.