In this article

A Slack incoming webhook is a URL that lets any script post a message to one channel with a single curl call. Getting one takes about two minutes in a Slack app’s settings, and you only need teh app and a channel. Receiving messages from Slack is a different job, and the old outgoing webhooks that did it are legacy, so the Events API has replaced them.
This article covers what Slack webhooks are, how to create an incoming webhook, what to use instead of outgoing webhooks, how to handle errors, and how to test the receiving side on your own machine with Pinggy.
What Are Slack webhooks?
Slack webhooks are a way to send or receive data to and from Slack through HTTP requests. They serve as automated messengers, allowing communication between Slack and external services, such as bots and assistants, improving efficiency by automating real-time alerts, notifications, and interactions. Slack webhooks fall into two primary categories:
- Incoming webhooks: These allow external services to post messages directly into a specified Slack channel, providing real-time updates or notifications.

- Outgoing webhooks: These are used to trigger actions from Slack. When a specified keyword or phrase is mentioned in a Slack channel, Slack sends an HTTP request to an external URL, allowing that server to handle the message and respond accordingly. Slack calls these legacy custom integrations and “strongly recommends” not using them anymore. New apps should use the Events API instead, which works the same way with more event types.

Later, we will create an incoming webhook and set up the Events API replacement for outgoing ones.
Difference Between webhooks and APIs
While both webhooks and APIs enable communication between different services, they operate in distinct ways:
| Feature | webhooks | APIs |
|---|---|---|
| Communication Type | Event-driven: webhooks send data automatically when a specific event occurs. | Request-driven: APIs require a request to retrieve or send data. |
| Data Transfer | Data is pushed from one service to another. | Data is pulled by a service requesting it from another. |
| Efficiency | More efficient, as they only send data when an event triggers it. | Can be less efficient, especially when polling for updates. |
| Usage Scenario | Best for real-time notifications (e.g., sending alerts or updates automatically). | Best for on-demand data retrieval or for performing specific actions (e.g., fetching user data, updating records). |
| Control | Once set up, the data is sent without further input from the receiving service. | The requesting service has full control over when and how often it makes requests. |
| Complexity | Simpler setup for specific events but limited in scope. | More versatile and can handle a wider variety of operations. |
In summary, webhooks are ideal for real-time, automated updates based on specific events, while APIs offer more control and flexibility for retrieving or sending data as needed.
Steps to Create an Incoming Slack Webhook
Incoming webhooks push messages from an external application directly to a Slack channel, which is useful for alerts, reports, or any external-to-Slack notifications.
Step 1: Create a Slack App
- Go to the Slack API Website and click Create New App.
- Choose From scratch.
- Enter a name for your app and select the workspace where it will reside.
- Click Create App.
Step 2: Enable Incoming webhooks
- In your app’s settings, navigate to Incoming Webhooks on the left-side menu.
- Toggle Activate Incoming Webhooks on.
- Click Add New Webhook to Workspace.
Step 3: Select a Channel
- Choose the channel where the webhook will post messages.
- Click Allow (some workspaces show Authorize) to grant the necessary permissions. Workspace admins can restrict who may add apps, and then the request goes to an admin first.
Step 4: Retrieve the Webhook URL
- After selecting the channel, Slack lists the new URL under Webhook URLs for Your Workspace. It looks like
https://hooks.slack.com/services/T000/B000/XXXX. - Copy it and send a test message:
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Hello from my webhook"}' \
https://hooks.slack.com/services/T000/B000/XXXXA successful call returns HTTP 200 with the body ok, and the message appears in the channel. Each URL is tied to one channel. You can’t override the channel, username or icon in the payload, and a posted message can’t be deleted through the webhook, so create one webhook per channel and don’t recieve any surprises later. Add blocks next to text in the same JSON for richer layouts. Slack also revokes webhook URLs it finds in public repositories, so keep yours in an environment variable.
Steps to Create an Outgoing Slack Webhook
Outgoing webhooks allow Slack to send an HTTP POST request to an external URL when specific keywords are mentioned in a channel. Slack lists them as a legacy custom integration and tells developers to use the Events API for anything new, so the steps below apply only if you still have one running. For new work, jump to the Events API setup in the testing section.
Step 1: Open the legacy integration
- Open the custom integrations page of your workspace.
- Select Outgoing WebHooks and add a configuration.
Step 2: Set Up the Outgoing Webhook
- Choose the channel(s) where the webhook will listen for keywords.
- Enter the trigger words that Slack should watch for in the specified channels.
Step 3: Specify the URL to Receive POST Requests
- Enter the URL of the server or endpoint where Slack should send the POST request when the trigger word is mentioned.
- Customize the response message template if needed. Slack will post the message sent from your external server back to the Slack channel if a response is provided.
Step 4: Save the Configuration
- Click Save Settings to activate the webhook.
Slack limits legacy outgoing webhooks to about one message per second.
How to Handle Errors
Proper error handling is crucial to ensure smooth integration with Slack webhooks. Both incoming and outgoing webhooks can encounter errors that disrupt communication, so understanding these error types and managing them effectively is key.
Common Error Responses for Slack webhooks
Slack webhooks can encounter the following errors when there are issues with requests, responses, or connectivity:
Incoming Webhook Errors
Incoming webhooks are HTTP requests sent from an external application to Slack, typically to post messages in a channel. Here are common errors you might encounter with incoming webhooks:
Slack returns a short text code in the response body, so print the body when a call fails:
- 400
invalid_payload: the JSON is malformed or the text is not escaped. Check quotes and newlines in the body you build. - 400
no_text: the payload has notextfield (or blocks). - 403
action_prohibited: a workspace admin restricted what the app may do. Retrying won’t help; ask an admin. - 404
channel_not_foundorchannel_is_archived: the channel behind the webhook was deleted or archived. Add a new webhook for a live channel. - 5xx errors: these come from Slack’s side and are rare. Retrying after a short wait usually resolves them.
Outgoing Webhook Errors
Outgoing webhooks are HTTP requests from Slack to an external server when a specific keyword is mentioned in a channel. Common issues here include:
- Timeouts or Connectivity Issues: If Slack cannot reach the external server, the request times out. The Events API expects an HTTP 2xx within three seconds. Ensure your server is up, accessible, and correctly configured to receive requests.
- 4xx Client Errors: If Slack encounters issues with your endpoint, like a
404 Not Foundor400 Bad Request, it typically means the URL or payload is incorrect. Check the endpoint URL and ensure your server can parse and respond to the request. - 5xx Server Errors: If your server is down or encounters a server-side error, Slack’s request will fail. Implement server health monitoring and retry logic to handle intermittent outages.
Retry Logic for Slack webhooks
For incoming webhooks, your application should implement an exponential backoff strategy if it encounters 5xx errors. Retry the request at increasingly longer intervals, such as 1 second, 2 seconds, then 4 seconds, until it is successful.
For the Events API, Slack retries a failed delivery up to three times: almost immediately, after 1 minute and after 5 minutes. Each retry carries an X-Slack-Retry-Num header, so you can ignore duplicates, and acknowledge fast and do the real work afterwards so a slow handler doesn’t trigger them. If more than 95% of deliveries fail within an hour, Slack temporarily disables the subscription and emails the app owner.
Logging and Monitoring
- For Incoming webhooks: Log each request and response to track any malformed payloads, connectivity issues, or authorization problems. If possible, integrate alerts to notify you of persistent failures.
- For Outgoing webhooks: On your server, log every incoming request from Slack, along with responses and any errors encountered. Use a monitoring tool to trigger alerts if your endpoint becomes unavailable or errors exceed a certain threshold.
By following these error-handling steps for both incoming and outgoing webhooks, you can ensure reliable, uninterrupted communication between Slack and your external services.
How to Test Outgoing Slack Webhook using Pinggy
Slack can only deliver events to a public URL, so a server on your laptop needs a tunnel. Pinggy exposes your local server to the internet, which lets you receive and debug requests from Slack, whether they come from a legacy outgoing webhook or the Events API. Here’s how to set it up:
Step 1: Set Up Pinggy
Pinggy simplifies the process of creating a secure tunnel. Use the following command to set up a tunnel to your local development server:
ssh -p 443 -R0:localhost:3000 free.pinggy.ioNote: Port 3000 matches the example server in the next step. Replace it with the port where your own server runs. A free tunnel lasts 60 minutes and gets a new URL each time you start it, so you’ll update the URL in Slack on every restart; Pinggy Pro ($3/month, or $2.50/month billed yearly) keeps a persistent subdomain.
If you run the command with your specified port where your service is running, you will get an output similar to the following:

