> ## Documentation Index
> Fetch the complete documentation index at: https://docs.capedigital.co.ke/llms.txt
> Use this file to discover all available pages before exploring further.

# List groups

> GET /api/v1/auth/groups

Admins (role:manage) see all groups and can filter by ?department_id=.
All other users see only groups in their own department.



## OpenAPI

````yaml /openapi/user.yaml get /api/v1/auth/groups
openapi: 3.0.3
info:
  title: CapeMedia User Service API
  version: 1.0.0
  description: |2-

        **CapeMedia User Service API** - Comprehensive user service and management system.

        ## Authentication
        This API uses **JWT Bearer tokens** for authentication.

        1. Login via `/api/v1/auth/login` to obtain tokens
        2. Include the access token in the `Authorization` header: `Bearer <access_token>`
        3. Refresh expired tokens via `/api/v1/auth/refresh-token`

        ## Versioning
        The API uses URL path versioning (e.g., `/api/v1/`, `/api/v2/`).
        Current version: **v1**
        
  contact:
    name: API Support
    email: support@capemedia.co.ke
  license:
    name: Cape Media
servers:
  - url: https://api.diginacape.co.ke/acl
    description: Production
  - url: http://localhost:8000
    description: Local
security: []
paths:
  /api/v1/auth/groups:
    get:
      tags:
        - Groups
      summary: List groups
      description: |-
        GET /api/v1/auth/groups

        Admins (role:manage) see all groups and can filter by ?department_id=.
        All other users see only groups in their own department.
      operationId: groups_list
      parameters:
        - name: cursor
          required: false
          in: query
          description: The pagination cursor value.
          schema:
            type: string
        - in: query
          name: department_id
          schema:
            type: string
          description: Filter by department ID (UUID).
        - name: limit
          required: false
          in: query
          description: Number of results to return per page.
          schema:
            type: integer
        - in: query
          name: search
          schema:
            type: string
          description: Search by group name or department name.
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGroupList'
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    PaginatedGroupList:
      type: object
      required:
        - results
      properties:
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?cursor=cD00ODY%3D"
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?cursor=cj0xJnA9NDg3
        results:
          type: array
          items:
            $ref: '#/components/schemas/Group'
    Group:
      type: object
      description: |-
        Serializer for Group — a Keycloak group scoped to a department.

        On write, supply `department_id`. On read, the full department object
        is returned. The `keycloak_id` field is read-only — set by the server
        at creation time and must never be changed by the client.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          description: >-
            Name of the group, e.g. 'Commercial Operations'. Normalized to title
            case with single spaces on write.
        description:
          type: string
          nullable: true
        department:
          allOf:
            - $ref: '#/components/schemas/Department'
          readOnly: true
        keycloak_id:
          type: string
          readOnly: true
          nullable: true
        realm:
          type: string
          readOnly: true
          default: capemedia
          description: Keycloak realm this group belongs to
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - department
        - id
        - keycloak_id
        - name
        - realm
        - updated_at
    Department:
      type: object
      description: Serializer for Department.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
        description:
          type: string
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - id
        - name
        - updated_at
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````