Using task webhooks
Learn how to use webhooks to react to changes in your Meilisearch database.
This guide teaches you how to use webhooks to notify a URL when Meilisearch completed a task.
Requirements
- a command-line console
- a self-hosted Meilisearch instance
- a server configured to receive
POST
requests with an ndjson payload
Configure the webhook URL
Restart your Meilisearch instance and provide the webhook URL to --task-webhook-URL
:
You may also define the webhook URL with environment variables or in the configuration file with MEILI_TASK_WEBHOOK_URL
.
Optional: configure an authorization header
Depending on your setup, you may need to provide an authorization header. Provide it to task-webhook-authorization-header
:
Test the webhook
A common asynchronous operation is adding or updating documents to an index. The following example adds a test document to our books
index:
When Meilisearch finishes indexing this document, it will send a POST
request the URL you configured with --task-webhook-url
. The request body will be one or more task objects in ndjson format:
If Meilisearch has batched multiple tasks, it will only trigger the webhook once all tasks in a batch are finished. In this case, the response payload will include all tasks, each separated by a new line:
Was this page helpful?