SendForm.net

How to Create a Slack Webhook and Post Form Submissions to a Channel

A Slack webhook is a secret URL that posts a JSON text message into one Slack channel. This guide shows how to create one, test it with curl, keep it private, fix the common errors and send every form submission to a channel.

Simon MeierPublished ยท 8 min read
A web form sending a submission through a secret Slack webhook URL into a chat channel as a new message
Key takeaways The short version, before the details.
  1. An incoming webhook is a hooks.slack.com URL tied to one channel. You POST JSON with a text field and a message appears.
  2. To create one, make a Slack app, turn on Incoming Webhooks, pick a channel and copy the URL.
  3. Treat the URL like a password. Anyone who has it can post to your channel.
  4. SendForm can post each form submission to Slack on every plan. You paste the URL into the form's Plugins tab.

What is a Slack webhook?

A Slack incoming webhook is a unique URL that Slack gives you for one channel. Send an HTTP POST to that URL with a small JSON body and Slack posts the message in that channel. You don't need an OAuth flow, an SDK or a bot token.

That makes webhooks the quickest way to get alerts into Slack from scripts, CI jobs, monitoring and contact forms. The trade-off is that a webhook only writes. It can't read messages, reply in threads by itself or switch channels. If you're new to the idea of one server calling another, our guide to web hooks covers the basics.

QuestionIncoming webhook
DirectionInto Slack only
Where it postsOne channel, chosen when you create it
AuthThe URL itself is the credential
BodyJSON with a text field, or Block Kit blocks
Success replyHTTP 200 with the body ok

How to create a Slack webhook

In Slack, webhooks belong to a Slack app. Creating the app takes about a minute, and you don't publish it anywhere: it lives in your own workspace.

Create the Slack app

  1. Open the Slack apps page and sign in to your workspace.
  2. Click Create New App, then choose From scratch.
  3. Give the app a name people will recognise in the channel, for example "Website forms", and pick the workspace.

Turn on incoming webhooks in your Slack app

  1. In the app's settings, open Incoming Webhooks under Features.
  2. Switch Activate Incoming Webhooks on.
  3. Scroll down and click Add New Webhook. In some workspaces the button says Add New Webhook to Workspace.

Pick the channel and copy the URL

  1. Choose the channel the messages should go to, then click Allow.
  2. Back on the Incoming Webhooks page, copy the new webhook URL from the table.

If your workspace limits app installs, an admin may have to approve the app first. Ask them to approve it, or ask an admin to create the webhook.

Slack's own incoming webhooks documentation covers the same steps and the full list of message options.

What does a webhook URL in Slack look like?

Every Slack incoming webhook URL starts with https://hooks.slack.com/services/, followed by three parts separated by slashes. The first two identify the workspace and the webhook. The last part is a long random string that works as the secret.

https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX

The X characters above are placeholders. A real URL holds real IDs and a real token, and the URL alone lets anyone post to your channel.

Slack webhook example with curl and JSON

Before you wire the URL into anything, test it from a terminal. Replace the placeholder with your URL and run:

curl -X POST \
  -H 'Content-Type: application/json' \
  --data '{"text":"Hello from my webhook"}' \
  https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX

If it works, the terminal prints ok and the message appears in the channel under your app's name.

Plain text message JSON

The smallest valid body is a single text field. Use \n for line breaks. Slack formats the text as mrkdwn, so *bold* and <https://example.com|links> work.

{
  "text": "New submission - Contact\nFrom: jane@example.com\n\nCan you send me a quote for 20 seats?"
}

Block Kit message JSON

For richer layouts, send blocks. Keep a text field as well: Slack uses it for notifications and as a fallback.

{
  "text": "New submission from jane@example.com",
  "blocks": [
    {
      "type": "section",
      "text": { "type": "mrkdwn", "text": "*New submission* from jane@example.com" }
    },
    {
      "type": "section",
      "text": { "type": "mrkdwn", "text": "Can you send me a quote for 20 seats?" }
    }
  ]
}

You can design and preview block layouts in Slack's Block Kit Builder.

How to keep a Slack webhook URL secret

The URL is the only credential a webhook has. Anyone who has it can post anything to your channel, including convincing phishing links. Handle it the way you would handle an API key.

  • Never put it in front-end code. JavaScript in a web page, a mobile app bundle or a public form's HTML is readable by every visitor. Call the webhook from a server, or from a service that stores the URL for you.
  • Keep it out of git. Load it from an environment variable or a secrets manager. Slack can revoke webhook URLs that get published in public code, so a leaked URL can suddenly stop working.
  • Don't paste it in tickets or chat. Screenshots and support threads leak more URLs than attackers do.
  • Rotate it if it leaks. Remove the webhook in the app's Incoming Webhooks settings, add a new one and update everything that used the old URL.

