When to use this endpoint

Use Vehicle_setCostPerDistance only for the legacy single-field workflow. New mapped clients should use Vehicle_updateData.

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

ParameterTypeRequiredDescription
idInteger-compatible or 32-character stringEffectively yesNumeric vehicle ID or UUID selected by exact length. Missing, blank, and invalid values can target ID 0 and still return success.
valNumeric-compatibleNo validationConverted with floatval(). Missing or nonnumeric input becomes 0; negative values are accepted.

Example request

$result = FM_api('Vehicle_setCostPerDistance', [
	'id' => '30124',
	'val' => '0.42',
]);

Example response

{"ok":1}

Errors and unusual responses

ResponseCondition
{"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

  • Unknown IDs and unchanged values still return success; the query result is not checked.
  • The endpoint performs no currency, distance-unit, precision, or minimum validation beyond PHP numeric conversion.

Side effects

  • Updates cost_per_distance, sets last_edited to the current server datetime and edited_uuid to Vehicle_setCostPerDistance, and invalidates the vehicle cache.
  • It does not write Core field history.

See it in Fieldmotion

CRM1

Open Settings → Vehicles in CRM1 and filter browser developer tools for the exact function name. Edit the Cost per Mile/KM table cell.

CRM2

CRM2 uses Vehicle_updateData from mapped forms; no direct CRM2 caller was found.

Related endpoints