Show examples in:
Create a new webhook

Body Parameters

name  Required  string  Example: "Item type creation/update"

Unique name for the webhook

url  Required  string  Example: ""

The URL to be called

headers  Required  object  Example: {"X-Foo":"Bar"}

Additional headers that will be sent

events  Required  Array  Example: [{"entity_type":"item_type","event_types":["update","create"],"filter":{"entity_type":"item_type","entity_ids":["42","43"]}}]

All the events you will be notified for

custom_payload  Required  string, null  Example: "{ \"message\": \"{{event_type}} event triggered on {{entity_type}}!\", \"entity_id\": \"{{#entity}}{{id}}{{/entity}}\"] }"

A custom payload

http_basic_user  Required  string, null  Example: "user"

HTTP Basic Authorization username

http_basic_password  Required  string, null  Example: "password"

HTTP Basic Authorization password

enabled  Optional  boolean  Example: true

Whether the webhook is enabled and sending events or not

payload_api_version  Optional  string  Example: "3"

Specifies which API version to use when serializing entities in the webhook payload

nested_items_in_payload  Optional  boolean  Example: true

Whether the you want records present in the payload to show blocks expanded or not


Returns a webhook resource object.


Example Basic example
import { buildClient } from '@datocms/cma-client-node';
async function run() {
const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
const webhook = await client.webhooks.create({
name: 'Item type creation/update',
url: '',
headers: {
'X-Foo': 'Bar'
events: [
entity_type: 'item_type',
event_types: [
filter: {
entity_type: 'item_type',
entity_ids: [
custom_payload: '{ \message\: \'{{event_type}} event triggered on {{entity_type}}!\', \entity_id\: \'{{#entity}}{{id}}{{/entity}}\'] }',
http_basic_user: 'user',
http_basic_password: 'password'