Customer types
Create a customer type
/a/CustomerType_new
Create one customer type from a required legacy name field.
When to use this endpoint
Use CustomerType_new for the CRM1 single-type create dialog. CRM2 normally uses CustomerType_createData.
Authentication and permissions
The name is cleaned and validated before login is required. A blank unauthenticated request therefore returns the name error instead of the normal authentication error.
An accepted request must then authenticate with signed API-key fields or a logged-in CRM session. The insert is tenant-scoped and has no role check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name after removing angle-bracket tag-like fragments and trimming surrounding whitespace. There is no length or duplicate-name check. |
Example request
$created = FM_api('CustomerType_new', [
'name' => ' Commercial ',
]);
Example response
{
"ok": 1,
"id": 12
}
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: name"} | The key is absent or its cleaned value is blank. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Names can be duplicated. The endpoint stores only the cleaned name and current server timestamp; remaining columns use database defaults.
- There is no filtering or pagination.
Side effects
- Inserts one tenant row and invalidates the customer-type cache.
- It does not create customers, configure allowed transitions, or run email triggers.
See it in Fieldmotion
CRM1
Open Settings → Customer Types and choose New Customer Type.
CRM2
No direct production CRM2 caller was found; CRM2’s shared create form calls CustomerType_createData.
Related endpoints
CustomerType_saveconfigures the new row.CustomerType_createDataaccepts CRM2 mapped fields.