← Blog

Claude API Webhook Event Notifications: Setup Guide

2026-11-22 · 5 min read · SubToAPI Team

If you've been searching for how to configure webhook event notifications on the Claude API, the short answer is: Anthropic's API doesn't have a native webhook system. Unlike payment processors or some batch-job APIs, Claude's Messages API is a synchronous request/response call (or a streamed response) — there's no "callback URL" field you can register, and no dashboard setting that fires a POST to your server when a generation finishes.

That doesn't mean you can't get webhook-style notifications. It means you have to build a thin layer that watches your Claude calls and dispatches events yourself. This is a common pattern and it's not hard to implement correctly — this guide covers the architecture, the events worth tracking, and working code for a webhook dispatcher you can drop into an existing integration.

Why Claude doesn't have built-in webhooks

Claude's API is designed around two response modes:

There's no job queue with a callback option like you'd see in some async APIs. So "setting up a webhook" for Claude really means wrapping your own event layer around calls you're already making, and firing HTTP callbacks to wherever you want — Slack, an internal service, a billing system, a monitoring dashboard.

The architecture: event dispatcher pattern

The cleanest approach is a small middle layer between your app and the Claude API:

  1. Your app sends a request to Claude (directly, or through a proxy like SubToAPI).
  2. A dispatcher wraps that call and emits internal events: started, streaming, completed, errored, tool-use-requested.
  3. Each event is turned into a signed HTTP POST to one or more webhook URLs you configure.
  4. A queue with retries handles delivery, so a slow or down webhook receiver doesn't block your main request path.

This keeps your application code simple — it just calls Claude — while giving downstream systems (Slack alerts, logging pipelines, support tools) a reliable notification channel.

Minimal dispatcher example

import crypto from "crypto";

const WEBHOOK_URL = process.env.WEBHOOK_URL;
const WEBHOOK_SECRET = process.env.WEBHOOK_SECRET;

async function sendWebhook(event, payload) {
  const body = JSON.stringify({ event, payload, timestamp: Date.now() });
  const signature = crypto
    .createHmac("sha256", WEBHOOK_SECRET)
    .update(body)
    .digest("hex");

  await fetch(WEBHOOK_URL, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-Signature": signature,
    },
    body,
  }).catch((err) => {
    // enqueue for retry instead of swallowing silently
    console.error("webhook delivery failed", err);
  });
}

async function callClaudeWithEvents(messages) {
  await sendWebhook("message.started", { messages });

  const res = await fetch("https://api.subtoapi.app/v1/messages", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.SUBTOAPI_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "claude-sonnet-4-5",
      max_tokens: 1024,
      messages,
    }),
  });

  const data = await res.json();

  if (!res.ok) {
    await sendWebhook("message.errored", { status: res.status, data });
    throw new Error("Claude request failed");
  }

  await sendWebhook("message.completed", {
    id: data.id,
    usage: data.usage,
    stop_reason: data.stop_reason,
  });

  return data;
}

Signing the payload with HMAC means receivers can verify the webhook actually came from your dispatcher, not from a spoofed request — treat WEBHOOK_SECRET the same way you'd treat an API key.

Events worth notifying on

Not every API call needs a webhook. Focus on events that someone actually needs to react to:

For streaming specifically, don't try to forward every SSE delta as its own webhook — that's a lot of HTTP overhead for no benefit. Buffer deltas server-side and fire one webhook per logical event (start, tool call, completion). The streaming docs cover the event types you'll be buffering.

Making delivery reliable

A webhook system is only useful if deliveries don't silently vanish. Two things matter most:

const body = JSON.stringify({
  id: crypto.randomUUID(),
  event: "message.completed",
  payload,
  timestamp: Date.now(),
});

Where this fits with usage metadata

If your main goal is notifications about spend or volume rather than individual completions, you don't need a full event bus — you can poll usage metadata on a schedule instead. SubToAPI returns per-request usage data (input/output tokens, model used) with every call through /docs/messages, which is enough to build a periodic check that fires a webhook only when a threshold is crossed, instead of on every single request.

Getting application API keys, streaming, and usage metadata set up correctly is covered in the quickstart — once requests are flowing through a single endpoint, wrapping a webhook dispatcher around them is a small addition. You can try the whole setup with a free trial, and plan details are on /pricing.

questions

Does the Claude API support native webhooks? No. Anthropic's Messages API is synchronous or streamed directly to the caller — there's no callback URL field or webhook registration in the API itself. You build notification logic as a layer on top of your own requests.

What's the simplest way to get Slack alerts on Claude errors? Wrap your API calls in a dispatcher that POSTs to a Slack incoming webhook URL whenever a request returns a non-2xx status. No queue is needed for low volume — a direct fetch call with basic retry logic is enough to start.

Can I get a webhook when token usage crosses a budget? Not natively, but you can build it: check the usage field returned with each response (or poll aggregated usage periodically) and fire a webhook whenever a configured threshold is exceeded.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →