You're reading "Content Management API"

Webhook

A webhook allows to make requests following certain Dato events. It is linked to a Role, which describes what actions can be performed.

The Webhook object

A Webhook object is returned as part of the response body of each successful Index, Show, Create, Update or Delete API call. The following table contains the list of all its fields along with their type, description and example values.

Object fields:
eventsarray

All the events you will be notified for

This attribute is required
headersobject

Additional headers that will be sent

This attribute is required
http_basic_passwordstring

HTTP Basic Authorization password

http_basic_userstring

HTTP Basic Authorization username

namestring

Unique name for the webhook

This attribute is required
urlstring

The URL to be called

This attribute is required

List all webhooks

To list all webhooks, send a GET request to the /webhooks endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/webhooks HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": [ { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "http_basic_user": "user", "http_basic_password": "password", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ] } } ] }

Retrieve a webhook

To retrieve a webhook, send a GET request to the /webhooks/:webhook_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/webhooks/:webhook_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "http_basic_user": "user", "http_basic_password": "password", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ] } } }

Create a new webhook

To create a new webhook, send a POST request to the /webhooks endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
POST https://site-api.datocms.com/webhooks HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "webhook", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ], "http_basic_user": "user", "http_basic_password": "password" } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "http_basic_user": "user", "http_basic_password": "password", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ] } } }

Update a webhook

To update a webhook, send a PUT request to the /webhooks/:webhook_id endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
PUT https://site-api.datocms.com/webhooks/:webhook_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ], "http_basic_user": "user", "http_basic_password": "password" } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "http_basic_user": "user", "http_basic_password": "password", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ] } } }

Delete a webhook

To delete a webhook, send a DELETE request to the /webhooks/:webhook_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
DELETE https://site-api.datocms.com/webhooks/:webhook_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "webhook", "id": "312", "attributes": { "name": "Item type creation/update", "url": "https://www.example.com/webhook", "http_basic_user": "user", "http_basic_password": "password", "headers": { "X-Foo": "Bar" }, "events": [ { "entity_type": "item_type", "event_types": [ "update", "create" ], "filter": { "entity_type": "item_type", "entity_ids": [ "42", "43" ] } } ] } } }