When to use this endpoint

Use AssetTable_importTables only with CRM2’s Asset Table definition CSV importer. Row data is imported separately.

Authentication and permissions

The request must authenticate as a logged-in tenant user.

The handler requires client-admin status. It does not separately check the Asset Tables page permission.

Parameters

ParameterTypeRequiredDescription
tablesJSON arrayYesOuter array of definitions. Each usable item needs positive id, nonblank name, and fields. The fields value is itself a nonempty JSON array string, not a nested array.

Example request

$result = FM_api('AssetTable_importTables', [
	'tables' => json_encode([
		[
			'id' => 1700000000123,
			'name' => 'Inspection readings',
			'fields' => json_encode([
				['id' => 1, 'name' => 'Pressure', 'type' => 'text', 'extra' => ''],
			]),
		],
	]),
]);

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":"only client admins can edit table attributes"}The authenticated user is not a client administrator.
{"error":"missing or invalid parameter: tables"}The tables key is absent.
{"error":"invalid parameter: fields"}A definition that otherwise has an ID/name/fields key contains invalid or empty encoded fields.

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

Behaviour and edge cases

  • Definitions missing a positive ID, a nonblank name, or the fields key are silently skipped. Names and individual field objects are not normalized or validated.
  • Valid definitions overwrite matching keys and preserve other existing definitions.
  • After parsing, the handler deletes the existing setting row and inserts the complete replacement directly. The delete and insert are not transactional.

Side effects

  • Rewrites the tenant asset-tables setting and clears its cache. Stored Asset Table rows are unchanged and no audit entry is written.

See it in Fieldmotion

CRM1

No production CRM1 caller was found.

CRM2

Open the Assets module’s Asset Table definition importer, upload its CSV format, and inspect AssetTable_importTables after the browser groups fields by table name.

Related endpoints