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

ParameterTypeRequiredDescription
idInteger stringYesDepartment ID after integer conversion. Zero is rejected; existence is not checked.
valStringYesReplacement 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

ResponseCondition
{"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 name and advances last_edited for 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