When to use this endpoint

Use Asset_setActive when a caller needs to change the active field without archiving or deleting the asset.

The handler is a permissive legacy scalar setter; callers should send only 0 or 1.

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 stringYesPositive server-side asset ID. The existence check does not exclude soft-deleted assets.
valInteger stringYesConverted with intval and stored directly. Blank and nonnumeric values become 0; integers other than 0 and 1 are not rejected.

Example request

$result = FM_api('Asset_setActive', [
	'id' => '4821',
	'val' => '0',
]);

Example response

{
  "ok": 1
}

If the stored string value already equals the converted integer, the response is {"ok":1,"msg":"no changes needed"}.

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: id"}id is absent or does not convert to a positive integer.
{"error":"missing parameter: val"}val is omitted. A present blank value is accepted as zero.
{"error":"asset does not exist"}No asset row has the ID. Soft-deleted rows still count as existing.

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 no-change comparison happens after integer conversion and returns before timestamps or logs are changed.
  • The endpoint can edit inactive, archived, or soft-deleted rows.
  • This is a single-record mutation; it provides no list filtering or pagination.

Side effects

  • A real change updates active and last_edited, sets edited_uuid to Asset_setActive, invalidates the asset cache, and writes an asset audit entry.

See it in Fieldmotion

CRM1

No direct production CRM1 call to Asset_setActive was found. CRM1’s normal asset lifecycle controls use archive, restore, and delete actions.

CRM2

No direct production CRM2 call to Asset_setActive was found.

Related endpoints