> ## Documentation Index
> Fetch the complete documentation index at: https://meilisearch-6b28dec2-add-platform-documentation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Configure HTTP webhooks to receive notifications when Meilisearch indexing tasks complete or fail.

Webhooks let Meilisearch notify an external HTTP endpoint whenever a task completes. Use them to trigger downstream actions automatically, such as purging a cache after a successful index update or alerting your team when a task fails.

Webhooks are configured per project in **Project Settings > Webhooks**. Up to 20 webhooks can be configured per project.

<Frame>
  <img src="https://mintcdn.com/meilisearch-6b28dec2-add-platform-documentation/OWGPd0pJLBDzivo8/assets/images/platform/management/webhooks_empty.png?fit=max&auto=format&n=OWGPd0pJLBDzivo8&q=85&s=aaa444e7e0232e7fdc164fbbe648ec03" alt="Webhooks section in Project Settings showing the Add webhook button and description" width="3440" height="1974" data-path="assets/images/platform/management/webhooks_empty.png" />
</Frame>

## Adding a webhook

1. Go to **Project Settings > Webhooks** and click **+ Add webhook**.

<Frame>
  <img src="https://mintcdn.com/meilisearch-6b28dec2-add-platform-documentation/OWGPd0pJLBDzivo8/assets/images/platform/management/webhooks_add.png?fit=max&auto=format&n=OWGPd0pJLBDzivo8&q=85&s=6230f146ce3237ac8db47465a2fd755c" alt="Add webhook modal with Webhook URL and Authorization Header fields" width="3452" height="1972" data-path="assets/images/platform/management/webhooks_add.png" />
</Frame>

2. Enter the **Webhook URL**: the endpoint where Meilisearch will send POST requests with task data.
3. Optionally, enter an **Authorization Header** (for example, `Bearer your-secret-token`). This header is sent with every webhook request so your endpoint can verify the source.
4. Click **Add webhook**.

## How webhooks work

When a task completes, Meilisearch sends an HTTP POST request to your configured URL. The request body is [ndjson](https://ndjson.org/) (newline-delimited JSON), with one task object per line matching the format returned by the [Tasks API](/reference/api/tasks/get-task).

```
{"uid":1,"indexUid":"movies","status":"succeeded","type":"documentAdditionOrUpdate",...}
{"uid":2,"indexUid":"movies","status":"failed","type":"documentAdditionOrUpdate",...}
```

Your endpoint must respond with a 2xx status code. Non-2xx responses are treated as failures and retried with exponential backoff.

<Warning>
  Multiple active webhooks may impact performance. Keep only the webhooks you actively use.
</Warning>

## Securing your endpoint

Always validate the `Authorization` header on incoming webhook requests. Set a long random secret and reject requests that do not match.

```js theme={null}
app.post('/webhook', (req, res) => {
  if (req.headers['authorization'] !== process.env.WEBHOOK_SECRET) {
    return res.status(401).end();
  }
  // Process the ndjson payload
  res.status(200).end();
});
```

## Example use cases

| Use case               | Description                                                                               |
| ---------------------- | ----------------------------------------------------------------------------------------- |
| **Cache purge**        | Invalidate your CDN or application cache after a `documentAdditionOrUpdate` task succeeds |
| **Slack notification** | Send a message to a Slack channel when any task fails                                     |
| **CI/CD integration**  | Signal a deployment pipeline that a new index is ready                                    |
| **Audit log**          | Append every task event to an external log store for compliance                           |
