Asset types
Set an asset-type legacy template
/a/AssetType_setTemplate
Replace an asset type’s legacy custom-field template stored inside its metadata.
When to use this endpoint
Use AssetType_setTemplate only for the CRM1 Asset Type custom-details editor and other consumers of the legacy meta.template format.
CRM2 custom layouts are separate layout_groups/layouts records and are managed through AssetType_getCustomLayout plus the Layout APIs.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Existing asset-type ID. |
val | JSON string | Yes | Complete legacy template, normally an array of tab objects with name and draggable. The server JSON-decodes it; invalid JSON becomes null and is still stored successfully. |
Example request
$result = FM_api('AssetType_setTemplate', [
'id' => '47',
'val' => json_encode([
['name' => 'Main', 'draggable' => []],
]),
]);
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":"no ID provided"} | id is absent. |
{"error":"no val provided"} | val is absent. |
{"error":"asset_type does not exist"} | The target ID is not found. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Other top-level metadata properties are preserved when the existing metadata decodes as an object.
- The endpoint does not merge the account-wide shared template; saving can therefore retain, remove, or alter shared entries according to the supplied JSON.
Side effects
- Rewrites the complete
metaJSON, refresheslast_edited, and invalidates the asset-type cache. No audit entry is written.
See it in Fieldmotion
CRM1
Open an Asset Type, choose Custom Details, edit the legacy tabs/fields, click Save, and inspect AssetType_setTemplate.
CRM2
No direct production CRM2 caller was found; CRM2 saves layout records instead of meta.template.
Related endpoints
AssetTypes_listCustomFieldsenumerates fields from these legacy templates.AssetTypes_mergeSharedCustomTemplatereplaces shared entries across every legacy template.