Webhooks

Webhooks extend the integration possibilities by notifying you, another person or system when content (assets, entries or content types) have changed by calling a pre-configured HTTP endpoint.

Whenever a matching event occurs, a webhook calls a specified URI to react. For example, every time a user edits an entry, sending a push notification or message to a Slack channel.

Create and configure a webhook

With the web app

In the top navigation bar, open SettingsWebhooks. Click Add webhook, configure the remote host, and click Save.

Creating a new webhook

Creating a new webhook

You can configure the events that trigger a webhook at the bottom of the screen.

Configure triggering events

Select what events trigger the webhook

Note: The "Save" webhook is triggered when the entry (or an asset) has been saved with an API call, and "Autosave" is triggered when it's autosaved in the UI.

With the API

Create a webhook by sending the settings for the webhook in a body with your API call, for example, the following:

1
2
3
4
curl -X POST "https://api.contentful.com/spaces/<SPACE_ID>/webhook_definitions"
  -d '{"url": "<URL>", "name": "foo", "topics": ["*.*"]}'
  -H 'Authorization: Bearer <API_KEY>'
  -H 'Content-Type: application/vnd.contentful.management.v1+json'

Will create a new webhook in the specified space with a url, name, and topics which match the configuration options mentioned above.

topics takes the form of comma separated Type and Action pairs, with * covering all actions, including any future actions Contentful introduces. For example, ContentType.create would trigger when someone creates a new content type, and ContentType.* would trigger for any of the five current actions.

Find more details on creating a webhook with the API in our reference docs.

List webhooks in a space

With the web app

The Webhooks overview screen shows a list of the most recent webhook calls made, their status, possible errors, and the target URL.

Overview of webhooks

With the API

To list all webhooks in a space, use the following endpoint:

1
2
3
curl -X GET "https://api.contentful.com/spaces/<SPACE_ID>/webhook_definitions"
-H "Authorization: Bearer <API_KEY>"
-H "Content-Type: application/vnd.contentful.management.v1+json"

Find more details on listing the webhooks in a space with the API in our reference docs.

Activity log of a call

With the web app

Click the View details link of any webhook in the overview screen to get a detailed activity log, including the JSON and remote server response.

Activity log for webhooks

Detailed activity log of a webhook

With the API

The following endpoint will return the status of recent calls made by a webhook and any errors.

1
2
3
curl -X GET "https://api.contentful.com/spaces/<SPACE_ID>/webhooks/<WEBHOOK_ID>/calls"
-H "Authorization: Bearer <API_KEY>"
-H "Content-Type: application/vnd.contentful.management.v1+json"

Find more details on getting the activity log of a webhook with the API in our reference docs.

Next steps

For more details on using webhooks with our API including deleting and updating, read our API guide.