Skip to content

Commit 4ec1f39

Browse files
add webhooks reference
1 parent 301cf97 commit 4ec1f39

File tree

3 files changed

+165
-1
lines changed

3 files changed

+165
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,32 @@ export_post_1: |-
14791479
}
14801480
}
14811481
}'
1482+
webhooks_get_1: |-
1483+
curl \
1484+
-X GET 'MEILISEARCH_URL/webhooks'
1485+
webhooks_post_1: |-
1486+
curl \
1487+
-X POST 'MEILISEARCH_URL/webhooks' \
1488+
-H 'Content-Type: application/json' \
1489+
--data-binary '{
1490+
"url": "WEBHOOK_TARGET_URL",
1491+
"headers": {
1492+
"authorization": "SECURITY_KEY",
1493+
"referer": "https://example.com"
1494+
}
1495+
}'
1496+
webhooks_patch_1: |-
1497+
curl \
1498+
-X PATCH 'MEILISEARCH_URL/webhooks/WEBHOOK_UUID' \
1499+
-H 'Content-Type: application/json' \
1500+
--data-binary '{
1501+
"header": {
1502+
"referer": null
1503+
}
1504+
}'
1505+
webhooks_delete_1: |-
1506+
curl \
1507+
-X DELETE 'MEILISEARCH_URL/webhooks'
14821508
14831509
### Code samples for experimental features
14841510
experimental_get_metrics_1: |-

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@
350350
"reference/api/experimental_features",
351351
"reference/api/metrics",
352352
"reference/api/logs",
353-
"reference/api/export"
353+
"reference/api/export",
354+
"reference/api/webhooks"
354355
]
355356
},
356357
{

reference/api/webhooks.mdx

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
title: Webhooks
3+
description: Use the /webhooks to trigger automatic workflows when Meilisearch finishes processing tasks.
4+
---
5+
6+
import { RouteHighlighter } from '/snippets/route_highlighter.mdx'
7+
8+
import CodeSamplesWebhooksGet1 from '/snippets/samples/code_samples_webhooks_get_1.mdx';
9+
import CodeSamplesWebhooksPost1 from '/snippets/samples/code_samples_webhooks_post_1.mdx';
10+
import CodeSamplesWebhooksPatch1 from '/snippets/samples/code_samples_webhooks_patch_1.mdx';
11+
import CodeSamplesWebhooksDelete1 from '/snippets/samples/code_samples_webhooks_delete_1.mdx';
12+
13+
Use the `/webhooks` to trigger automatic workflows when Meilisearch finishes processing tasks.
14+
15+
## The webhook object
16+
17+
```json
18+
{
19+
"uuid": "V4_UUID_GENERATED_BY_MEILISEARCH",
20+
"url": "WEBHOOK_NOTIFICATION_TARGET_URL",
21+
"headers": {
22+
"HEADER": "VALUE",
23+
},
24+
"isEditable": false
25+
}
26+
```
27+
28+
- `uuid`: a v4 uuid Meilisearch automatically generates when you create a new webhook
29+
- `url`: a string indication the URL Meilisearch should notify whenever it completes a task, required
30+
- `headers`: an object with HTTP headers and their values, optional, often used for authentication
31+
- `isEditable`: read-only Boolean field indicating whether you can edit the webhook. Meilisearch automatically sets this to false for its internal webhooks
32+
33+
## The webhook payload
34+
35+
When Meilisearch finishes processing a task, it sends the relevant [task object](/reference/api/tasks#task-object) to all configured webhooks.
36+
37+
## Get all webhooks
38+
39+
<RouteHighlighter method="GET" path="/healths" />
40+
41+
Get a list of all webhooks configured in the current Meilisearch instance.
42+
43+
### Example
44+
45+
<CodeSamplesWebhooksGet1 />
46+
47+
#### Response: `200 OK`
48+
49+
```json
50+
{
51+
"results": [
52+
{
53+
"uuid": "UUID_V4",
54+
"url": "WEBHOOK_TARGET_URL",
55+
"headers": {
56+
"HEADER": "VALUE",
57+
},
58+
"isEditable": false
59+
},
60+
{
61+
"uuid": "UUID_V4",
62+
"url": "WEBHOOK_TARGET_URL",
63+
"headers": null,
64+
"isEditable": true
65+
}
66+
]
67+
}
68+
```
69+
70+
## Create new webhook
71+
72+
<RouteHighlighter method="POST" path="/webhooks" />
73+
74+
Create a new webhook. When Meilisearch finishes processing a task, it sends the relevant [task object](/reference/api/tasks#task-object) to all configured webhooks.
75+
76+
### Example
77+
78+
<CodeSamplesWebhooksPost1 />
79+
80+
#### Response: `200 OK`
81+
82+
```json
83+
{
84+
"uuid": "627ea538-733d-4545-8d2d-03526eb381ce",
85+
"url": "WEBHOOK_TARGET_URL",
86+
"headers": {
87+
"authorization": "SECURITY_KEY",
88+
"referer": "https://example.com",
89+
},
90+
"isEditable": true
91+
}
92+
```
93+
94+
## Update webhook
95+
96+
<RouteHighlighter method="PATCH" path="/webhooks/{uuid}" />
97+
98+
Update the configuration for the specified webhook. To remove a field, set its value to `null`.
99+
100+
<Note>
101+
It is not possible to edit webhooks whose `isEditable` field is set to `false`.
102+
103+
Meilisearch Cloud may create internal webhooks to support features such as Analytics and monitoring. These webhooks are always `isEditable: false`.
104+
</Note>
105+
106+
### Example
107+
108+
<CodeSamplesWebhooksPatch1 />
109+
110+
#### Response: `200 OK`
111+
112+
```json
113+
{
114+
"uuid": "627ea538-733d-4545-8d2d-03526eb381ce",
115+
"url": "WEBHOOK_TARGET_URL",
116+
"headers": {
117+
"authorization": "SECURITY_KEY"
118+
},
119+
"isEditable": true
120+
}
121+
```
122+
123+
## Delete webhook
124+
125+
<RouteHighlighter method="DELETE" path="/webhooks/{uuid}" />
126+
127+
Delete a webhook and stop sending task completion data to the target URL.
128+
129+
<Note>
130+
It is not possible to delete webhooks whose `isEditable` field is set to `false`.
131+
</Note>
132+
133+
### Example
134+
135+
<CodeSamplesWebhooksDelete1 />
136+
137+
#### Response: `204 No Content`

0 commit comments

Comments
 (0)