Customer types
Create customer types in bulk
/a/CustomerTypes_new
Create several customer types by name and return an independent status for every submitted item.
When to use this endpoint
Use CustomerTypes_new for the legacy customer import’s name-only bulk creation. For mapped CRM2 fields, use CustomerType_createData bulk mode.
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 |
|---|---|---|---|
customerTypes | JSON array string or native array | Yes | List of objects with a name member. A decoded JSON object/associative array is iterated by its values and does not behave as one item. |
Example request
$result = FM_api('CustomerTypes_new', [
'customerTypes' => json_encode([
['name' => 'Commercial'],
['name' => 'Residential'],
]),
]);
Example response
{
"statuses": [
{"ok": 1, "id": 12},
{"ok": 1, "id": 13}
]
}
Each input item contributes one status in input order. A blank item contributes {"error":"name not set"} and processing continues.
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. |
{"error":"missing or invalid parameter: customerTypes"} | The key is absent. |
{"statuses":[{"error":"name not set"}]} | An item lacks a usable name after cleaning. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Each name has angle-bracket tag-like fragments removed and surrounding whitespace trimmed. There is no duplicate or length check.
- An empty list returns
{"statuses":[]}. A JSON object instead of a list is iterated as values rather than treated as one item; for example,{"name":"Commercial"}produces onename not setstatus. - There is no filtering or pagination.
Side effects
- Inserts each valid name independently. It does not explicitly invalidate the customer-type cache or write generic mapped-field audit rows.
- It does not update customers, configure transitions, or run email triggers.
See it in Fieldmotion
CRM1
The legacy customer import uses this route to add translated type names that were not found by CustomerTypes_listByNames.
CRM2
CRM2’s dedicated customer-type import calls this endpoint. Its generic customer import instead creates missing translated type names through CustomerType_createData bulk mode.
Related endpoints
CustomerTypes_listByNamesshould be used first to find existing names.CustomerType_createDatatimestamps and audits mapped bulk inserts.