Webhooks Overview

You can listen to events using webhooks, SQS or SNS. When setting up a webhook you can specify the exact events you want to receive, or select to receive all events.

To ensure that a webhook is triggered by Stream you can verify it's signature. Webhook retries are in place. If you want to ensure an outage in your API never loses an event, it's better to use SQS or SNS for reliability.

Quick Start

Here's how to quickly set up webhooks using the event_hooks configuration:

Subscribe to Specific Events

// Subscribe to message.new and message.updated events only
await client.updateAppSettings({
  event_hooks: [
    {
      enabled: true,
      hook_type: "webhook",
      webhook_url: "https://example.com/webhooks/stream/messages",
      event_types: ["message.new", "message.updated"],
    },
  ],
});

Subscribe to All Events

Use an empty event_types array to receive all existing and future events:

// Subscribe to all events (empty array = all events)
await client.updateAppSettings({
  event_hooks: [
    {
      enabled: true,
      hook_type: "webhook",
      webhook_url: "https://example.com/webhooks/stream/all",
      event_types: [], // empty array = all events
    },
  ],
});

For reliable event delivery, you can also configure SQS or SNS instead of webhooks.

Debugging webhook requests with NGROK

The easiest way to debug webhooks is with NGROK.

  1. Start NGROK
brew install ngrok
ngrok http 8000
  1. Update your webhook URL to the NGROK url

  2. Trigger a webhook

  3. Open up the ngrok inspector

http://127.0.0.1:4040/inspect/http

Handling the webhook

Your endpoint should accept POST requests with JSON, return a 2xx response on success, be idempotent (Stream retries on network or 5xx errors), and run over HTTPS with Keep-Alive enabled.

To verify and parse the event, call verifyAndParseWebhook on your chat client. It transparently decompresses the body when Payload Compression is on (detected from the body bytes, so it works behind middleware that auto-decompresses the request) and verifies the HMAC X-Signature header against the API secret the client was constructed with. Every SDK returns a typed event object — unknown event types fall back to an UnknownEvent shape so your handler keeps working when Stream introduces new ones.

Every failure mode — signature mismatch, gzip decompression failure, base64 decode failure, JSON parse failure — raises a single, language-idiomatic webhook error so you only need one catch arm. The message text identifies which mode fired, so callers that want to differentiate (security logging, retry policy) can filter on it:

