Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Webhook

Update a webhook

Body parameters

namestringOptional

Unique name for the webhook

Example:"Item type creation/update"
urlstringOptional

The URL to be called

Example:"https://www.example.com/webhook"
custom_payloadstring, nullOptional

A custom payload

Example:'{ "message": "{{event_type}} event triggered on {{entity_type}}!", "entity_id": "{{#entity}}{{id}}{{/entity}}"] }'
headersobjectOptional

Additional headers that will be sent

Example:{ "X-Foo": "Bar" }
eventsOptional
Type:Array<object>
entity_typeenumRequired

The subject of webhook triggering

Example:"item"
item_typeOptional
itemOptional
uploadOptional
build_triggerOptional
environmentOptional
maintenance_modeOptional
sso_userOptional
cda_cache_tagsOptional
event_typesRequired
Type:Array<string>
filtersOptional
Type:Array<object>, null
entity_typeenumRequired
item_typeOptional
itemOptional
build_triggerOptional
environmentOptional
environment_typeOptional
entity_idsRequired
Type:Array<string>
http_basic_userstring, nullOptional

HTTP Basic Authorization username

Example:"user"
http_basic_passwordstring, nullOptional

HTTP Basic Authorization password. It is null when the webhook has no basic auth, or when the credentials you are using cannot manage the webhooks of the project.

Example:"password"
enabledbooleanOptional

Whether the webhook is enabled and sending events or not

payload_api_versionstringOptional

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

Example:"3"
nested_items_in_payloadbooleanOptional

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

auto_retrybooleanOptional

If enabled, the system will attempt to retry the call several times when the webhook operation fails due to timeouts or errors.

Returns

Returns a resource object of type webhook

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const webhookId = "312";
const webhook = await client.webhooks.update(webhookId, { id: "312" });
// Check the 'Returned output' tab for the result ☝️
console.log(webhook);
}
run();
{
id: "312",
name: "Item type creation/update",
url: "https://www.example.com/webhook",
enabled: true,
headers: { "X-Foo": "Bar" },
events: [{ entity_type: "item", event_types: ["update"] }],
http_basic_user: "user",
http_basic_password: "password",
custom_payload: '{ "message": "{{event_type}} event triggered on {{entity_type}}!", "entity_id": "{{#entity}}{{id}}{{/entity}}"] }',
payload_api_version: "3",
nested_items_in_payload: true,
auto_retry: true,
}