When to use this endpoint

Use CustomerType_createData for CRM2’s configurable Customer Types create dialog or for a mapped bulk import. Use CustomerType_new for the older single-name workflow.

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
nameStringNoStored name. It is not trimmed, length-limited, required, or checked for uniqueness.
allowedNextStringNoComplete raw allowed_next value. Normal CRM editing uses a comma-separated list of customer-type IDs, but this route does not validate that format.
triggersString or JSON-compatible valueNoComplete trigger configuration. Arrays/objects are JSON-encoded by the shared helper; strings are stored verbatim.
lastEditedDatetime stringNoStored timestamp. Current server time is supplied when omitted; a supplied value is not date-validated.
colourHexStringNoComplete colour_hex value. This mapped route does not enforce a leading hash, hexadecimal digits, or seven-character length.
multipleNative array of objectsNoSwitches to bulk mode. Each object accepts the fields above. This must be an already-decoded request array, not a JSON string.
idAnyNoIgnored during creation even though it exists in the read/update map.

Example request

$created = FM_api('CustomerType_createData', [
	'multiple' => [
		['name' => 'Commercial', 'colourHex' => '#336699'],
		['name' => 'Residential', 'colourHex' => '#669933'],
	],
]);

Example response

[
  {"id": 12, "name": "Commercial"},
  {"id": 13, "name": "Residential"}
]

Without multiple, the response is {"ok":1,"id":12}. Bulk mode instead returns one id/name object per successful input row.

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.
Runtime warning or type errormultiple is not a native list of request objects. JSON text is not decoded by this handler.

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

Behaviour and edge cases

  • An empty single-row request still inserts a row because the helper supplies last_edited. Blank and duplicate names are accepted.
  • An empty multiple array returns an empty array. A missing name in a bulk item can still create a row; its echoed response name is then null after a PHP notice.
  • There is no filtering or pagination.

Side effects

  • Inserts one row per accepted item, invalidates the customer-type cache, and writes the shared field-level audit entries.
  • It does not change customers or run a type’s email trigger.

See it in Fieldmotion

CRM1

No production CRM1 caller was found. CRM1’s settings dialog calls CustomerType_new, while its import flow calls CustomerTypes_new.

CRM2

Open Settings → Customer Types and create a row. The shared display widget derives this endpoint from the Customer Type API prefix. CRM2’s generic customer import uses bulk mode for missing translated type names; its dedicated customer-type import still calls CustomerTypes_new.

Related endpoints