Unique name for the webhook
The URL to be called
Additional headers that will be sent
All the events you will be notified for
A custom payload
HTTP Basic Authorization username
HTTP Basic Authorization password
Whether the webhook is enabled and sending events or not
Specifies which API version to use when serializing entities in the webhook payload
Whether the you want records present in the payload to show blocks expanded or not
const SiteClient = require('datocms-client').SiteClient;const client = new SiteClient('YOUR-API-TOKEN');client.webhook.create({name: 'Item type creation/update',url: 'https://www.example.com/webhook',customPayload: '{ message: 'Successfully published record!' }',headers: {xFoo: 'Bar'},events: [{entityType: 'item_type',eventTypes: ['update','create'],filter: {entityType: 'item_type',entityIds: ['42','43']}}],httpBasicUser: 'user',httpBasicPassword: 'password',enabled: true,payloadApiVersion: '3',nestedItemsInPayload: true}).then((webhook) => {console.log(webhook);}).catch((error) => {console.error(error);});
> node example.js{"id": "312","name": "Item type creation/update","enabled": true,"url": "https://www.example.com/webhook","customPayload": "{ message: 'Successfully published record!' }","httpBasicUser": "user","httpBasicPassword": "password","headers": {"xFoo": "Bar"},"events": [{"entityType": "item_type","eventTypes": ["update","create"],"filter": {"entityType": "item_type","entityIds": ["42","43"]}}],"payloadApiVersion": "3","nestedItemsInPayload": true}