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

# Link groups

> Links existing groups to the community. The response includes who joined (`added`) and who failed.



## OpenAPI

````yaml /en/api-reference/openapi.json post /communities/add-groups
openapi: 3.1.0
info:
  title: Zapfy API
  description: >-
    Multi-tenant WhatsApp API. Send messages and manage webhooks through a
    single surface.
  version: 1.0.0
servers:
  - url: https://api.zapfy.io/v1
security:
  - accountToken: []
paths:
  /communities/add-groups:
    post:
      tags:
        - Communities
      summary: Link groups
      description: >-
        Links existing groups to the community. The response includes who joined
        (`added`) and who failed.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CommunityGroupsBody'
      responses:
        '200':
          $ref: '#/components/responses/CommunityGroups'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
        '502':
          $ref: '#/components/responses/Error'
      security:
        - instanceToken: []
components:
  schemas:
    CommunityGroupsBody:
      type: object
      required:
        - id
        - groups
      properties:
        id:
          $ref: '#/components/schemas/CommunityId'
        groups:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/GroupId'
          description: Group ids to link/unlink.
          example:
            - 120363098765432109@g.us
    CommunityId:
      type: string
      description: >-
        Community id: the `...@g.us` `id` returned when creating the community
        (POST /communities/create). Use exactly as received.
      example: 120363012345678901@g.us
    GroupId:
      type: string
      description: the group id (returned by GET /groups).
      example: '120363012345678901'
    CommunityGroupsResult:
      type: object
      properties:
        added:
          type: array
          items:
            type: string
          description: Linked group ids.
          example:
            - 120363098765432109@g.us
        failed:
          type: array
          items:
            type: string
          description: Group ids that failed.
          example: []
  responses:
    CommunityGroups:
      description: Groups linked.
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/CommunityGroupsResult'
    Error:
      description: Error.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Instance not found
  securitySchemes:
    accountToken:
      type: http
      scheme: bearer
      description: Account token (`zpfy_acct_...`) — manages instances and webhooks.
    instanceToken:
      type: http
      scheme: bearer
      description: Instance token (`zpfy_inst_...`) — sends messages.

````