User accounts and profiles
Group active users by stored departments
/a/Users_getDepartments
Return visible departments with their active member user IDs.
When to use this endpoint
Use only when reproducing legacy timeline grouping. This reads user memberships, not the full department directory or hierarchy.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Session requests use the dispatcher’s CSRF protection when configured.
Configured TeamAccess row scope is applied in the queries. Ordinary collection requests do not need artificial record IDs. Explicit IDs still pass dispatcher record authorization; unavailable IDs can be rejected there rather than silently omitted.
Login is required. No additional page permission is imposed by this handler.
Parameters
This endpoint has no operation-specific parameters.
Example request
$result = FM_api('Users_getDepartments', [
]);
Example response
[
{
"id": "18",
"name": "Engineering",
"users": [
1042
]
}
]
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. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Selects visible active users with SQL-null is_tmp. CSV and CRM2 JSON memberships are normalized into unique positive numeric department IDs.
- Only existing, visible Departments are returned, sorted by name then ID. Each users list contains unique integer IDs of visible active members. Missing Departments and zero placeholders are omitted; no matches returns []. No pagination.
Side effects
- Reads data without changing business records, edit markers, activity history or notifications. Shared setting reads can populate their normal settings cache.
See it in Fieldmotion
CRM1
CRM1 Jobs Timeline and Assets Timeline load Users_getDepartments to build resource groups.
CRM2
No direct production caller was found in CRM2. Current User layouts use the mapped getRequestedDetails/getDataTable flow; do not assume those contracts match this legacy reader.
Related endpoints
Users_list— Read the basic selectable user list and its explicit scope predicate.User_setDepartments— Write complete department memberships.