When to use this endpoint

Use AssetType_setUrl from CRM1’s Asset Type edit page to control the default URL used when a non-Fieldmotion user follows a QR code for that type.

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 stringYesExisting asset-type ID.
valMixedYesValue assigned to meta.url. A blank string is accepted and clears the effective URL; null is rejected as absent. No URL-format validation is performed.

Example request

$result = FM_api('AssetType_setUrl', [
	'id' => '47',
	'val' => 'https://example.test/assets',
]);

Example response

{
  "ok": 1
}

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"}id is absent.
{"error":"no val provided"}val is absent or null.
{"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

  • Existing metadata is decoded, url is assigned, and the entire object is encoded again.
  • The route accepts non-URL strings and structured values; downstream UI expects a URL-like string.
  • There is no no-change detection.

Side effects

  • Updates meta and invalidates the asset-type cache. It deliberately does not refresh last_edited and writes no audit entry.

See it in Fieldmotion

CRM1

Open an Asset Type, change QR-Code URL, and inspect AssetType_setUrl. The setup table displays the value parsed from metadata.

CRM2

No direct production CRM2 caller was found. CRM2’s mapped update can write metaURL and does refresh last_edited.

Related endpoints