Skip to main content
The TypeScript SDK is typed from the OpenAPI contract and ships both ESM and CommonJS. It runs anywhere fetch does: Node 18+, browsers, Deno, Bun, and Cloudflare Workers.
npm install @webhook-co/sdk

Quickstart

import { WebhookClient } from "@webhook-co/sdk";

const webhook = new WebhookClient({ apiKey: process.env.WEBHOOK_API_KEY! });

const endpoint = await webhook.endpoints.create({ name: "orders-prod" });
console.log(endpoint.ingestUrl); // returned once — capture it now

Pagination

List methods return a Paginator you can iterate directly — it follows the cursor for you:
for await (const endpoint of webhook.endpoints.list({ name: "prod" })) {
  console.log(endpoint.id);
}

// Or collect everything (careful with large result sets):
const failed = await webhook.deliveries.list({ status: ["failed"] }).collect();

// One page at a time (e.g. for your own UI):
const page = await webhook.endpoints.listPage({ limit: 50 });
console.log(page.items, page.nextCursor);

Errors

Every failure is a WebhookError subclass, so you can narrow by instanceof:
import { WebhookRateLimitError, WebhookNotFoundError } from "@webhook-co/sdk";

try {
  await webhook.endpoints.get(id);
} catch (err) {
  if (err instanceof WebhookNotFoundError) {
    // 404
  } else if (err instanceof WebhookRateLimitError) {
    console.log(`retry after ${err.retryAfterMs}ms`);
  } else {
    throw err;
  }
}
Each error carries code, status, and requestId when present.

Retries & idempotency

The client retries idempotent requests on transient failures (429/502/503/504 and network errors) with capped exponential backoff and jitter, honouring Retry-After. It never blind-retries a non-idempotent write. Replays carry an idempotency key, so those are safe to retry:
await webhook.events.replay({
  eventId: event.id,
  target: { kind: "destination", destinationId },
  idempotencyKey: crypto.randomUUID(),
});

Configuration

const webhook = new WebhookClient({
  apiKey,
  baseUrl: "https://api.webhook.co", // https-only (loopback http allowed for dev)
  maxRetries: 4, // default 2
  timeoutMs: 15_000, // default 30_000
});
Full source, changelog, and issues: github.com/webhook-co/webhook.