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

# Group Management

The group management endpoint allows you to perform various WhatsApp group operations including creating groups, managing participants, and updating group settings.

### Key Operations:

* Create new groups with specified participants
* Update group details (name, description, picture)
* Manage participants (add, remove, promote/demote admins)
* Handle group invites and messaging permissions

### Example Request

```bash theme={null}
curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-api-secret: YOUR_API_SECRET' \
--header 'Content-Type: application/json' \
--data '{
    "action": "create",
    "agent_number": "+1234567890",
    "title": "New Group",
    "participants": ["+1987654321"]
}'
```

### Request Body

<ParamField body="action" type="string" required>
  The operation to perform. Valid values:

  * `create`
  * `update_name`
  * `update_description`
  * `update_picture`
  * `add_participants`
  * `remove_participants`
  * `promote_admin`
  * `demote_admin`
  * `join`
  * `leave`
  * `update_settings`
</ParamField>

<ParamField body="agent_number" type="string" required>
  The phone number initiating the action (must start with '+')
</ParamField>

<ParamField body="thread_id" type="string">
  The group chat ID. Required for all actions except 'create'
</ParamField>

### Action-Specific Fields

<AccordionGroup>
  <Accordion icon="plus" title="Create Group">
    Required fields for `action: "create"`:

    * `title` (string): Group name
    * `participants` (array): Phone numbers to add
    * `initial_message` (string, optional): First message to send
  </Accordion>

  <Accordion icon="pen" title="Update Group Details">
    Fields for update actions:

    * `name` (string): New group name (`update_name`)
    * `description` (string): New description (`update_description`)
    * `image_url` (string): New profile picture URL (`update_picture`)
  </Accordion>

  <Accordion icon="users" title="Manage Participants">
    Required for participant management actions:

    * `participants` (array): Phone numbers to modify
      For actions: `add_participants`, `remove_participants`, `promote_admin`, `demote_admin`
  </Accordion>

  <Accordion icon="link" title="Join Group">
    Required for `action: "join_group"`:

    * `invite_code` (string): Group invite code
    * `thread_id` (string): Direct group ID (if already have access)
  </Accordion>

  <Accordion icon="gear" title="Group Settings">
    Required for `update_settings`:

    * `setting` (string): One of:
      * `announcement`: Only admins can send messages in the group
      * `not_announcement`: All participants can send messages in the group
      * `locked`: Only admins can modify group settings (display picture, description, etc)
      * `unlocked`: All participants can modify group settings
  </Accordion>
</AccordionGroup>

### Example Requests

<AccordionGroup>
  <Accordion icon="plus" title="Create Group">
    ```bash theme={null}
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "create",
        "agent_number": "+1234567890",
        "title": "Project Team",
        "participants": ["+1987654321", "+1012345678"],
        "initial_message": "Welcome to the project team group!"
    }'
    ```
  </Accordion>

  <Accordion icon="pen" title="Update Group Details">
    ```bash theme={null}
    # Update Name
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "update_name",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "name": "A1Base Project Team"
    }'

    # Update Description
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "update_description",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "description": "Official group for project coordination"
    }'

    # Update Picture
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "update_picture",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "image_url": "https://example.com/group-image.jpg"
    }'
    ```
  </Accordion>

  <Accordion icon="users" title="Manage Participants">
    ```bash theme={null}
    # Add Participants
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "add_participants",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "participants": ["+1555999888", "+1555777666"]
    }'

    # Remove Participants
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "remove_participants",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "participants": ["+1555999888"]
    }'

    # Promote Admin
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "promote_admin",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "participants": ["+1555777666"]
    }'

    # Demote Admin
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "demote_admin",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "participants": ["+1555777666"]
    }'
    ```
  </Accordion>

  <Accordion icon="gear" title="Other Actions">
    ```bash theme={null}
    # Join Group
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "join_group",
        "agent_number": "+1234567890",
        "thread_id": "123123"
    }'

    # Leave Group
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "leave",
        "agent_number": "+1234567890",
        "thread_id": "123123"
    }'

    # Update Group Settings
    curl --location 'https://api.a1base.com/v1/whatsapp/{accountId}/group-management' \
    --header 'x-api-key: YOUR_API_KEY' \
    --header 'x-api-secret: YOUR_API_SECRET' \
    --header 'Content-Type: application/json' \
    --data '{
        "action": "update_settings",
        "agent_number": "+1234567890",
        "thread_id": "123123",
        "setting": "announcement"
    }'
    ```
  </Accordion>
</AccordionGroup>
