Assets
Set an asset vehicle registration
/a/Asset_setVehicleReg
Replace the vehicle-registration value nested at <code>meta.main.vehicle_reg</code> on one asset.
When to use this endpoint
Use Asset_setVehicleReg for the dedicated registration field in the CRM1 asset editor.
The value is stored verbatim; normalization, country format, and uniqueness are the caller’s responsibility.
Authentication and permissions
The handler requires an authenticated tenant context, established by signed API-key fields or a CRM session. It checks the tenant table prefix but does not separately require a logged-in user ID.
No page, role, or asset permission is checked.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive server-side asset ID. The handler does not verify that the row exists. |
val | Mixed | No | Replacement registration value. The handler reads the key without checking presence, so omission becomes null with a runtime notice. Normal callers send a string. |
Example request
$result = FM_api('Asset_setVehicleReg', [
'id' => '4821',
'val' => '241-D-12345',
]);
Example response
{
"ok": 1,
"meta": {
"custom": [],
"main": {
"vehicle_reg": "241-D-12345"
}
}
}
The response returns the complete decoded metadata value after assignment. Existing keys are preserved when the stored JSON decodes to an array.
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. |
{"error":"missing or invalid parameter: id"} | id is absent or does not convert to a positive integer. |
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, invalid, or JSON
nullmetadata is replaced with{"main":[],"custom":[]}before assignment. - Valid scalar JSON is not normalized and can cause a PHP runtime error when the handler indexes
main. - There is no no-change shortcut, formatting rule, uniqueness check, or deleted-state filter.
- This is a single-record mutation; it provides no list filtering or pagination.
Side effects
- Attempts to replace the complete encoded
metacolumn, updateslast_edited, setsedited_uuidtoAsset_setVehicleReg, invalidates the asset cache, and writes an asset audit entry.
See it in Fieldmotion
CRM1
Open an asset edit page or the editor in a customer’s Assets tab, change Vehicle Registration, and filter Network requests for Asset_setVehicleReg.
CRM2
No direct production CRM2 call to Asset_setVehicleReg was found; CRM2 uses its broader update contract.
Related endpoints
Asset_getreturns encodedmeta; callers must decode it to read the registration.Asset_setUrlupdates anothermeta.mainvalue.