Metanow Docs
API & IntegrationReference

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.

MethodPathPermissionTool
GET/vehiclesfleet:readlist_vehicles
GET/vehicles/:idfleet:readget_vehicle
POST/vehiclesfleet:create:allcreate_vehicle
PATCH/vehicles/:idfleet:update:allupdate_vehicle
DELETE/vehicles/:idfleet:delete:allarchive_vehicle
GET/driversfleet:read:alllist_drivers
POST/vehicles/:id/assignmentsfleet:update:allassign_driver
GET/vehicles/:id/meter-entriesfleet:readlist_meter_readings
POST/vehicles/:id/meter-entriesfleet:createrecord_meter_reading
GET/vehicles/:id/fuel-entriesfleet:readlist_fuel_entries
POST/vehicles/:id/fuel-entriesfleet:createlog_fuel_entry
POST/fuel-entries/importfleet:create:allimport_fuel_entries
POST/fuel-entries/:id/postfleet:update:allpost_fuel_entry
GET/contractsfleet:read:alllist_vehicle_contracts
POST/vehicles/:id/contractsfleet:create:allcreate_vehicle_contract
PATCH/contracts/:idfleet:update:allupdate_vehicle_contract
POST/contracts/:id/renewfleet:update:allrenew_vehicle_contract
POST/contracts/:id/cancelfleet:delete:allcancel_vehicle_contract
GET/issuesfleet:readlist_vehicle_issues
POST/vehicles/:id/issuesfleet:createopen_vehicle_issue
PATCH/issues/:idfleet:updateupdate_vehicle_issue
POST/issues/:id/resolvefleet:updateresolve_vehicle_issue
GET/vehicles/:id/service-logsfleet:readlist_vehicle_service_logs
POST/vehicles/:id/service-logsfleet:create:alllog_vehicle_service
DELETE/service-logs/:idfleet:delete:allvoid_vehicle_service_log
GET/compliancefleet:read:alllist_fleet_compliance
POST/alerts/runfleet:update:allrun_fleet_expiry_alerts
GET/cost-reportfleet:read:allfleet_cost_report
POST/repairs/legacy-datesfleet:update:allrepair_fleet_legacy_dates
POST/repairs/member-grantsplatform:manage_role_templates:allrepair_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 (every service_interval_days, default 365; every service_interval_km, default 15 000), then clears them.
  • repair_fleet_member_grants — moves the global Member role's fleet grants to assigned. Needed once per environment: role grants are not re-seeded from permissions.yaml on boot.

On this page