Home
Content Management API⁡𝅶‍‍𝅺⁡‍𝅴⁡𝅴𝅹‍‍⁢𝅵‍‍⁣⁣‌⁡⁣𝅺⁣⁢⁣𝅸⁠⁢‍‍‍𝅷‍‍𝅳⁡‍⁠‍‍⁢𝅵‍‍𝅳⁡⁣⁡⁣⁡​⁡⁢⁢𝅵‍𝅺‍𝅺⁢𝅸⁡⁢‍𝅹⁣‌⁡⁣𝅺⁢𝅸⁡⁢‍𝅹⁢𝅺𝅸‍𝅺⁠⁣𝅴⁡⁣𝅺⁡‍‍𝅺𝅴⁡⁣⁠𝅸⁠𝅺⁡⁣⁡𝅴⁡​⁠⁡⁢‍𝅺⁢𝅳⁢‌⁢​⁢𝅴⁢‍⁢⁠‍𝅺𝅴⁡⁣⁠𝅸⁡⁢‍𝅺⁢⁢⁢𝅴⁢𝅳⁢⁢⁢‌⁢⁡⁢𝅳⁢‌‍‍⁡𝅸
Main resources
Upload-related
Site Search
Environments
UI
Workflows
Async jobs
Roles & permissions
Webhooks
Hosting & CI integrations
Subscription
Enterprise
    Show examples in:
    Update a webhook

    Parameters

    name  string  Optional

    Unique name for the webhook

    url  string  Optional

    The URL to be called

    custom_payload  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

    http_basic_user  string, null  Optional

    HTTP Basic Authorization username

    http_basic_password  string, null  Optional

    HTTP Basic Authorization password

    enabled  boolean  Optional

    Whether the webhook is enabled and sending events or not

    payload_api_version  string  Optional

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

    nested_items_in_payload  boolean  Optional

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

    Returns

    Returns a webhook resource object.

    Examples

    Example code:
    import { buildClient } from '@datocms/cma-client-node';
    async function run() {
    const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
    const webhookId = '312';
    const webhook = await client.webhooks.update(webhookId, {
    name: 'Item type creation/update',
    url: 'https://www.example.com/webhook',
    custom_payload: '{ message: 'Successfully published record!' }',
    headers: {
    'X-Foo': 'Bar'
    },
    events: [
    {
    entity_type: 'item_type',
    event_types: [
    'update',
    'create'
    ],
    filter: {
    entity_type: 'item_type',
    entity_ids: [
    '42',
    '43'
    ]
    }
    }
    ],
    http_basic_user: 'user',
    http_basic_password: 'password',
    enabled: true,
    payload_api_version: '3',
    nested_items_in_payload: true
    });
    console.log(webhook);
    }
    run();
    Returned output:
    {
    id: '312',
    name: 'Item type creation/update',
    enabled: true,
    url: 'https://www.example.com/webhook',
    custom_payload: '{ message: 'Successfully published record!' }',
    http_basic_user: 'user',
    http_basic_password: 'password',
    headers: {
    'X-Foo': 'Bar'
    },
    events: [
    {
    entity_type: 'item_type',
    event_types: [
    'update',
    'create'
    ],
    filter: {
    entity_type: 'item_type',
    entity_ids: [
    '42',
    '43'
    ]
    }
    }
    ],
    payload_api_version: '3',
    nested_items_in_payload: true
    }