Step 2: Set Up a Local Web Server
Create a simple local server to receive the webhook data from Slack. If you’re using Node.js, you can set it up as follows:
var express = require("express");
var app = express();
app.use(express.json());
const port = 3000;
app.all("/*", function (req, res) {
console.log("Headers:" + JSON.stringify(req.headers, null, 3));
console.log("Body:" + JSON.stringify(req.body, null, 3));
if (req.body.challenge != null) {
//When you enable Event Subscriptions in Slack,
//Slack makes a one-time post call to the app
//sending a challenge field value and
//expects the app to respond with this value.
res.type("txt");
res.send(req.body.challenge);
} else {
//For all the rest of the requests
//the app responds the same message.
res.json({ message: "Thank you for the message" });
}
});
app.listen(port, function () {
console.log(`Example Slack app listening at ${port}`);
});Save the above code in a file named app.js and run the following command to start the application:
node app.jsStep 3: Configure Event Subscriptions in Slack
- Open your app at api.slack.com/apps and go to Event Subscriptions. Turn Enable Events on.
- Paste the public URL from Pinggy (for example
https://abcde-203-0-113-7.run.pinggy-free.link) into Request URL. Slack immediately sends aurl_verificationrequest with achallengevalue, and the example server above answers it, so the field shows Verified. - Under Subscribe to bot events, add
message.channelsto receive channel messages, then save. Add thechannels:historyscope under OAuth & Permissions and reinstall the app. - Invite the app to a channel with
/invite @yourapp.
If you can’t expose a public URL at all, Socket Mode delivers the same events over an outbound WebSocket, but apps using it can’t be listed in the public Slack Marketplace.
Step 4: Test the Webhook
- In the channel where the app is invited, post a message.
- Slack sends a POST request to your public Pinggy URL for each message. Check the terminal where your local server is running: it prints the request headers, including
X-Slack-Signature, and a JSON body whoseevent.textholds your message. - The server answers every event with a short JSON reply, which Slack ignores for Events API requests. To post back into the channel, call your incoming webhook URL from the handler.
Pinggy’s web debugger shows each request Slack sent and lets you replay it without typing in Slack again.
Step 5: Validate the Response
Respond with HTTP 2xx within three seconds, or Slack treats the delivery as failed and retries it. For the url_verification request, respond with 200 and the challenge value, as the example does. Legacy outgoing webhooks are different: they accept a JSON reply such as {"text": "Thank you for the message"} and post it back to the channel.
Security Best Practices for Slack webhooks
- Keep Webhook URLs Private
- Webhook URLs act as a direct access point to post or retrieve information from Slack. Treat these URLs as sensitive information, similar to API keys.
- Avoid embedding webhook URLs directly in source code, especially if your code is publicly accessible. Instead, use environment variables or secure vaults to store them securely.
- Limit Channel Permissions and Scope
- Only grant permissions necessary for the webhook’s purpose. For instance, when setting up an incoming webhook, restrict it to only the channels where it’s essential.
- Use Slack’s granular app permissions to minimize access and prevent unintended access across the workspace.
- Verify Outgoing Webhook Requests
For Events API requests, Slack includes a verification signature (found in the
X-Slack-Signatureheader). Validate this signature to ensure the request is genuinely from Slack. Slack’s old verification token is deprecated, so use the signing secret.The signing secret is on your app’s Basic Information page. Hash
v0:<timestamp>:<raw body>with HMAC-SHA256, prefix the hex digest withv0=, and compare it to the header in constant time. Hash the raw request body before any JSON parsing, and reject timestamps more than five minutes old to block replays. Example in Node.js:const crypto = require("crypto"); function verifySlackRequest(req, signingSecret) { const timestamp = req.headers["x-slack-request-timestamp"]; if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 60 * 5) return false; const signature = req.headers["x-slack-signature"]; const baseString = `v0:${timestamp}:${req.rawBody}`; const hash = `v0=${crypto .createHmac("sha256", signingSecret) .update(baseString) .digest("hex")}`; const a = Buffer.from(hash); const b = Buffer.from(signature || ""); return a.length === b.length && crypto.timingSafeEqual(a, b); }req.rawBodyisn’t set by default in Express; capture it withexpress.json({ verify: (req, res, buf) => { req.rawBody = buf.toString(); } }).
- Restrict IP Addresses (If Possible)
- Slack doesn’t publish a stable IP list for event delivery, so rely on signature verification instead of an allowlist. On a Pinggy tunnel you can still add basic auth or an allowlist for other endpoints on the same server, but don’t put either in front of the Slack Request URL, since Slack can’t supply credentials.
- Monitor Webhook Activity
- Log all webhook activity, including request timestamps, sender IPs, and payloads. Monitoring these logs can help identify unusual activity or unauthorized access attempts.
- Set up automated alerts to notify your team if unexpected or excessive requests are received, signalling potential abuse or misconfiguration.
- Implement Rate Limiting
- Limit the number of requests accepted by your server for each webhook endpoint to prevent abuse. Use rate limiting tools or middlewares in your backend to detect and block IPs or requests that exceed reasonable thresholds.
- Set Up Error Handling for Unauthorized Access
- When an unauthorized request is detected (such as an invalid signature or excessive request rate), respond with an appropriate HTTP status code (e.g.,
403 Forbidden) and log the incident. - Optionally, consider temporarily blocking IPs with frequent unauthorized attempts to access the webhook.
By applying these security practices, you can help ensure that your Slack webhooks are protected from unauthorized access and misuse, allowing them to reliably and safely enhance your team’s workflows.
Alternatives to Slack Webhooks
While Slack webhooks offer a straightforward way to integrate with external applications, there are alternatives that can provide greater flexibility and functionality.
- Slack API: The Slack API allows you to build more complex integrations, including real-time messaging and user interactions. You can use it to create custom commands, interactive messages, and more sophisticated features beyond basic webhook functionality.
- Slack Events API: The Events API is the replacement for outgoing webhooks, allowing you to receive a broader range of events and notifications, such as message edits, reactions and channel changes. It delivers to a public URL or over Socket Mode.
- Workflow Builder and integration platforms: Slack’s own Workflow Builder can start a workflow from a webhook URL, on paid plans and limited to one request per second. Tools like Zapier, Make and Tray.io offer no-code solutions to connect Slack with other applications. These platforms allow you to create automation workflows without writing any code, making it easier to integrate Slack with various services.
- Custom Bots: Building a Slack bot using the Slack API provides even more control over how your integration interacts with users. Bots can respond to messages, initiate conversations, and perform actions based on user input, making them suitable for interactive applications.
Conclusion
An incoming webhook is still the quickest way to post into Slack: create an app, enable Incoming Webhooks, and send JSON to the URL it gives you. To receive messages from Slack, use the Events API instead of legacy outgoing webhooks, verify every request’s signature, and test locally through a Pinggy tunnel first.