When to use this endpoint

Create an underlying named location under an active Customer, using parentID=0 for a root. Use the returned id for subsequent edits and reads.

Authentication and permissions

Use signed API-key authentication or a logged-in CRM session. API keys act as their owner; session requests use dispatcher CSRF protection where configured. IDs and mapped queries address the authenticated tenant.

Login is required. CRM2 requests require Customers View and Edit for location changes, including creation. CRM2 TeamAccess scope applies to records and related data. These added CRM2 role/scope checks do not apply to CRM1 requests; CRM1 retains its legacy permission model. Tenant isolation and business validation apply to both clients.

Parameters

ParameterTypeRequiredDescription
name / customerID / parentIDText / integer IDsname and customerID required on createname must be nonblank and at most 100 characters. customerID must identify an active visible owning Customer. parentID defaults 0 (root); a positive parent must belong to the same Customer. The full ancestor chain is checked for cycles.

Example request

$result = FM_api('CustomerAssetLocation_createData', ['name'=>'Ground floor','customerID'=>'1042','parentID'=>'0']);

Example response

{
  "ok": 1,
  "id": 18
}

Scalar numeric values may be strings or numbers depending on the database driver.

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": "Your role does not permit this action."}A CRM2 request lacks the required View/action grant.
{"error": "Record is unavailable or outside your permitted scope."}A selected write target is unavailable or outside CRM2 scope.
{"error": "missing or invalid parameter: id/ids"}An update omits its selection, or supplies an invalid/nonpositive ID.
{"error": "Unable to complete this operation. Check the saved state before retrying."}An unexpected persistence failure is reported; inspect saved state before retrying.
{"error": "Location parents cannot contain a cycle."}The parent chain contains this node or another repeated ancestor.
{"error": "Choose a parent location belonging to the same customer."}A positive parent/ancestor is missing or belongs to another Customer.

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

Behaviour and edge cases

  • Record identity and lifecycle values are server-owned. Inline writes reject id and lifecycle targets. Full edits tolerate unchanged lifecycle values from a fetched record and reject changed ones; create derives them on the server. Transport metadata such as CSRF/API/session keys and extra is not a business-field update.
  • Omitted or native-null optional mapped values are skipped on edits. Blank text is saved; blank date/datetime/JSON clears to SQL NULL where mapped. Date fields require real YYYY-MM-DD. Ordinary numeric fields retain the mapped numeric conversion; the explicit ID/reference/enum checks listed here run first.
  • Selected records are checked before writes. Tenant primary writes run in one checked transaction: a later validation/write failure rolls back earlier members of the batch. Empty/no-change updates return ok=1 and warning="No Change."; inline responses also carry oldData with previous storage-column values. Unknown business fields are ignored by the mapped writer.
  • Changing customerID is rejected if this node has children or active Assets, preventing stranded descendants/Asset relationships. Changing parent does not move an Asset or alter locID. Missing/null optional edit fields preserve the saved values; a blank name is invalid.
  • No direct caller of this exact namespace was found in the current mobile intermediary/app sources; mobile synchronization uses separate APIs.

Side effects

  • Changed mapped values stamp last_edited, invalidate the affected table cache and record field-change history. Read the saved object back before performing dependent work.

See it in Fieldmotion

CRM1

No direct caller was found in the current CRM1 JavaScript. This is separate from the general Locations screen and from the Asset owner/customer fields.

CRM2

In CRM2, open Customers > a record > Asset Location. The page reads nodes using customerID and writes parent moves with each stored node ID. Save waits for acknowledgements and verifies the stored parent with a fresh read before clearing the changed flag. Rejection stops dependent saves, re-enables Save and retains the draft; newer changes made during a save remain pending. The selected node’s Asset table uses Asset/Assets with locID.

Related endpoints