Choose your language:
    Update a webhook
    Parameters
    name  string  Optional

    Unique name for the webhook

    url  string  Optional

    The URL to be called

    customPayload  string, null  Optional

    A custom payload

    headers  object  Optional

    Additional headers that will be sent

    events  Array  Optional

    All the events you will be notified for

    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
    Returns a webhook object.

    Examples

    Example code:
    const { SiteClient } = require('datocms-client');
    async function run() {
    const client = new SiteClient('YOUR-API-TOKEN');
    const webhookId = '312';
    const webhook = await client.webhook.update(webhookId, {
    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
    });
    console.log(webhook);
    }
    run();
    Returned output:
    > 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
    }