Skip to content
29 changes: 29 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,35 @@ export_post_1: |-
}
}
}'
webhooks_get_1: |-
curl \
-X GET 'MEILISEARCH_URL/webhooks'
webhooks_get_single_1: |-
curl \
-X GET 'MEILISEARCH_URL/webhooks/WEBHOOK_UUID'
webhooks_post_1: |-
curl \
-X POST 'MEILISEARCH_URL/webhooks' \
-H 'Content-Type: application/json' \
--data-binary '{
"url": "WEBHOOK_TARGET_URL",
"headers": {
"authorization": "SECURITY_KEY",
"referer": "https://example.com"
}
}'
webhooks_patch_1: |-
curl \
-X PATCH 'MEILISEARCH_URL/webhooks/WEBHOOK_UUID' \
-H 'Content-Type: application/json' \
--data-binary '{
"header": {
"referer": null
}
}'
webhooks_delete_1: |-
curl \
-X DELETE 'MEILISEARCH_URL/webhooks/WEBHOOK_UUID'

### Code samples for experimental features
experimental_get_metrics_1: |-
Expand Down
123 changes: 121 additions & 2 deletions assets/misc/meilisearch-collection-postman.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"info": {
"_postman_id": "f4b62ec3-0403-44ba-b6f4-640badbbd1b2",
"name": "Meilisearch v1.16",
"_postman_id": "a0638dc7-4c40-4c37-822d-bf342771238d",
"name": "Meilisearch latest",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "25294324"
},
Expand Down Expand Up @@ -3044,6 +3044,125 @@
}
]
},
{
"name": "Webhooks",
"item": [
{
"name": "Get all webhooks",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{url}}/webhooks",
"host": [
"{{url}}"
],
"path": [
"webhooks"
]
}
},
"response": []
},
{
"name": "Get one webhook",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{url}}/webhooks/WEBHOOK_UUID",
"host": [
"{{url}}"
],
"path": [
"webhooks",
"WEBHOOK_UUID"
]
}
},
"response": []
},
{
"name": "Create a webhook",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"WEBHOOK_TARGET_URL\",\n \"headers\": {\n \"authorization\": \"SECURITY_KEY\",\n \"referer\": \"https://example.com\"\n }\n}"
},
"url": {
"raw": "{{url}}/webhooks",
"host": [
"{{url}}"
],
"path": [
"webhooks"
]
}
},
"response": []
},
{
"name": "Update a webhook",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"header\": {\n \"referer\": null\n }\n}"
},
"url": {
"raw": "{{url}}/webhooks/WEBHOOK_UUID",
"host": [
"{{url}}"
],
"path": [
"webhooks",
"WEBHOOK_UUID"
]
}
},
"response": []
},
{
"name": "Delete a webhook",
"request": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "{{url}}/webhooks/WEBHOOK_UUID",
"host": [
"{{url}}"
],
"path": [
"webhooks",
"WEBHOOK_UUID"
]
}
},
"response": []
}
]
},
{
"name": "Stats",
"item": [
Expand Down
3 changes: 2 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@
"reference/api/experimental_features",
"reference/api/metrics",
"reference/api/logs",
"reference/api/export"
"reference/api/export",
"reference/api/webhooks"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion learn/async/asynchronous_operations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Tasks always contain a field indicating the task's current `status`. This field
- **`failed`**: a failure occurred when processing the task. No changes were made to the database
- **`canceled`**: the task was canceled

`succeeded`, `failed`, and `canceled` tasks are finished tasks. Meilisearch keeps them in the task database but has finished processing these tasks. It is possible to [configure a webhook](/learn/self_hosted/configure_meilisearch_at_launch#task-webhook-url) to notify external services when a task is finished.
`succeeded`, `failed`, and `canceled` tasks are finished tasks. Meilisearch keeps them in the task database but has finished processing these tasks. It is possible to [configure a webhook](/reference/api/webhooks) to notify external services when a task is finished.

`enqueued` and `processing` tasks are unfinished tasks. Meilisearch is either processing them or will do so in the future.

Expand Down
6 changes: 5 additions & 1 deletion learn/async/task_webhook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ description: Learn how to use webhooks to react to changes in your Meilisearch d
sidebarDepth: 3
---

This guide teaches you how to use webhooks to notify a URL when Meilisearch completed a [task](/learn/async/asynchronous_operations).
This guide teaches you how to configure a single webhook via instance options to notify a URL when Meilisearch completes a [task](/learn/async/asynchronous_operations).

<Tip>
If you are using Meilisearch Cloud or need to configure multiple webhooks, use the [`/webhooks` API route](/reference/api/webhooks) instead.
</Tip>

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion learn/async/working_with_tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This will return the full task object:
}
```

If the task is still `enqueued` or `processing`, wait a few moments and query the database once again. If you are working with a self-hosted Meilisearch instance, you may also [set up a webhook listener](/learn/async/task_webhook).
If the task is still `enqueued` or `processing`, wait a few moments and query the database once again. You may also [set up a webhook listener](/reference/api/webhooks).

When `status` changes to `succeeded`, Meilisearch has finished processing your request.

Expand Down
2 changes: 2 additions & 0 deletions learn/resources/telemetry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,5 @@ This list is liable to change with every new version of Meilisearch. It's not be
| `export.avg_index_patterns` | Average number of index patterns set per export | `3.2`
| `export.avg_patterns_with_filter` | Average number of index patterns with filters per export | `1.7`
| `export.avg_payload_size` | Average payload size per export | `512`
| `webhooks_created` | Number of webhooks created in an instance | `2`
| `webhooks.updated` | Number of times all webhooks in an instance have been updated | `5`
2 changes: 2 additions & 0 deletions learn/self_hosted/configure_meilisearch_at_launch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ Notifies the configured URL whenever Meilisearch [finishes processing a task](/l

The webhook payload contains the list of finished tasks in [ndjson](https://github.com/ndjson/ndjson-spec). For more information, [consult the dedicated task webhook guide](/learn/async/task_webhook).

The task webhook option requires having access to a command-line interface. If you are using Meilisearch Cloud, use the [`/webhooks` API route](/reference/api/webhooks) instead.

### Task webhook authorization header

**Environment variable**: `MEILI_TASK_WEBHOOK_AUTHORIZATION_HEADER`<br />
Expand Down
6 changes: 5 additions & 1 deletion reference/api/keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Custom API keys are deterministic: `key` is a SHA256 hash of the `uid` and maste
**Default value**: N/A<br />
**Description**: An array of API actions permitted for the key, represented as strings. API actions are only possible on authorized [`indexes`](#indexes). `["*"]` for all actions.

You can use `*` as a wildcard to access all endpoints for the `documents`, `indexes`, `tasks`, `settings`, `stats` and `dumps` actions. For example, `documents.*` gives access to all document actions.
You can use `*` as a wildcard to access all endpoints for the `documents`, `indexes`, `tasks`, `settings`, `stats`, `webhooks`, and `dumps` actions. For example, `documents.*` gives access to all document actions.

<Warning>
For security reasons, we do not recommend creating keys that can perform all actions.
Expand Down Expand Up @@ -111,6 +111,10 @@ For security reasons, we do not recommend creating keys that can perform all act
| **`network.get`** | Provides access to the [get the network object](/reference/api/network#get-the-network-object) endpoint |
| **`network.update`** | Provides access to the [update the network object](/reference/api/network#update-the-network-object) endpoint |
| **`chatCompletions`** | Provides access to the [chat completions endpoints](/reference/api/chats). Requires experimental feature to be enabled |
| **`webhooks.get`** | Provides access to the [get webhooks](/reference/api/webhooks#get-all-webhooks) endpoints |
| **`webhooks.create`** | Provides access to the [create webhooks](/reference/api/webhooks#create-a-webhook) endpoint |
| **`webhooks.update`** | Provides access to the [update webhooks](/reference/api/webhooks#update-a-webhook) endpoint |
| **`webhooks.delete`** | Provides access to the [delete webhooks](/reference/api/webhooks#delete-a-webhook) endpoint |

### `indexes`

Expand Down
Loading