Assets
Set an asset type
/a/Asset_setType
Replace an asset’s type ID without validating the type or migrating type-specific metadata.
When to use this endpoint
Use Asset_setType only for the CRM1 inline type selector, where the chosen ID has already come from the tenant’s asset-type list.
For integrations, prefer a broader update workflow that validates the type and handles custom-field compatibility.
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-type permission is checked.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive server-side asset ID. The handler does not verify that a row exists. |
val | Integer string | No | New asset-type ID after integer conversion. The handler reads it without a presence check, so omission, blank, and nonnumeric input become 0. The type is not validated. |
Example request
$result = FM_api('Asset_setType', [
'id' => '4821',
'val' => '52',
]);
Example response
{
"ok": 1
}
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
- There is no no-change shortcut and no active, archived, or deleted filter on the update.
- Changing type does not normalize custom-field keys, clear incompatible values, or apply a new layout template.
- This is a single-record mutation; it provides no list filtering or pagination.
Side effects
- The update attempts to set
type_idandlast_edited, setsedited_uuidtoAsset_setType, invalidates the asset cache, and writes an asset audit entry even if no asset matched.
See it in Fieldmotion
CRM1
Open Assets, edit the Type cell, and filter Network requests for Asset_setType. CRM1 chooses from AssetTypes_list and can create a type before submitting its returned ID.
CRM2
No direct production CRM2 call to Asset_setType was found; CRM2 uses its broader update contract.