Slack webhooks
How to Test Slack Webhooks and Events (and Verify X-Slack-Signature)
Slack sends requests to your app for events, slash commands and interactive components. Before any of that works, your URL has to pass a verification handshake.
Capture a real Slack webhook in a minute
- Get a URL. Use the button on this page. It opens the inspector with a fresh URL that is ready to receive.
- Give it to Slack. In your app's settings at api.slack.com, open Event Subscriptions and paste the URL as the Request URL. First set the response described below so the handshake succeeds.
- Trigger an event. The request appears in the inspector as it arrives, with Slack recognised and the event name shown.
- Check the signature. Open Verify signature, paste your secret and confirm the request is genuine. The check runs in your browser.
Passing URL verification
When you save a Request URL, Slack posts a JSON body containing "type": "url_verification" and a random challenge. Your endpoint must reply with that challenge value.
A static response cannot do this, which is why most request inspectors fail Slack's check. On webhook.stream, open Response, choose the Slack URL verification preset and save. The body becomes a template that echoes the challenge:
{"challenge":"{{body.challenge}}"}Slack accepts the URL, and from then on real events flow into your inspector.
Headers Slack sends
| Header | Meaning |
|---|---|
X-Slack-Signature | v0= followed by an HMAC-SHA256 in hex. |
X-Slack-Request-Timestamp | Unix time of the request. Part of the signed string. |
X-Slack-Retry-Num | Present on retries: which attempt this is. |
X-Slack-Retry-Reason | Why Slack is retrying, such as http_timeout. |
Verifying the signature
Slack signs the string v0:{timestamp}:{raw body} with your app's signing secret.
import crypto from "node:crypto";
export function verifySlack(rawBody, headers, signingSecret) {
const timestamp = headers["x-slack-request-timestamp"];
const received = headers["x-slack-signature"] ?? "";
// Reject anything older than five minutes to stop replays.
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const expected = "v0=" + crypto
.createHmac("sha256", signingSecret)
.update(`v0:${timestamp}:${rawBody}`)
.digest("hex");
return received.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));
}What Slack expects back
- A 2xx response within three seconds. For anything slower, acknowledge immediately and reply later using the
response_urlor the Web API. - Retries. The Events API retries a failed delivery up to three times: almost immediately, after about a minute, and after about five minutes.
- Two body formats. Events arrive as JSON. Slash commands and interactive payloads arrive form-encoded. Verify the raw body in both cases.
Looking for the other direction?
If you want to send messages into Slack when some other service fires a webhook, that is an automation with a Slack incoming webhook.
Frequently asked questions
How do I pass Slack's URL verification with a test endpoint?
The endpoint must echo the challenge value from the request body. On webhook.stream, set the response body to the template {"challenge":"{{body.challenge}}"} using the Slack URL verification preset.
Why does Slack send the same event several times?
Slack retries when it does not receive a 2xx response within three seconds. Look for the X-Slack-Retry-Num header, acknowledge faster and de-duplicate on the event ID.
Which secret verifies Slack requests?
The signing secret from your app's Basic Information page. The older verification token is deprecated.