Webhooks
Is this page helpful?
X-Kontent-ai-Signature
HTTP header. This reserved header contains a checksum of the webhook payload. Specifically, the X-Kontent-ai-Signature
value is a base64-encoded hash generated using an HMAC-SHA-256 with the webhook’s secret key.
You can find the webhook's Secret key in Kontent.ai > Environment settings > Webhooks > Your webhook > Settings > Secret. The secret is unique for each webhook.
To verify the received notification, use the raw JSON body of the webhook payload and the generated webhook Secret as the secret for the HMAC function. Once you generate a hash, compare the hash value with the X-Kontent-ai-Signature
header value.
X-KC-Wait-For-Loading-New-Content
header set to true
. The header tells the API to wait while fetching content if the requested content has changed since the last request.
data
object contains metadata information that identifies a specific object in your environment. This object can be an asset, content item, content type, language, or taxonomy group.
For all object types, the data
object specifies the id
, name
, codename
, and last_modified
properties of the modified object. For content items, there's additional information about the item.
id
(string): The object’s internal ID.name
(string): The object’s display name.codename
(string): The object’s codename.collection
(string): The codename of the content item's collection.workflow
(string): The codename of the content item's workflow.workflow_step
(string): The codename of the content item's workflow step.language
(string): The codename of the content item's language. type
(string): The codename of the content item's content type.last_modified
(string): The object's last modification date and time in ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ
) in UTC.data
object to retrieve the updated object via APIs.
message
object gives you context for the change. It tells you where the change occurred and due to which event. An event is a combination of an action
performed on an object
.
environment_id
(string): The environment’s internal ID.object_type
(string): Identifies the type of the object that was affected.action
(string): Specifies what happened to the object.delivery_slot
(string): Specifies whether the change occurred in preview data or published data.message
object to filter webhook notifications in your apps.
key: value
pairs where the key
is case insensitive and the value
can be case sensitive depending on the header.
host
(string): The URL to which the webhook notification was sent.content-length
(integer): The size of the payload body in bytes.x-kontent-ai-signature
(string): The checksum of the payload body. Use it to verify notification authenticity.request-context
(string): The internal context of the webhook notification.request-id
(string): The internal identifier of the webhook notification.traceparent
(string): The internal trace information of the webhook notification.content-type
(string): The media type of the webhook payload. Kontent.ai webhook notifications come with the content-type
header set to application/json; charset=utf-8
.x-kontent-ai
prefix.a
-z
, A
-Z
, and 0
-9
) and the special characters -
and _
.a
-z
, A
-Z
, and 0
-9
) and the following special characters: _ :;.,\/"'?!(){}[]@<>=-+*#$&`|~^%
.reusedKey: value1, value2, value3
.
Event | Occurs when | object_type | action |
Asset created | Creating an asset | asset | created |
Asset updated | Replacing the asset’s binary file | asset | changed |
Asset deleted | Deleting an unused asset | asset | deleted |
Asset metadata changed |
| asset | metadata_changed |
Event | Occurs when | object_type | action |
Content item metadata changed |
| content_item | metadata_changed |
Content item variant published | Publishing a content item variant | content_item | published |
Content item variant unpublished | Unpublishing a content item variant | content_item | unpublished |
Event | Occurs when | object_type | action |
Content item metadata changed |
| content_item | metadata_changed |
Content item variant created | Creating a content item | content_item | created |
Content item variant updated | Changing a content item variant's content | content_item | changed |
Content item variant deleted | Deleting a content item variant | content_item | deleted |
Workflow step changed to | Moving a content item to a specific workflow step | content_item | workflow_step_changed |
Event | Occurs when | object_type | action |
Content type created | Creating a content type | content_type | created |
Content type updated | content_type | changed | |
Content type deleted | Deleting an unused content type | content_type | deleted |
Event | Occurs when | object_type | action |
Language created | Creating or activating a language | language | created |
Language updated |
| language | changed |
Language deleted | Deactivating a language | language | deleted |
Event | Occurs when | object_type | action |
Taxonomy group created | Creating a taxonomy group | taxonomy | created |
Taxonomy group metadata changed |
| taxonomy | metadata_changed |
Taxonomy group deleted | Deleting a taxonomy group | taxonomy | deleted |
Taxonomy term created | Creating a taxonomy term | taxonomy | term_created |
Taxonomy term changed |
| taxonomy | term_changed |
Taxonomy term deleted | Deleting a taxonomy term | taxonomy | term_deleted |
Taxonomy terms moved | Reordering taxonomy terms in a taxonomy group | taxonomy | terms_moved |
20X
. These webhook notifications are still being sent based on the retry policy. If you’ve issued a fix and want to reset the retry policy, you can reset the webhook.{
"notifications": [
{
"data": {
"system": {
"id": "32022d85-ee58-4655-9016-e130c375820a",
"name": "This changes everything!",
"codename": "this_changes_everything",
"collection": "marketing",
"workflow": "default",
"workflow_step": "published",
"language": "english",
"type": "product_update",
"last_modified": "2024-01-08T13:54:54.3153716Z"
}
},
"message": {
"environment_id": "5f313984-9216-0158-9068-1d194f578bce",
"object_type": "content_item",
"action": "published",
"delivery_slot": "published"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "f24e4721-f081-50ef-9a47-2ebd45b0c915",
"name": "sofia-patel.jpg",
"codename": "sofia_patel_jpg",
"last_modified": "2024-02-15T13:10:36.8256346Z",
"collection": "default"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "asset",
"action": "metadata_changed",
"delivery_slot": "preview"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "ad2db98c-f4fe-5ce7-bd99-488b6b61d280",
"name": "Solutions",
"codename": "solutions_imaging",
"collection": "ficto_imaging",
"workflow": "default",
"workflow_step": "published",
"language": "default",
"type": "navigation_item",
"last_modified": "2023-09-12T15:24:05.8881433Z"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "content_item",
"action": "unpublished",
"delivery_slot": "published"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "ad2db98c-f4fe-5ce7-bd99-488b6b61d280",
"name": "Solutions",
"codename": "solutions_imaging",
"collection": "ficto_imaging",
"workflow": "default",
"workflow_step": "archived",
"language": "default",
"type": "navigation_item",
"last_modified": "2023-09-12T15:24:05.8881433Z"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "content_item",
"action": "workflow_step_changed",
"delivery_slot": "preview"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "121d16aa-de4b-454f-9174-e26f25f1d860",
"name": "💡 Page",
"codename": "page",
"last_modified": "2024-02-15T13:17:12.6761225Z"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "content_type",
"action": "changed",
"delivery_slot": "preview"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "b25ecaa3-a356-4d8e-9d86-46ce295cbf22",
"name": "Spanish",
"codename": "es-ES",
"last_modified": "2024-02-15T13:21:42.1300774Z"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "language",
"action": "deleted",
"delivery_slot": "published"
}
}
]
}
{
"notifications": [
{
"data": {
"system": {
"id": "0308d684-96c6-4896-8784-c8590608c672",
"name": "Handheld",
"codename": "handheld",
"last_modified": "2024-02-15T13:23:29.3147543Z",
"taxonomy_group": "product_category"
}
},
"message": {
"environment_id": "195a50c1-f1b8-0066-9eb4-83f7246d5459",
"object_type": "taxonomy",
"action": "term_created",
"delivery_slot": "published"
}
}
]
}
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using System;
using System.Security.Cryptography;
using System.Text;
// Generates a payload hash to compare with the 'X-Kontent-ai-Signature' header value
private static string GenerateHash(string message, string secret)
{
secret = secret ?? "";
UTF8Encoding SafeUTF8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
byte[] keyBytes = SafeUTF8.GetBytes(secret);
byte[] messageBytes = SafeUTF8.GetBytes(message);
using (HMACSHA256 hmacsha256 = new HMACSHA256(keyBytes))
{
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
return Convert.ToBase64String(hashmessage);
}
}
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
// Initializes a client that retrieves the latest version of published content
IDeliveryClient client = DeliveryClientBuilder
.WithOptions(builder => builder
.WithProjectId("<YOUR_ENVIRONMENT_ID>")
.UseProductionApi
.WaitForLoadingNewContent
.Build())
.Build();
// Gets a content item
// Tip: Create strongly typed models according to https://kontent.ai/learn/net-strong-types
IDeliveryItemResponse<Article> response = await client.GetItemAsync<Article>("my_article");
Article item = response.Item;
last_modified
property.