Show examples in:
List all webhooks calls

Query parameters

page  Optional  object

Parameters to control offset-based pagination

filter  Optional  object

Attributes to filter

order_by  Optional  enum  Example: "name_DESC"

Fields used to order results

Returns

Returns an array of webhook_call resource objects.

Examples

Example List all calls
import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const webhookCalls = await client.webhookCalls.list();
console.log(webhookCalls);
}
run();
Example Filter webhook calls by environment

The webhookCalls.list() method does NOT support serverside filtering.

If you wish to filter the calls by some payload attribute, you must fetch them from the server and then filter them clientside, after decoding their request_payload fields with JSON.parse().

This example shows how to filter the calls by their environment names.

import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
// Which environment to look for
const environmentNameToFilterBy = "main";
// Because we can't filter serverside, we'll have to fetch all the calls and then deal with them clientside
const iterator = await client.webhookCalls.listPagedIterator();
// Empty array will be filled by the iterator
let filteredWebhookCalls = [];
// Go through the async iterable one at a time
for await (const call of iterator) {
// Parse the stringified webhook payload
const payload = JSON.parse(call.request_payload);
// Only push to the array if the environment matches
const environment = payload.environment;
if (environment === environmentNameToFilterBy) {
filteredWebhookCalls.push(call);
}
}
console.log(filteredWebhookCalls);
}
run();