TinyPingTinyPing

How to create a Slack incoming webhook

To create a Slack incoming webhook, make an app at api.slack.com/apps, turn on Incoming Webhooks, click Add New Webhook to Workspace, pick a channel and click Allow. Slack then shows the webhook URL for you to copy.

Last updated

Before you start

  • A Slack workspace you can add apps to. Some workspaces need an admin to approve new apps first.
  • The channel the messages should go to. One webhook posts to one channel, so make one webhook per channel.
  • A web browser. The steps happen on Slack's app settings site, not in the Slack app itself.

Create a Slack incoming webhook, step by step

  1. Go to api.slack.com/apps (opens in a new tab), click Create New App, then choose From scratch.
  2. Name the app, pick the workspace it belongs to, then click Create App.
  3. In the left menu, open Incoming Webhooks and switch on Activate Incoming Webhooks.
  4. Click Add New Webhook to Workspace.
  5. Pick the channel the app should post to, for example #server-alerts, then click Allow.
  6. Back on Incoming Webhooks, find your new URL under Webhook URLs for Your Workspace and click Copy. It looks like https://hooks.slack.com/services/T.../B.../....

Want to post to another channel later? Click Add New Webhook to Workspace again and pick that channel. Each one gets its own URL.

Test your webhook

Paste this into a terminal, with your own URL in place of the example.

Terminal
curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"text":"Hello from curl"}' \
  'https://hooks.slack.com/services/T00000000/B00000000/EXAMPLEEXAMPLEEXAMPLE'

If it works, Slack answers ok and "Hello from curl" appears in the channel, posted by your app.

Troubleshooting

When a message is refused, Slack answers with a short error instead of ok. The common ones:

invalid_payload
Slack could not read the body. Check that it is valid JSON with a text field, and that you sent the Content-Type: application/json header.
no_service or 404 Not Found
The webhook no longer exists. It was removed, or the app was uninstalled from the workspace. Add a new webhook and use the new URL.
channel_is_archived
The channel was archived. Unarchive it, or add a new webhook for a different channel.
action_prohibited
A workspace admin has restricted who can post in that channel. Ask them to allow the app, or pick another channel.
Slack asks you to request approval instead of showing Allow
Your workspace needs an admin to approve new apps. Send the request and wait for approval, then add the webhook again.
The command does not work in Windows Command Prompt
Command Prompt does not understand single quotes. Use double quotes around the URL and escape the ones in the body: -d "{\"text\":\"Hello\"}". Or run it in PowerShell with curl.exe.

Keep the URL secret

The webhook URL works like a password. Anyone who has it can post messages into your channel, without signing in. Do not commit it to a public repository or paste it into tickets and chats. Store it the way you store other secrets.

If the URL leaks, open your app at api.slack.com/apps, go to Incoming Webhooks and remove that webhook from the list. Then click Add New Webhook to Workspace for a fresh URL. Uninstalling the app removes all of its webhooks at once.

Use it with TinyPing

TinyPing checks your websites, APIs and cron jobs around the clock and posts to your Slack channel when something goes down. The quickest way in does not need a webhook you made yourself:

  1. In TinyPing, open Alerts and click Add to Slack.
  2. Slack asks which channel TinyPing may post to. Pick one and click Allow.
  3. Back in TinyPing, the channel is added and alerts every monitor straight away.

If your workspace needs an admin to approve apps, or Add to Slack is not offered, use the webhook you made above: under Add a contact, set Type to Slack webhook URL, paste the URL, choose the monitors and click Add contact.

TinyPing posts one short message when a monitor goes down, one when it recovers (with how long it was out), and reminders before an SSL certificate or domain expires. Each names the monitor and its target and links to it in TinyPing. If Slack says the webhook is gone (the app was removed or the channel archived), TinyPing switches that channel off and shows "Slack disconnected" on the Alerts page, so you know to add it again.

Start your 7-day free trial

US$6.99 a month or US$47 a year per 50 monitors, team members free. No card needed for the trial.

Related

More guides in the help center.