New webhooks
Is this page helpful?
https://example.com/cache-invalidate
.X-Kontent-ai-Signature
HTTP header with a checksum of the JSON payload. You can use the header’s value to verify the authenticity of the notification. This way, you can check that the notification came from Kontent.ai, not someone else.
The signature is a base64 encoded hash generated using an HMAC-SHA-256 with the webhook’s secret key.
To verify the received notification, use the JSON payload (the raw body of the notification as-is) and the generated webhook Secret as the secret for the HMAC function. The secret is unique for each webhook. Once you generate a hash, compare the hash value with the X-Kontent-ai-Signature
header value.
object_type: asset
and action: changed
) occurs when:
object_type: asset
and action: deleted
) occurs when someone deletes an unused asset. This means the asset wasn’t used in any content item or guidelines.object_type: content_type
and action: changed
) occurs when:
object_type: content_type
and action: deleted
) occurs when someone deletes an unused content type. This means the type wasn’t used for any content item or component.data
object – tells you what data in your environment was affected. That is metadata information of the affected object, such as asset or content type.message
object – tells you what event occurred, whether the event occurred in preview or published data, and in which environment.data
object identifies a specific object in your environment. Use the information to retrieve the updated object via APIs.
id
(string): The object’s internal ID.name
(string): The object’s display name.codename
(string): The object’s codename.last_modified
(string): ISO-8601 formatted UTC time and date, for example, YYYY-MM-DDTHH:MM:SSZ
, of the last time the object was modified.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. For example, asset
or content_type
.action
(string): Specifies what happened to the object. For example, changed
if the object was created or modified, or deleted
if the object was deleted.delivery_slot
(string): Specifies whether the change occurred in preview data or published data.{
"notifications": [
{
"data": {
"system": {
"id": "b7aa4a53-d9b1-48cf-b7a6-ed0b182c4b89",
"name": "Article",
"codename": "article",
"last_modified": "2023-08-11T08:46:58.0234716Z"
}
},
"message": {
"environment_id": "dcee574e-6134-00b9-4b79-054d20a0f04f",
"object_type": "content_type",
"action": "changed",
"delivery_slot": "preview"
}
}
]
}
notification
array in the JSON payload contains a single object. This will change soon.
We’re working on batching notifications related to a single event into a single JSON payload. For example, this is useful when one event, such as a taxonomy update, affects a lot of assets or content items.// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { signatureHelper } from '@kontent-ai/webhook-helper';
// Example of generating the hash to verify the notification
const isValidSignature = (req, secret) => {
return signatureHelper.isValidSignatureFromString(
req.body, // Use raw body data from the request, i.e., by using body-parser
secret,
req.headers['x-kc-signature']
);
};