4.5 KiB
pageClass
| pageClass |
|---|
| page-reference |
Webhooks
Webhooks are configured within the App (no code required) and send HTTP requests to an external service when a specific event is triggered.
The Webhook Object
id integer
Primary key of the webhook.
name string
Name for the webhook. Shown in the Admin App.
method string
HTTP method to use. One of GET, POST.
url string
Where to send the request too.
status string
Status of the webhook. One of active, inactive.
data boolean
Whether or not to send the event data to the external endpoint.
actions csv
When to fire the webhook. Can contain create, update, delete.
collections csv
What collections to fire this webhook on.
{
"data": {
"id": 1,
"name": "Build Website",
"method": "POST",
"url": "https://example.com/",
"status": "active",
"data": true,
"actions": ["create", "update"],
"collections": ["articles"]
}
}
List Webhooks
List all webhooks that exist in Directus.
Query Parameters
Supports all global query parameters.
Returns
An array of up to limit webhook objects. If no items are available, data will be an empty array.
GET /webhooks
// Response
{
"data": [
{
"id": 1,
"name": "Build Website",
"method": "POST",
"url": "https://example.com/",
"status": "active",
"data": true,
"actions": ["create", "update"],
"collections": ["articles"]
},
{...},
{...}
]
}
Retrieve a Webhook
List an existing webhook by primary key.
Query Parameters
Supports all global query parameters.
Returns
Returns the requested webhook object.
GET /webhooks/:id
// Response
{
"data": {
"id": 1,
"name": "Build Website",
"method": "POST",
"url": "https://example.com/",
"status": "active",
"data": true,
"actions": ["create", "update"],
"collections": ["articles"]
}
}
Create a Webhook
Create one or more new webhook(s).
Query Parameters
Supports all global query parameters.
Request Body
A partial webhook object or an array of partial webhook objects.
name, actions, collections, and url are required.
Returns
Returns the webhook object(s) for the created webhook(s).
POST /webhooks
// Request
{
"name": "Example",
"actions": ["create", "update"],
"collections": ["articles"],
"url": "https://example.com"
}
// Response
{
"data": {
"id": 3,
"name": "Example",
"method": "POST",
"url": "https://example.com",
"status": "active",
"data": true,
"actions": ["create", "update"],
"collections": ["articles"]
}
}
Update a Webhook
Update an existing webhook.
Query Parameters
Supports all global query parameters.
Request Body
A partial webhook object.
Returns
Returns the webhook object for the created webhook.
PATCH /webhooks/:id
// Request
{
"name": "Build Website"
}
// Response
{
"data": {
"id": 3,
"name": "Build Website",
"method": "POST",
"url": "https://example.com",
"status": "active",
"data": true,
"actions": ["create", "update"],
"collections": ["articles"]
}
}
Delete a Webhook
Delete an existing webhook.
Returns
Empty body.
DELETE /webhooks/:id
// Empty Response
Delete Multiple Webhooks
Delete multiple existing webhooks.
Request Body
An array of webhook primary keys
Returns
Empty body.
DELETE /webhooks
// Request
[2, 15, 41]
// Empty Response