> ## Documentation Index
> Fetch the complete documentation index at: https://developer.omni.z-api.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get groups

> Returns the channel's groups, paginated

## Overview

Method that returns the channel's groups. Use the `phone` field of each item as the group ID in the other routes of this section.

Send `page` and `pageSize` to paginate the result.

> [!WARNING]
>
> On WhatsApp Official, the list returns the [active groups of the number](https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference#get-active-groups) in Meta's Groups API, and `page` and `pageSize` are optional (they default to `1` and `10`).

> [!NOTE]
>
> The response structure is identical to Z-API. Your existing code that processes these returns will continue working without changes.


## OpenAPI

````yaml en/z-api/openapi.json GET /groups
openapi: 3.1.0
info:
  title: Omni Z-API - Z-API Compatibility
  description: Z-API compatible API to facilitate migration to Omni Z-API
  version: 1.0.0
servers:
  - url: https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}
    variables:
      channel_id:
        description: Channel ID (equivalent to Z-API instance_id)
        default: YOUR_CHANNEL
      channel_token:
        description: Channel token (equivalent to Z-API token)
        default: YOUR_TOKEN
security:
  - bearerAuth: []
paths:
  /groups:
    get:
      tags:
        - Groups
      summary: Get groups
      description: Returns the channel's groups, paginated.
      operationId: getGroups
      parameters:
        - name: page
          in: query
          required: true
          description: >-
            Page of groups to fetch (pagination). Required in Z-API; on WhatsApp
            Official, without it the value is 1
          schema:
            type: integer
        - name: pageSize
          in: query
          required: true
          description: >-
            Number of groups per page. Required in Z-API; on WhatsApp Official,
            without it the value is 10
          schema:
            type: integer
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GroupListItem'
              example:
                - isGroup: true
                  name: Grupo teste
                  phone: 120263358412332916-group
                  unread: '0'
                  lastMessageTime: '1730918668000'
                  isMuted: '0'
                  isMarkedSpam: 'false'
                  archived: 'false'
                  pinned: 'false'
                  muteEndTime: null
                  messagesUnread: '0'
        '400':
          $ref: '#/components/responses/GroupBadRequest'
        '422':
          $ref: '#/components/responses/GroupUnprocessable'
        '500':
          $ref: '#/components/responses/GroupInternalError'
        '502':
          $ref: '#/components/responses/GroupBadGateway'
        '503':
          $ref: '#/components/responses/GroupUnavailable'
components:
  schemas:
    GroupListItem:
      type: object
      properties:
        isGroup:
          type: boolean
          description: Indicates whether it is a group
        name:
          type: string
          description: Name assigned to the chat
        phone:
          type: string
          description: Group ID/Phone
        unread:
          type: string
          description: Number of unread messages in the chat
        lastMessageTime:
          type: string
          description: Timestamp of the last interaction with the chat
        isMuted:
          type: string
          description: '`0` or `1` indicates whether the chat is muted'
        isMarkedSpam:
          type: string
        archived:
          type: string
        pinned:
          type: string
        muteEndTime:
          type: string
        messagesUnread:
          type: string
    GroupError:
      type: object
      properties:
        error:
          type: string
          description: Error message
  responses:
    GroupBadRequest:
      description: >-
        Invalid request: parameter or field outside the rules. See the common
        errors in the Groups introduction.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GroupError'
          example:
            error: invalid path parameter
    GroupUnprocessable:
      description: >-
        Route unavailable for the channel type, inactive subscription or refusal
        by Meta. See the common errors in the Groups introduction.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GroupError'
          example:
            error: instance subscription is not active
    GroupInternalError:
      description: Unexpected internal error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GroupError'
          example:
            error: internal server error
    GroupBadGateway:
      description: The channel did not answer.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GroupError'
          example:
            error: failed to reach the META_WHATSAPP channel
    GroupUnavailable:
      description: >-
        Internal Omni Z-API failure that the request did not cause. Try again
        later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GroupError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Secret Key generated in the Omni Z-API Security panel

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.