When to use this endpoint

Use Assets_import for the CRM import workflow after parsing a spreadsheet into JSON row objects. It is not transactional: validate data before submission.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login or an established tenant database context and performs no additional Asset-page or role-permission check unless the page says otherwise.

Every query and write uses the authenticated tenant’s tables. CRM1 and CRM2 may hide actions through client-side permissions that these collection routes do not repeat.

Parameters

ParameterTypeRequiredDescription
mapJSON object stringYesSource-column mapping. Each entry identifies a destination in to and may include translation settings.
rowsJSON array stringYesParsed import rows keyed by the source names referenced by map.
meta[filename]StringNoStored in the import-log row for audit/display.

Example request

$result = FM_api('Assets_import', [
	'map' => json_encode([
		'ID' => ['to' => 'asset_id'],
		'Name' => ['to' => 'asset_name'],
		'Type' => ['to' => 'type'],
		'Code' => ['to' => 'code'],
	]),
	'rows' => json_encode([
		['ID' => '', 'Name' => 'Compressor 4', 'Type' => 'Compressor', 'Code' => 'CMP-004'],
	]),
	'meta' => ['filename' => 'assets.csv'],
]);

Example response

{
  "ok": 1,
  "errors": [],
  "ids": [4821]
}

Destinations include Asset ID/name/code/book ID/value/type, active/archive state, owner, whereabouts and home whereabouts, dates, make/model/warranty/QR, department, raw/selected metadata, cust:<key>, and main:<key>. Name and type destinations also support limited translation modes.

Row validation failures are accumulated rather than aborting the batch. Error entries contain the zero-based row index and row-level details; failed rows contribute ID 0.

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: map"}map is absent; this check occurs before login enforcement.
{"error":"missing or invalid parameter: rows"}rows is absent; this check occurs before login enforcement.
PHP warning/error or malformed resultEither JSON value decodes to the wrong shape; the endpoint does not explicitly validate decoded arrays.

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

Behaviour and edge cases

  • A blank Asset ID creates through Asset_new and then applies the mapped edit. A supplied ID edits that Asset. These helpers retain their normal validation, audit, movement, and related side effects.
  • A missing type name is created automatically. Whereabouts names are resolved by exact target-name lookup for the mapped type; an unresolved name silently removes the whereabouts fields from that row.
  • Home-whereabouts values use the shared validator. metaNextDate accepts only the YYYY-MM-DD shape, but the shape check does not prove that the calendar date exists.
  • serviceFrequency accepts the importer’s four-part daily/weekly/monthly/yearly format. Invalid frequency text is silently ignored. Bracketed custom-field text is normalized into a comma-split array.

See it in Fieldmotion

CRM1

Use the Assets import wizard to map uploaded spreadsheet columns and submit parsed rows.

CRM2

Use the CRM2 Assets import flow. A CRM2 migration utility also calls this route with generated mappings.

Related endpoints