Vehicles
List vehicle distance costs
/a/Vehicles_getCostPerDistance
List every vehicle UUID with its internal per-distance cost.
When to use this endpoint
Use Vehicles_getCostPerDistance when a legacy user or job assignment stores vehicle UUIDs and only the internal mileage cost is needed.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login but performs no additional Vehicles-page, create, edit, delete, or role-permission check.
All reads and writes use the authenticated tenant’s tables. CRM1 and CRM2 may hide controls through client-side permissions; these routes do not repeat those UI checks.
Parameters
This endpoint has no operation-specific parameters.
Example request
$costs = FM_api('Vehicles_getCostPerDistance');
Example response
[{"id":"4ec721a4aa8f4ec393b6c66fd31bf611","cost_per_distance":"0.4200"},{"id":"cb3c49b7c48340aca9703f4c1dbbe411","cost_per_distance":"0.3900"}]
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The response field named
idis the vehicle UUID, not its numeric database ID. - The list is unfiltered, unpaginated, and has no explicit ordering. Null UUIDs or costs are not excluded.
- Decimal costs are returned in the database’s fixed-scale string form.
See it in Fieldmotion
CRM1
No direct browser caller was found. CRM1’s job editor instead resolves one assignment with Vehicle_getByUserId and then Vehicle_get.
CRM2
No direct CRM2 caller was found.
Related endpoints
Vehicle_getByUserIdreturns a user’s raw vehicle assignment.Vehicle_setCostPerDistancechanges one stored cost.