When to use this endpoint

Use Customer_getDepartmentId only when a caller needs this single relationship ID and already knows that the customer exists.

Use Customer_get when absence must be distinguished from an unassigned department.

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

ParameterTypeRequiredDescription
idInteger stringYesCustomer ID; it must convert to a positive integer.

Example request

$department = FM_api('Customer_getDepartmentId', [
	'id' => '1088',
]);

Example response

{
  "ok": 1,
  "department_id": 7
}

A nonexistent customer also returns {"ok":1,"department_id":0}.

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":"missing or invalid parameter: id"}id is absent or invalid.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • The query does not filter inactive or soft-deleted rows.
  • The database value is converted to an integer.
  • This is a single-value lookup with no filtering or pagination.

See it in Fieldmotion

CRM1

No direct production CRM1 caller was found. Current edit screens already load the department through broader customer data.

CRM2

No direct production CRM2 caller was found; CRM2 uses layout-driven customer reads.

Related endpoints