LanguageError classFailure-mode messages
JavaScriptInvalidWebhookErrorsignature mismatch, invalid base64 encoding, gzip decompression failed, invalid JSON payload
PythonInvalidWebhookErrorsame
RubyStreamChat::InvalidWebhookErrorsame
PHPInvalidWebhookErrorsame (InvalidWebhookError::SIGNATURE_MISMATCH etc.)
Gosentinel stream.ErrInvalidWebhooksame prefixes; use errors.Is(err, stream.ErrInvalidWebhook) for the unified check
JavaInvalidWebhookErrorsame (InvalidWebhookError.SIGNATURE_MISMATCH etc.)
.NET (C#)InvalidWebhookErrorsame (InvalidWebhookError.SignatureMismatch etc.)

Pass the raw body bytes and the X-Signature header value. The client already knows your API secret, so the call stays a two-argument one-liner.

// rawBody is the request body as Buffer or string (NOT a parsed JSON object).
// signature is the value of the x-signature header.
// Returns the parsed event object. Throws InvalidWebhookError on any failure.
try {
  const event = client.verifyAndParseWebhook(
    req.rawBody,
    req.headers["x-signature"],
  );
  // event.type, event.message, event.user, ...
} catch (err) {
  // err instanceof InvalidWebhookError; err.message identifies the mode
}

Where each argument comes from

ArgumentSourceExample
body / rawBodyRaw HTTP request body bytes (not a parsed JSON object)req.rawBody, request.body, request.data, r.Body (drained)
signatureX-Signature request headerreq.headers["x-signature"]

The API secret comes from the client you constructed at startup (new StreamChat(apiKey, apiSecret) and friends), so it's never passed into the helper.

Pass the raw body bytes, before any JSON parsing or string normalization — the helper hashes them as-is. In Express, enable express.raw({ type: 'application/json' }); in Django use request.body; in Flask use request.data; in Go drain r.Body once and reuse the bytes. If your framework hands you a parsed object, the signature check fails.

No client handy? Every SDK also ships the same logic as a stateless static / module-level helper that takes the API secret as an explicit third argument. The instance method is a thin wrapper around it, so the two forms behave identically — pick whichever fits the call site (Lambdas, edge functions, queue consumers, tests).

// JavaScript (getstream-node)
import { Webhook } from "@getstream/node";
const event = Webhook.verifyAndParseWebhook(rawBody, signature, secret);
# Python (getstream)
from getstream import webhook
event = webhook.verify_and_parse_webhook(body, signature, secret)
# Ruby (getstream_ruby) — static helper exposed under the StreamChat::Webhook module
event = StreamChat::Webhook.verify_and_parse_webhook(body, signature, secret)
// PHP (getstream-php)
$event = \GetStream\Webhook::verifyAndParseWebhook($body, $signature, $secret);
// Go (getstream-go)
event, err := getstream.VerifyAndParseWebhook(body, signature, secret)
// C# (getstream-dotnet)
var ev = GetStream.Webhook.VerifyAndParseWebhook(body, signature, secret);
// Java (getstream-java)
var event = io.getstream.Webhook.verifyAndParseWebhook(body, signature, secret);

The same dual-API surface exists on the legacy stream-chat-* SDKs (e.g. import { verifyAndParseWebhook } from "stream-chat", \GetStream\StreamChat\Webhook::verifyAndParseWebhook, stream_chat.webhook.verify_and_parse_webhook).

Return type on legacy stream-chat-* SDKs. stream-chat-go, stream-chat-js, stream-chat-java, and stream-chat-net return typed event objects; stream-chat-python, stream-chat-ruby, and stream-chat-php return parsed JSON (dict / Hash / array) until typed events ship in those SDKs. The older verifyWebhook / verify_webhook_signature helpers still work for plain (uncompressed) bodies and are now also exposed under the name verifySignature; to support compressed payloads switch to verifyAndParseWebhook or call verifySignature(gunzipPayload(body), …) yourself.

Building this without a Stream SDK? Expand the per-language reference implementation below — language tabs cover JavaScript, Python, Ruby, PHP, Go, Java, and C#.

All webhook requests contain these headers:

NameDescriptionExample
X-Webhook-IdUnique ID of the webhook call. This value is consistent between retries and could be used to deduplicate retry calls123e4567-e89b-12d3-a456-426614174000
X-Webhook-AttemptNumber of webhook request attempt starting from 11
X-Api-KeyYour application’s API key. Should be used to validate request signaturea1b23cdefgh4
X-SignatureHMAC signature of the request body. See Signature sectionca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb

Payload Compression

Enable gzip compression for hook payloads from the Dashboard or with enable_hook_payload_compression. Compressed payloads are typically 70–90% smaller and the decompression cost is negligible. HTTP webhooks get a Content-Encoding: gzip header; SQS and SNS messages are gzipped and base64-wrapped (because both transports are UTF-8 only). The verifyAndParseWebhook helper (HTTP) and parseSqs / parseSns (SQS/SNS, no app-level HMAC) detect the encoding from the body bytes, so the same handler code works whether or not compression is on — and stays correct even when middleware (Rails, Django, Laravel, Phoenix) auto-decompresses the request.

Apps created after May 7, 2026 have enable_hook_payload_compression set to true by default — your handlers will receive compressed payloads out of the box, so make sure they call verifyAndParseWebhook on HTTP traffic and parse_sqs / parse_sns on queue/topic deliveries (or equivalent decode + parse_event primitives) before going live. Apps created before that date stay opt-in; run the snippet below to turn compression on.

Enabling compression

await client.updateAppSettings({
  enable_hook_payload_compression: true,
});

The flag applies to every transport: HTTP webhooks, SQS, SNS, the Before Message Send hook, and the event failover hook.

Before enabling compression in production

  • Use a current SDKverifyAndParseWebhook for HTTP (decompress + verify_signature + typed event) and parse_sqs / parse_sns for SQS/SNS (decode + typed event, no app-level HMAC). All three handle uncompressed, gzipped, and base64+gzipped payloads without caller-side branching.
  • Without an SDK, your handler must accept Content-Encoding: gzip and gzip-decompress the body; for SQS/SNS, base64-decode then gzip-decompress (or detect via the gzip magic bytes 1f 8b, per RFC 1952).
  • Verify HMAC on the uncompressed bytes — never on the gzipped or base64-wrapped envelope.
  • Small payloads stay uncompressed to avoid envelope overhead, even with the flag on. The composite helpers handle both cases transparently.

Webhook types

In addition to the above there are 3 special webhooks.

TypeDescription
PushPush webhook is useful for triggering push notifications on your end
Before Message SendAllows you to modify or moderate message content before sending it to the chat for everyone to see
Custom CommandsReacts to custom /slash commands

Configuration

Before Message Send and Custom Commands

These webhooks continue to use the original configuration method and are NOT part of the multi-event hooks system:

  • Before Message Send: before_message_send_hook_url
  • Custom Commands: custom_action_handler_url
await client.updateAppSettings({
  before_message_send_hook_url:
    "https://example.com/webhooks/stream/before-message-send", // sets Before Message Send webhook address
  custom_action_handler_url:
    "https://example.com/webhooks/stream/custom-commands?type={type}", // sets Custom Commands webhook address
});

Push webhook

The example below shows how to use the push webhooks

// Note: Any previously existing hooks not included in event_hooks array will be deleted.
// Get current settings first to preserve your existing configuration.

// STEP 1: Get current app settings to preserve existing hooks
const response = await client.getAppSettings();
console.log("Current event hooks:", response.event_hooks);

// STEP 2: Add webhook hook while preserving existing hooks
const existingHooks = response.event_hooks || [];
const newWebhookHook = {
  enabled: true,
  hook_type: "webhook",
  webhook_url: "https://example.com/webhooks/stream/push",
  event_types: [], // empty array = all events
};

// STEP 3: Update with complete array including existing hooks
await client.updateAppSettings({
  event_hooks: [...existingHooks, newWebhookHook],
});

// Test the webhook connection
await client.testWebhookSettings({
  webhook_url: "https://example.com/webhooks/stream/push",
});

You can also configure specific event types by providing an array of event names instead of an empty array:

// Configure webhook for specific events only
const newWebhookHook = {
  enabled: true,
  hook_type: "webhook",
  webhook_url: "https://example.com/webhooks/stream/messages",
  event_types: ["message.new", "message.updated", "message.deleted"], // specific events
};

await client.updateAppSettings({
  event_hooks: [newWebhookHook],
});

Request info

Some webhooks contain a field request_info , which holds information about the client that issued the request. This info is intended as an additional signal that you can use for moderation, fraud detection, or other similar purposes.

When configuring the SDK, you may also set an additional x-stream-ext header to be sent with each request. The value of this header is passed along as an ext field in the request_info . You can use this to pass along information that may be useful, such as device information. Refer to the SDK-specific docs on how to set this header.

"request_info": {
 "type": "client",
 "ip": "86.84.2.2",
 "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0",
 "sdk": "stream-chat-react-10.11.0-stream-chat-javascript-client-browser-8.12.1",
 "ext": "device-id=123"
}

For example, in Javascript, you can set the value like this:

client = new StreamChat(apiKey, {
  axiosRequestConfig: {
    headers: {
      "x-stream-ext": "device-id=123",
    },
  },
});

The format of the ext header is up to you and you may leave it blank if you don't need it. The value is passed as-is, so you can use a simple value, comma-separated key-values, or more structured data, such as JSON. Binary data must be encoded as a string, for example using base64 or hex encoding.

Pending Message Options

You can configure pending message hooks to handle messages that require approval before being sent. The following options are available:

OptionTypeDescriptionRequired
webhook_urlstringThe URL where pending message events will be sentYes, except for CALLBACK_MODE_NONE
timeout_msnumberHow long messages should stay pending before being deleted in millisecondsYes
callback.modestringCallback mode ("CALLBACK_MODE_NONE", "CALLBACK_MODE_REST")Yes

You may set up to two pending message hooks per application. Only the first commit to a pending message will succeed; any subsequent commit attempts will return an error, as the message is no longer pending. If multiple hooks specify a timeout_ms, the system will use the longest timeout value.

For more information on configuring pending messages, please refer to the Pending Messages documentation.

Restricting access to webhook

If necessary, you can only expose your webhook service to Stream. This is possible by configuring your network (eg. iptables rules) to drop all incoming traffic that is not coming from our API infrastructure.

Below you can find the complete list of egress IP addresses that our webhook infrastructure uses. Such list is static and is not changing over time.

US-EastZONE IDeip
Primaryuse1-az234.225.10.29/32
Secondaryuse1-az434.198.125.61/32
Tertiaryuse1-az352.22.78.160/32
Quaternaryuse1-az63.215.161.238/32
EU-westZONE IDeip
Primaryeuw1-az352.212.14.212/32
Secondaryeuw1-az152.17.43.232/32
Tertiaryeuw1-az234.241.110.177/32
SydneyZONE IDeip
Primaryapse2-az354.252.193.245/32
Secondaryapse2-az213.55.254.141/32
Tertiaryapse2-az13.24.48.104/32
mumbaiZONE IDeip
Primaryaps1-az165.1.48.87/32
Secondaryaps1-az315.206.221.25/32
Tertiaryaps1-az213.233.48.78/32
SingaporeZONE IDeip
Primaryapse1-az213.229.11.158/32
Secondaryapse1-az152.74.225.150/32
Tertiaryapse1-az352.76.180.70/32
OHIOZONE IDEIP
Primaryuse2-az13.14.163.216/32
Secondaryuse2-az23.15.245.3/32
Tertiaryuse2-az33.141.116.179/32
CANADAZONE IDEIP
Primarycac1-az135.183.141.98/32
Secondarycac1-az252.60.71.231/32
Tertiarycac1-az43.97.253.35/32
OREGONZONE IDEIP
Primaryusw2-az152.25.165.25/32
Secondaryusw2-az244.237.58.11/32
Tertiaryusw2-az352.10.213.81/32