Why a browser form can't post to Slack directly

A static HTML form that sends to hooks.slack.com would have to ship the webhook URL in its page source. That's why form-to-Slack setups always need something in between that keeps the URL on a server.

Why is my Slack webhook not working?

When a request fails, Slack returns an HTTP error code with a short plain-text reason in the body. These are the ones you'll see most often:

ResponseWhat it meansFix
400 invalid_payloadThe body is not valid JSON or has no message contentValidate the JSON and send a text or blocks field with the Content-Type: application/json header
403 invalid_tokenThe token part of the URL is wrong or was revokedCopy the URL again from the app settings, or create a new webhook
403 action_prohibitedA workspace admin restricted posting to that channelAsk an admin or pick a different channel
404 channel_not_foundThe channel was deleted or the app lost accessCreate a new webhook for an existing channel
404 no_serviceThe webhook was removed or the app was uninstalledReinstall the app and generate a new URL
410 channel_is_archivedThe target channel is archivedUnarchive it or point a new webhook at another channel
429Too many messages in a short timeSlow down. Slack allows roughly one message per second per webhook, with short bursts

Slack's incoming webhook error reference lists every code.

The message posts, but to the wrong channel

Webhooks from a Slack app always post to the channel picked at creation, and Slack ignores channel or username overrides in the JSON. To post somewhere else, create another webhook for that channel.

curl works, but my code gets 400

The JSON is usually being sent as form data or double-encoded into a string. Send the raw JSON object as the request body with the Content-Type: application/json header.

How to send form submissions to a Slack channel

If all you need is "someone filled in the form, tell the team", you don't need to host a server or set up an automation account. SendForm stores each submission and posts it to your Slack webhook from its own servers, so the URL never appears in your page. If you don't have a form yet, the contact form setup gives you one in a few minutes.

Connect a Slack app webhook to your form

  1. Create the Slack webhook as shown above and copy the hooks.slack.com URL.
  2. In the SendForm dashboard, open your form and go to the Plugins tab.
  3. Choose Slack, paste the webhook URL and click Connect.
  4. Use Send a test on the new connection. A "Test delivery" message should appear in your channel.

Slack is one of the built-in chat plugins, alongside Discord, Telegram and Mattermost, and it works on every plan. Only the Custom Webhook plugin, which sends raw JSON to any URL you choose, needs a paid plan. See pricing for what each plan includes.

What the Slack message looks like

SendForm spots the hooks.slack.com address and sends Slack's own format instead of raw JSON. Each submission becomes one readable message:

New submission - Contact
From: jane@example.com

Can you send me a quote for 20 seats?

company: Example Ltd
phone: +44 20 7946 0000

Attachments: brief.pdf

The first line names the form. Next come the sender's email, the message and every extra field as name: value. If files were uploaded, a final line lists their names.

What happens when Slack is down

  • Each delivery is tried up to three times: immediately, then after 1 second, then after 3 seconds.
  • Every attempt is logged on the form, so you can see the status code when something goes wrong.
  • If delivery still fails after the retries, you get an in-app notification. You get at most one per form every six hours, so a broken channel can't flood you.
  • Delivery runs after the visitor gets their response, so a slow Slack never delays the form.

Want the same message in several channels? Add one Slack webhook per channel to the form. Every enabled webhook gets each submission, and you can pause any of them with its toggle. The webhooks reference has the full delivery details.

Ready to see form submissions in Slack?

  • Paste a hooks.slack.com URL into the form's Plugins tab
  • Each submission arrives as a readable message, fields included
  • Available on every plan, with retries and a delivery log
Create your form

Frequently asked questions

Go to the Slack apps page, create a new app from scratch in your workspace, open Incoming Webhooks and switch it on. Click Add New Webhook, choose the channel and click Allow. Slack then shows a hooks.slack.com URL that you can copy and POST JSON messages to.

It starts with https://hooks.slack.com/services/ followed by three slash-separated parts. The first two are IDs for the workspace and the webhook, and the last is a long random token. The whole URL, including that token, is what you send requests to.

Yes. The URL is the only credential, so anyone who has it can post to your channel. Keep it out of front-end code, public repositories and support tickets. Load it from an environment variable, and if it ever leaks, remove the webhook and create a new one.

No. A webhook created by a Slack app is locked to the channel chosen when it was created, and Slack ignores channel overrides in the payload. To reach several channels, create one webhook per channel. In SendForm you can add several Slack webhooks to the same form.

Yes. Create an incoming webhook in Slack and paste its URL into your form's Plugins tab in SendForm. Each submission then posts straight to the channel as a readable message with the sender, the message and every field. This works on every plan, with no automation account or server to run.