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

# Send to a group

> Send messages to a group, pin one, and invite people with a template.

Sending to a group uses the same send call as a 1:1 message.\

Set `recipient_type` to `group` and `to` to the group id.

## Send a message

```bash theme={null}
curl -X POST "https://gateway.hookmyapp.com/meta/v22.0/${WHATSAPP_PHONE_NUMBER_ID}/messages" \
  -H "Authorization: Bearer ${WHATSAPP_ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "group",
  "to": "GROUP_ID",
  "type": "text",
  "text": {
    "body": "Your order has shipped."
  }
}'
```

With an API key, send the same fields in `message` to `POST /channels/{ch}/messages`:

```bash theme={null}
curl -X POST https://api.hookmyapp.com/channels/ch_AbCdEf12/messages \
  -H "Authorization: Bearer hmok_..." \
  -H "Content-Type: application/json" \
  -d '{"message":{"recipient_type":"group","to":"GROUP_ID","type":"text","text":{"body":"Your order has shipped."}}}'
```

The MCP tool `send_message` takes the same fields.

| Works in groups | Does not work in groups |
| - | - |
| Text | Interactive messages (buttons and lists) |
| Media | Authentication templates |
| Templates with text or media | |

A message from any member opens the 24-hour window for the whole group.

## Pin a message

Pin a message in the group, or unpin it. A group holds up to 3 pinned messages. Pinning a fourth unpins the oldest.

```bash theme={null}
curl -X POST "https://gateway.hookmyapp.com/meta/v22.0/${WHATSAPP_PHONE_NUMBER_ID}/messages" \
  -H "Authorization: Bearer ${WHATSAPP_ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "group",
  "to": "GROUP_ID",
  "type": "pin",
  "pin": {
    "type": "pin",
    "message_id": "wamid.HBgLM...",
    "expiration_days": 7
  }
}'
```

`pin.type` is `pin` or `unpin`. `expiration_days` is 1 to 30.

## Invite people with a template

People join through the invite link, and you send the link in a template.\

Meta offers a ready-made utility template for this in its Template Library. It takes the group id and fills in the invite link when it is delivered.

**1. Create the template from the Template Library**

Send `libraryTemplateName` instead of `components`. Copy the template without changes, or it loses its utility pricing.

```bash REST theme={null}
curl -X POST https://api.hookmyapp.com/channels/ch_AbCdEf12/whatsapp/templates \
  -H "Authorization: Bearer hmok_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"group_invite","language":"en_US","category":"UTILITY","libraryTemplateName":"LIBRARY_TEMPLATE_NAME"}'
```

```bash CLI theme={null}
hookmyapp whatsapp templates create --channel 15551234567 --body @invite.json
```

`LIBRARY_TEMPLATE_NAME` is the name of Meta's group invite template in its Template Library (utility category). Some library templates also take `libraryTemplateButtonInputs`.

With the CLI, `invite.json` holds Meta's field names:

```json theme={null}
{
  "name": "group_invite",
  "language": "en_US",
  "category": "UTILITY",
  "library_template_name": "LIBRARY_TEMPLATE_NAME"
}
```

**2. Wait for approval**

Meta can take up to 24 hours. Send only once the template is `APPROVED`. See [template lifecycle](https://docs.hookmyapp.com/whatsapp/templates/lifecycle.md).

**3. Send it to the person you want in the group**

This is a 1:1 template message. The `group_id` parameter takes the group id.

```bash theme={null}
curl -X POST "https://gateway.hookmyapp.com/meta/v22.0/${WHATSAPP_PHONE_NUMBER_ID}/messages" \
  -H "Authorization: Bearer ${WHATSAPP_ACCESS_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "messaging_product": "whatsapp",
  "to": "15551234567",
  "type": "template",
  "template": {
    "name": "group_invite",
    "language": { "code": "en_US" },
    "components": [
      {
        "type": "body",
        "parameters": [
          { "type": "group_id", "group_id": "GROUP_ID" }
        ]
      }
    ]
  }
}'
```

## Incoming group messages

Messages members send in a group reach your webhook like any other message, with the group id added.\

See [group events](https://docs.hookmyapp.com/whatsapp/groups/events.md#groupid-and-participant-on-message-events).


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