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

# User added to group webhook

> Receive a JSON payload at your own URL when a user joins a group on your Zapnito community, including the group's UUID and name.

Subscribe a URL of your choosing to be notified when a user joins a group on your community. Before you start, read the [webhooks overview](/webhooks/overview) for how subscriptions and authentication work.

<Note>This event is called `group_membership_created` in the API.</Note>

## Payload

When you subscribe to the User added to group webhook, your URL is sent a JSON payload with details of the event.

### Request headers

```text title="Headers sent to your URL" theme={null}
Accept: application/json
X-Zapnito-Hostname: community.acme.org
Authorization: Token token=YOUR_ENDPOINT_TOKEN
```

* `X-Zapnito-Hostname` is the hostname of the Zapnito community that sent the event.
* `Authorization` is only sent if you set an `authorization_token` when you created the subscription.

### Example payload

<ResponseExample>
  ```json title="User added to group payload" theme={null}
  {
    "user_id": "1",
    "name": "Alex Smith",
    "email": "alex.smith@example.com",
    "group_uuid": "a1ecad96-8849-45ba-821e-20199cde45cd",
    "group_name": "Expert Users"
  }
  ```
</ResponseExample>

## Create a subscription

<ParamField header="Authorization" type="string" required>
  Your API token in the format `Token token=YOUR_API_TOKEN`.
</ParamField>

<ParamField body="url" type="string" required>
  The URL you want Zapnito to notify when a user joins a group on your community.
</ParamField>

<ParamField body="authorization_token" type="string">
  A token that Zapnito sends in the `Authorization` header of each request to your URL, in the format `Token token=YOUR_ENDPOINT_TOKEN`.
</ParamField>

```bash title="Create a subscription" theme={null}
curl -X POST https://your-community.zapnito.com/api/v1/rest_hooks/group_membership_created/subscriptions \
  -H "Authorization: Token token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/webhooks/user-added-to-group", "authorization_token": "YOUR_ENDPOINT_TOKEN"}'
```

`POST https://your-community.zapnito.com/api/v1/rest_hooks/group_membership_created/subscriptions`

* `201 Created`: the subscription was created. The response body is `{"id": "27"}`. Keep the `id` so you can delete the subscription later.

## Delete a subscription

Remove a previously registered URL for the User added to group webhook.

<ParamField header="Authorization" type="string" required>
  Your API token in the format `Token token=YOUR_API_TOKEN`.
</ParamField>

<ParamField path="id" type="integer" required>
  The ID of the subscription that was returned when you created it.
</ParamField>

```bash title="Delete a subscription" theme={null}
curl -X DELETE https://your-community.zapnito.com/api/v1/rest_hooks/group_membership_created/subscriptions/27 \
  -H "Authorization: Token token=YOUR_API_TOKEN"
```

`DELETE https://your-community.zapnito.com/api/v1/rest_hooks/group_membership_created/subscriptions/:id`

* `204 No Content`: the subscription was deleted.
* `404 Not Found`: no subscription matches the provided ID.


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