Choose your language:
    Create a new webhook
    name  string  Optional

    Unique name for the webhook

    url  string  Optional

    The URL to be called

    headers  object  Optional

    Additional headers that will be sent

    events  Array  Optional

    All the events you will be notified for

    customPayload  string, null  Optional

    A custom payload

    httpBasicUser  string, null  Optional

    HTTP Basic Authorization username

    httpBasicPassword  string, null  Optional

    HTTP Basic Authorization password

    enabled  boolean  Optional

    Whether the webhook is enabled and sending events or not

    payloadApiVersion  string  Optional

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

    nestedItemsInPayload  boolean  Optional

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

    Returns a webhook object.


    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    name: 'Item type creation/update',
    url: '',
    customPayload: '{ message: 'Successfully published record!' }',
    headers: {
    xFoo: 'Bar'
    events: [
    entityType: 'item_type',
    eventTypes: [
    filter: {
    entityType: 'item_type',
    entityIds: [
    httpBasicUser: 'user',
    httpBasicPassword: 'password',
    enabled: true,
    payloadApiVersion: '3',
    nestedItemsInPayload: true
    .then((webhook) => {
    .catch((error) => {
    Returned output:
    > node example.js
    "id": "312",
    "name": "Item type creation/update",
    "enabled": true,
    "url": "",
    "customPayload": "{ message: 'Successfully published record!' }",
    "httpBasicUser": "user",
    "httpBasicPassword": "password",
    "headers": {
    "xFoo": "Bar"
    "events": [
    "entityType": "item_type",
    "eventTypes": [
    "filter": {
    "entityType": "item_type",
    "entityIds": [
    "payloadApiVersion": "3",
    "nestedItemsInPayload": true