Customers
Retrieve a customer department ID
/a/Customer_getDepartmentId
Return the integer department ID stored on a customer, using zero for both no assignment and a missing row.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Customer 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
| 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: 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
Customer_setDepartmentIdvalidates and changes the assignment.Customer_getprovides a not-found error and the wider record.