Skip to main content

List all user groups

Retrieve a list of user groups with optional filtering, searching, and pagination.

HTTP Request

GET/api/users/groups/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO AN EXTRA REDIRECT WITH 301 STATUS

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with GroupPermission or Admin
  • Permission Code: 1202
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Query Parameters

ParameterTypeDefaultDescription
limitIntegerNumber of results to return per page (default is 10)
offsetIntegerNumber of results to skip before returning results (default is 0)
searchStringSearch term to lookup results by`name` and `notes`
orderingStringOrder results by (`id`, `name`, `_users_count`, `created_at`, `updated_at`). Prefix with '-' for descending order
users_count_minIntegerMinimum number of users in the group
users_count_maxIntegerMaximum number of users in the group
id_minIntegerMinimum ID of the user group
id_maxIntegerMaximum ID of the user group
created_dateString (YYYY-MM-DD)Exact creation date
updated_dateString (YYYY-MM-DD)Exact updated date
created_fromString (YYYY-MM-DD)Groups created after a specific date
updated_fromString (YYYY-MM-DD)Groups last updated after a specific date
created_toString (YYYY-MM-DD)Groups created before a specific date
updated_toString (YYYY-MM-DD)Groups last updated before a specific date

Example Requests

1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token XXXXXXXXXXXXXXXXXXXXXX'})
5response = api.get('http://www.example.com/api/users/groups/', params={
6  'limit': 5,
7  'ordering': 'name'
8})
9print(response.json())

Response Fields

FieldTypeDescription
countIntegerTotal number of categories
nextStringURL for the next page of results
previousStringURL for the previous page of results
resultsArray[Object]Array of Group objects

Group Object Structure

FieldTypeDescription
idIntegerUnique identifier for the user group
nameStringName of the user group
notesString or nullOptional notes about the user group
users_countIntegerNumber of users in the group
created_atString (ISO 8601)Timestamp when the group was created
updated_atString (ISO 8601)Timestamp when the group was last updated

Example Response

{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"name": "Admins",
"notes": "Group for system administrators",
"users_count": 5,
"created_at": "2023-01-15T10:00:00Z",
"updated_at": "2023-06-01T12:00:00Z"
},
{
"id": 2,
"name": "Editors",
"notes": null,
"users_count": 12,
"created_at": "2023-02-20T14:30:00Z",
"updated_at": "2023-05-25T09:15:00Z"
}
]
}