When to use this endpoint

Use Vehicles_getById after another call has supplied a batch of numeric vehicle IDs. It returns raw snake_case fields; use Vehicle_getRequestedDetails for mapped names and custom-value extraction.

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
idsJSON array or native arrayYesNumeric vehicle IDs. Values are integer-converted; duplicates are retained in the SQL list but do not duplicate result rows.
fieldsJSON array or native arrayNoAllowed raw fields: id, reg, uuid, description, cost_per_distance, location, last_edited, edited_uuid, price_per_distance, meta, and cdate. Omission returns all of them.

Example request

$vehicles = FM_api('Vehicles_getById', [
	'ids' => json_encode(['30124', '30125']),
	'fields' => json_encode(['id', 'reg', 'description', 'cost_per_distance']),
]);

Example response

[{"id":"30124","reg":"241-D-12001","description":"Service van","cost_per_distance":"0.4200"},{"id":"30125","reg":"241-D-12002","description":"Support van","cost_per_distance":"0.3900"}]

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.
{"error":"missing or invalid parameter: ids"}ids is absent.
{"error":"no fields selected"}fields is present but contains no allowed names.
false or a database-query errorA malformed or empty decoded ID value produces a legacy invalid IN query instead of a structured parameter error.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Missing IDs are omitted; the response does not contain null placeholders and is not guaranteed to preserve requested order.
  • There is no pagination or explicit SQL ordering.
  • meta remains encoded JSON and Unix cdate remains a raw database value.

See it in Fieldmotion

CRM1

No direct CRM1 production caller was found.

CRM2

No direct CRM2 production caller was found. The endpoint is covered by API tests as a batch integration route.

Related endpoints