When to use this endpoint

Use AssetType_delete from Asset Type administration after every active, archived, or otherwise non-deleted asset has been moved away from the type.

Asset types do not have a restore route. This endpoint hard-deletes the definition after its usage check.

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

ParameterTypeRequiredDescription
idInteger stringYesAsset-type ID. Integer conversion is applied; zero or an unknown value produces the not-found response.

Example request

$result = FM_api('AssetType_delete', [
	'id' => '58',
]);

Example response

{
  "ok": 1
}

When the type is in use, CRM2 sessions receive {"assetName":"Mobile Compressor","idCount":3} rather than an error. Other callers receive the error documented below.

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":"no ID provided"}The id key is absent.
{"error":"asset_type does not exist"}No tenant asset type has the integer-converted ID.
{"error":"Cannot delete that Asset Type as it is used by (3) Assets"}At least one non-deleted asset uses the type outside a CRM2 session. Archived assets still count; soft-deleted assets do not.

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

Behaviour and edge cases

  • The usage check counts assets.deleted=0; it does not exclude archived or inactive assets.
  • All layout groups whose JSON metadata names this asset-type ID are selected. Their layout rows and then the groups are permanently deleted.
  • Files attached with asset-type file enum 1 are not removed, so file records can remain after the type is deleted.

Side effects

  • Hard-deletes the asset-type row and its type-specific CRM2 layouts, invalidates layout caches, and records an asset_types deletion for polling.

See it in Fieldmotion

CRM1

Open Assets → Setup Asset Types, click the delete link on an unused type, confirm, and inspect AssetType_delete. CRM1 displays the returned error when assets still use the type.

CRM2

Open Asset Types and delete a row. CRM2 uses the non-error assetName/idCount response to report types it could not remove.

Related endpoints