Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.snackbase.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Webhooks service allows you to create, manage, and monitor outbound webhooks that send HTTP notifications to external services when data changes.

Overview

import { SnackBaseClient } from "@snackbase/sdk";

const client = new SnackBaseClient({
  baseUrl: "https://api.example.com",
});

// Access the webhooks service
const webhooks = client.webhooks;

List Webhooks

const result = await client.webhooks.list();
// result.items - array of webhooks
// result.total - total count
With pagination:
const result = await client.webhooks.list({
  limit: 20,
  offset: 0,
});

Get a Webhook

const webhook = await client.webhooks.get("webhook-id");

Create a Webhook

const webhook = await client.webhooks.create({
  url: "https://your-server.com/webhook",
  collection: "orders",
  events: ["create", "update"],
  headers: {
    "X-Custom-Header": "value",
  },
});

// IMPORTANT: Save the secret - it's only returned on creation
console.log(webhook.secret);
The secret field is only included in the response when creating a webhook. Store it securely for signature verification.

Update a Webhook

const updated = await client.webhooks.update("webhook-id", {
  url: "https://new-server.com/webhook",
  events: ["create", "update", "delete"],
  enabled: true,
});

Delete a Webhook

await client.webhooks.delete("webhook-id");

Test a Webhook

Send a test payload to verify your webhook endpoint:
const result = await client.webhooks.test("webhook-id");

console.log(result.success); // boolean
console.log(result.status_code); // HTTP status code
console.log(result.response_body); // response body (truncated)
console.log(result.error); // error message if failed

List Deliveries

View the delivery history for a webhook:
const deliveries = await client.webhooks.listDeliveries("webhook-id", {
  limit: 50,
  offset: 0,
});

for (const delivery of deliveries.items) {
  console.log(delivery.event); // "records.create"
  console.log(delivery.status); // "delivered", "failed", "retrying", "pending"
  console.log(delivery.response_status); // 200
  console.log(delivery.attempt_number); // 1
}