Customer types
Create a customer type through the field map
/a/CustomerType_createData
Create one or several customer classifications through CRM2’s named field map.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | No | Stored name. It is not trimmed, length-limited, required, or checked for uniqueness. |
allowedNext | String | No | Complete raw allowed_next value. Normal CRM editing uses a comma-separated list of customer-type IDs, but this route does not validate that format. |
triggers | String or JSON-compatible value | No | Complete trigger configuration. Arrays/objects are JSON-encoded by the shared helper; strings are stored verbatim. |
lastEdited | Datetime string | No | Stored timestamp. Current server time is supplied when omitted; a supplied value is not date-validated. |
colourHex | String | No | Complete colour_hex value. This mapped route does not enforce a leading hash, hexadecimal digits, or seven-character length. |
multiple | Native array of objects | No | Switches to bulk mode. Each object accepts the fields above. This must be an already-decoded request array, not a JSON string. |
id | Any | No | Ignored 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
| Response | Condition |
|---|---|
{"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 error | multiple 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
multiplearray returns an empty array. A missingnamein 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
CustomerType_updateDataupdates the same mapped fields.CustomerTypes_newis the older bulk name-only route.