Webhook headers
An introduction to webhook headers.
Overview
Every webhook request includes the following predefined headers:
Consuming services can use the X-Contentful-Topic header to determine the type of payload included in the webhook call without looking into it. The topics depend on various actions which are described in the concepts section.
View all X-Contentful-Topic header values
The X-Contentful-Topic header can have the following values:
ContentManagement.ContentType.createContentManagement.ContentType.saveContentManagement.ContentType.publishContentManagement.ContentType.unpublishContentManagement.ContentType.deleteContentManagement.Entry.createContentManagement.Entry.saveContentManagement.Entry.auto_saveContentManagement.Entry.archiveContentManagement.Entry.unarchiveContentManagement.Entry.publishContentManagement.Entry.unpublishContentManagement.Entry.deleteContentManagement.Asset.createContentManagement.Asset.saveContentManagement.Asset.auto_saveContentManagement.Asset.archiveContentManagement.Asset.unarchiveContentManagement.Asset.publishContentManagement.Asset.unpublishContentManagement.Asset.deleteContentManagement.Task.CreateContentManagement.Task.SaveContentManagement.Task.DeleteContentManagement.Comment.createContentManagement.Comment.saveContentManagement.Comment.deleteContentManagement.Release.createContentManagement.Release.saveContentManagement.Release.deleteContentManagement.Workflow.createContentManagement.Workflow.saveContentManagement.Workflow.completeContentManagement.TemplateInstallation.complete
Other event types:
ContentManagement.ReleaseAction.createContentManagement.ReleaseAction.executeContentManagement.ScheduledAction.createContentManagement.ScheduledAction.saveContentManagement.ScheduledAction.deleteContentManagement.BulkAction.createContentManagement.BulkAction.executeSpaceManagement.EnvironmentAlias.createSpaceManagement.EnvironmentAlias.change_targetSpaceManagement.EnvironmentAlias.deleteAppManagement.AppInstallation.createAppManagement.AppInstallation.saveAppManagement.AppInstallation.deleteAppManagement.AppActionCall.call
Contextual event headers
Additionally, extra headers may be emitted to provide context for an action, such as an entry being published by a scheduled action or as part of a release.
Consuming services can use these headers to correlate events across multiple webhook calls to group the calls into a single downstream action, such as debouncing a rebuild of a website
CRN header
When triggered by an App Action call or an App Installation, Asset, or Entry event, the X-Contentful-CRN header is included.
This header provides the Contentful Resource Name (crn), an API identifier of the entity that triggered the webhook.
Custom headers
Besides these headers, you can configure webhooks to be called with a set of additional headers of your choice. When creating or updating a webhook, you can provide a list of headers that will be included in successive calls to that webhook.
For example assume that:
- One of your entries has just been published.
- The name of your webhook is ‘Notify subscribers’.
- You have defined two custom headers,
X-Notify: subscribersandAuthentication: subscribers.
The webhook would be called with the following set of headers:
Custom headers are provided with the headers property of the Webhook Definition:
You can mark a header as secret. Value of secret headers is hidden in the web app, API responses and logs. The first time you define a secret header you need to provide its value and the secret flag set to true:
Any consecutive update can omit the value property as long as the secret is true. Previously provided value will be used in this scenario:
Header values may contain values from the original payload. See header transformations.
Header transformations
For more information on header transformations, check out the webhook transformations page.
Signed request verification headers
When you’ve configured a webhook signing secret in the webhook settings of your space, a signature will be generated for all webhook requests coming from events in that space. When a consuming service receives a request, it can compute a signature in the same way. If the secret is the same, the signatures will match too, thus verifying that the sender knows the secret. For this reason, it is also important to not share the secret with any third party.
This signature and some additional metadata is then added to the headers of the request before it is sent. The headers look like this:
Consuming services can use these headers to verify the authenticity and integrity of incoming webhooks.
See verifyRequest in node-apps-toolkit for more information.