---
description: REST and GraphQL API documentation on the Webhooks collection in Directus.
readTime: 5 min read
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.
```json
{
"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.
### Request
`GET /webhooks`
`SEARCH /webhooks`
If using SEARCH you can provide a [query object](/reference/query) as the body of your request.
[Learn more about SEARCH ->](/reference/introduction#search-http-method)
`POST /graphql/system`
```graphql
type Query {
webhooks: [directus_webhooks]
}
```
```js
import { createDirectus, rest, readWebhooks } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readWebhooks(query_object));
```
#### Query Parameters
Supports all [global query parameters](/reference/query).
### Response
An array of up to [limit](/reference/query#limit) [webhook objects](#the-webhook-object). If no items are available,
data will be an empty array.
### Example
`GET /webhooks`
`SEARCH /webhooks`
`POST /graphql/system`
```graphql
query {
webhooks {
url
method
}
}
```
```js
import { createDirectus, rest, readWebhooks } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
readWebhooks({
fields: ['*'],
})
);
```
## Retrieve a Webhook
List an existing webhook by primary key.
### Request
`GET /webhooks/:id`
`POST /graphql/system`
```graphql
type Query {
webhooks_by_id(id: ID!): directus_webhooks
}
```
```js
import { createDirectus, rest, readWebhook } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readWebhook(webhook_id, query_object));
```
### Query Parameters
Supports all [global query parameters](/reference/query).
### Returns
Returns the requested [webhook object](#the-webhook-object).
### Examples
`GET /webhooks/15`
`POST /graphql/system`
```graphql
query {
webhooks_by_id(id: 15) {
url
actions
method
}
}
```
```js
import { createDirectus, rest, readWebhook } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
readWebhook('2', {
fields: ['*'],
})
);
```
## Create a Webhook
Create a new webhook.
### Request
`POST /webhooks`
Provide a [webhook object](#the-webhook-object) as the body of your request.
`POST /graphql/system`
```graphql
type Mutation {
create_webhooks_item(data: create_directus_webhooks_input!): directus_webhooks
}
```
```js
import { createDirectus, rest, createWebhook } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createWebhook(webhook_object));
```
#### Query Parameters
Supports all [global query parameters](/reference/query).
#### Request Body
A partial [webhook object](#the-webhook-object).
`name`, `actions`, `collections`, and `url` are required.
### Response
Returns the [webhook object](#the-webhook-object) for the created webhook.
### Example
`POST /webhooks`
```json
{
"name": "Example",
"actions": ["create", "update"],
"collections": ["articles"],
"url": "https://example.com"
}
```
`POST /graphql/system`
```graphql
mutation {
create_webhooks_item(
data: { name: "Example", actions: ["create", "update"], collections: ["articles"], url: "https://example.com" }
) {
id
name
}
}
```
```js
import { createDirectus, rest, createWebhook } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
createWebhook({
name: 'Articles Activity',
method: 'POST',
collections: 'articles',
actions: ['create', 'update', 'delete'],
url: 'https://directus.example.com/articles_activity',
})
);
```
## Create Multiple Webhook
Create multiple new webhooks.
### Request
`POST /webhooks`
Provide an array of [webhook objects](#the-webhook-object) as the body of your request.
`POST /graphql/system`
```graphql
type Mutation {
create_webhooks_items(data: [create_directus_webhooks_input!]!): [directus_webhooks]
}
```
```js
import { createDirectus, rest, createWebhooks } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(createWebhooks(webhook_object_array));
```
#### Query Parameters
Supports all [global query parameters](/reference/query).
#### Request Body
An array of partial [webhook object](#the-webhook-object).
`name`, `actions`, `collections`, and `url` are required.
### Response
Returns the [webhook objects](#the-webhook-object) for the created webhooks.
### Example
`POST /webhooks`
```json
[
{
"name": "Example",
"actions": ["create", "update"],
"collections": ["articles"],
"url": "https://example.com"
},
{
"name": "Second Example",
"actions": ["delete"],
"collections": ["articles"],
"url": "https://example.com/on-delete"
}
]
```
`POST /graphql/system`
```graphql
mutation {
create_webhooks_items(
data: [
{ name: "Example", actions: ["create", "update"], collections: ["articles"], url: "https://example.com" }
{ name: "Second Example", actions: ["delete"], collections: ["articles"], url: "https://example.com/on-delete" }
]
) {
id
name
}
}
```
```js
import { createDirectus, rest, createWebhooks } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
createWebhooks([
{
name: 'Articles Activity',
method: 'POST',
collections: 'articles',
actions: ['create', 'update', 'delete'],
url: 'https://directus.example.com/articles_activity',
},
{
name: 'Author Changes',
method: 'POST',
collections: 'authors',
actions: ['update'],
url: 'https://directus.example.com/authors_changes',
},
])
);
```
## Update a Webhook
Update an existing webhook.
### Request
`PATCH /webhooks/:id`
Provide a partial [webhook object](#the-webhook-object) as the body of your request.
`POST /graphql/system`
```graphql
type Mutation {
update_webhooks_item(id: ID!, data: update_directus_webhooks_input!): directus_webhooks
}
```
```js
import { createDirectus, rest, updateWebhook } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateWebhook(webhook_id, partal_webhook_object));
```
#### Query Parameters
Supports all [global query parameters](/reference/query).
#### Request Body
A partial [webhook object](#the-webhook-object).
### Response
Returns the [webhook object](#the-webhook-object) for the updated webhook.
### Example
`PATCH /webhooks/15`
```json
{
"name": "Build Website"
}
```
`POST /graphql/system`
```graphql
mutation {
update_webhooks_item(id: 15, data: { name: "Build Website" }) {
name
}
}
```
```js
import { createDirectus, rest, updateWebhook } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
updateWebhook('6', {
actions: ['update', 'delete'],
})
);
```
## Update Multiple Webhooks
Update multiple existing webhooks.
### Request
`PATCH /webhooks`
```json
{
"keys": webhook_id_array,
"data": partial_webhook_object
}
```
`POST /graphql/system`
```graphql
type Mutation {
update_webhooks_items(ids: [ID!]!, data: update_directus_webhooks_input!): [directus_webhooks]
}
```
```js
import { createDirectus, rest, updateWebhooks } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateWebhooks(webhook_id_array, partial_webhook_object));
```
#### Query Parameters
Supports all [global query parameters](/reference/query).
#### Request Body
`keys` **Required**\
Array of primary keys of the webhooks you'd like to update.
`data` **Required**\
Any of [the webhook object](#the-webhook-object)'s properties.
### Response
Returns the [webhook objects](#the-webhook-object) for the updated webhooks.
### REST API
### Example
`PATCH /webhooks`
```json
{
"keys": [15, 41],
"data": {
"name": "Build Website"
}
}
```
`POST /graphql/system`
```graphql
mutation {
update_webhooks_items(ids: [15, 41], data: { name: "Build Website" }) {
name
}
}
```
```js
import { createDirectus, rest, updateWebhooks } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(
updateWebhooks(['5', '6'], {
status: 'inactive',
})
);
```
## Delete a Webhook
Delete an existing webhook.
### Request
`DELETE /webhooks/:id`
`POST /graphql/system`
```graphql
type Mutation {
delete_webhooks_item(id: ID!): delete_one
}
```
```js
import { createDirectus, rest, deleteWebhook } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteWebhook(webhook_id));
```
### Response
Empty body.
### Example
`DELETE /webhooks/15`
`POST /graphql/system`
```graphql
mutation {
delete_webhooks_item(id: 15) {
id
}
}
```
```js
import { createDirectus, rest, deleteWebhook } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(deleteWebhook('1'));
```
## Delete Multiple Webhooks
Delete multiple existing webhooks.
### Request
`DELETE /webhooks`
Provide an array of webhook IDs as the body of your request.
`POST /graphql/system`
```graphql
type Mutation {
delete_webhooks_items(ids: [ID!]!): delete_many
}
```
```js
import { createDirectus, rest, deleteWebhooks } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteWebhooks(webhook_id_array));
```
#### Request Body
An array of webhook primary keys
### Response
Empty body.
### Example
`DELETE /webhooks`
```json
[2, 15, 41]
```
`POST /graphql/system`
```graphql
mutation {
delete_webhooks_items(ids: [2, 15, 41]) {
ids
}
}
```
```js
import { createDirectus, rest, deleteWebhooks } from '@directus/sdk';
const client = createDirectus('https://directus.example.com').with(rest());
const result = await client.request(deleteWebhooks(['2', '3']));
```