Departments
Rename a department
POST
/a/Department_setName
Replace a department name through the administrator-only CRM1 inline editor.
When to use this endpoint
Use Department_setName when reproducing the CRM1 Departments page’s focused rename action.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session, and the acting user must be a client administrator.
The update is restricted to the authenticated tenant.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Department ID after integer conversion. Zero is rejected; existence is not checked. |
val | String | Yes | Replacement name. It is not trimmed or checked for duplicates/length; empty and exact string 0 are rejected as false-like. |
Example request
$result = FM_api('Department_setName', [
'id' => '42',
'val' => 'Northern region',
]);
Example response
{
"ok": 1
}
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":"no id supplied"} | The ID is absent or integer-converts to zero. |
{"error":"no name supplied"} | val is absent or PHP-false-like. |
{"ok":1} | The positive ID does not exist; affected-row count is not checked. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Whitespace-only names and case/spacing duplicates are accepted. The route performs no read-before-write check.
- There is no filtering or pagination; one update statement is issued.
Side effects
- Replaces
nameand advanceslast_editedfor a matching department. - Does not invalidate the departments cache or write audit history.
See it in Fieldmotion
CRM1
Open Users → Departments and click a Name cell. Leaving the inline editor after a change calls this route.
CRM2
CRM2 updates names through Department_updateData.
Related endpoints
Department_updateDatais the mapped CRM2 updater.Department_newtrims names and reuses an exact duplicate during creation.