How to Use Discord Webhooks (No Bot Needed)
A Discord webhook is a secret link that posts messages into one channel. There's no bot to invite, nothing to keep online between messages, and no token. You can set it up in about two minutes, post a message with one command, and then connect it to GitHub, a script or a tool that supports webhooks. Here's how, from creating one to fixing the errors people hit most.
What a webhook can and can't do
A webhook only sends. Something outside Discord, like a website, a script or a scheduled job, sends a message to the webhook link, and Discord shows it in the channel under the webhook's name and picture.
- Good for: alerts and feeds. New GitHub commits, new Steam reviews of your game, free game alerts, patch notes, server status, a reminder from a scheduled task.
- Not able to: read messages, reply to people, respond to slash commands, give roles or moderate. If you need any of that, you need a real bot. Our guide on hosting a Discord bot on your PC for free covers that route.
Because a webhook only posts when something calls it, you don't need anything running in between. That's why a lot of small alert tools use webhooks instead of bots.
Step 1: Create a webhook
You need the Manage Webhooks permission in the server (server owners and admins have it).
- Open Server Settings > Integrations > Webhooks. You can also start from a single channel: Edit Channel (the gear next to its name) > Integrations > Webhooks.
- Click New Webhook. Discord creates one with a random name.
- Click it to open it. Give it a name, pick the channel it posts to, and change the picture if you like.
- Click Copy Webhook URL. It looks like
https://discord.com/api/webhooks/1234567890/AbCdEf....
Treat that URL like a password. Anyone who has it can post anything to that channel. Keep the webhook URL secret covers what to do if it leaks.
Step 2: Send a test message
A webhook takes a small piece of JSON. The only required part is something to post, and the simplest is content, plain text up to 2,000 characters. Paste your own URL in place of YOUR_WEBHOOK_URL.
Windows (PowerShell):
$url = "YOUR_WEBHOOK_URL"
$body = @{ content = "Hello from a webhook!" } | ConvertTo-Json
Invoke-RestMethod -Uri $url -Method Post -ContentType "application/json" -Body $body
Mac or Linux (Terminal):
curl -H "Content-Type: application/json" \
-d '{"content": "Hello from a webhook!"}' \
"YOUR_WEBHOOK_URL"
If the message appears in your channel, the webhook works. Discord answers a successful post with an empty response (HTTP 204), so it's normal to see nothing in the terminal. Add ?wait=true to the end of the URL if you'd rather get the posted message back.
Step 3: Change the name, picture and look
Each message can override the webhook's name and picture, and can carry up to 10 embeds, the boxed cards with a colored bar that alert bots use. Here are the fields you'll use most:
{
"username": "Server News",
"avatar_url": "https://example.com/logo.png",
"content": "Optional text above the card",
"embeds": [{
"title": "Game night is Friday",
"url": "https://example.com/event",
"description": "Bring a friend. Voice channel opens at 8 PM.",
"color": 5814783,
"fields": [
{"name": "Game", "value": "Deep Rock Galactic", "inline": true},
{"name": "Slots", "value": "8", "inline": true}
],
"footer": {"text": "Sent by a webhook"}
}]
}
Two things trip people up here. The color is a normal number, not a hex code: convert the hex color 58B9FF to decimal and you get 5814783. And avatar_url has to be a direct, public link to an image file.
| Limit | Maximum |
|---|---|
Plain message text (content) | 2,000 characters |
| Embeds per message | 10 |
| Embed title | 256 characters |
| Embed description | 4,096 characters |
| Fields per embed | 25 |
| All embed text in one message, combined | 6,000 characters |
Going over any of these gets the whole message rejected, so cut long text down before you send it.
Step 4: Connect a service without code
Many tools have a "Discord webhook" or "webhook URL" box in their settings. Paste the URL there and you're done. Two built-in shortcuts are worth knowing:
- GitHub: in your repository, open Settings > Webhooks > Add webhook. Paste your Discord URL with
/githubadded to the end, and set the content type toapplication/json. Discord then turns pushes, issues and pull requests into readable messages. Without/github, the messages won't show up properly. - Slack-style webhooks: if a tool only knows how to post to Slack, add
/slackto the end of your Discord URL. Discord accepts the basic Slack format, though not every Slack option.
Before you paste your webhook into any third-party site, remember it can post anything to that channel. Only give it to services you trust.
Step 5: Post from your own script
Once you can send one message, automating it is a small step. This Python script uses only the standard library, so there's nothing to install. It reads the URL from an environment variable so the secret isn't in your code, it stops accidental pings, and it waits and retries if Discord says you're sending too fast.
import json, os, time, urllib.error, urllib.request
WEBHOOK = os.environ["DISCORD_WEBHOOK_URL"] # keep the URL out of your code
def post(payload, tries=3):
payload.setdefault("allowed_mentions", {"parse": []}) # never ping by accident
data = json.dumps(payload).encode()
for _ in range(tries):
req = urllib.request.Request(WEBHOOK, data=data, headers={
"Content-Type": "application/json",
"User-Agent": "my-webhook-script"}) # without this, Discord answers 403
try:
with urllib.request.urlopen(req, timeout=20):
return True # 204 = posted
except urllib.error.HTTPError as e:
if e.code == 429: # rate limited: wait as told, then retry
wait = json.loads(e.read() or b"{}").get("retry_after", 2)
time.sleep(float(wait))
continue
print("Discord said", e.code, e.read()[:300])
return False # 400 = bad message, 404 = webhook deleted
return False
post({
"username": "Server News",
"embeds": [{
"title": "Game night is Friday",
"description": "Bring a friend. Voice channel opens at 8 PM.",
"url": "https://example.com/event",
"color": 5814783,
"fields": [{"name": "Game", "value": "Deep Rock Galactic", "inline": True},
{"name": "Slots", "value": "8", "inline": True}],
"footer": {"text": "Sent by a webhook"}
}]
})
Set the variable and run it. In PowerShell: $env:DISCORD_WEBHOOK_URL = "YOUR_WEBHOOK_URL", then python send_to_discord.py. On Mac or Linux: export DISCORD_WEBHOOK_URL="YOUR_WEBHOOK_URL", then python3 send_to_discord.py.
To run it on a schedule, use Task Scheduler on Windows or cron on Mac and Linux. It's free on your own PC, and it keeps working around the clock as long as the PC is on and awake. A small host for about $5–$8 a month is optional, for when you want it to run while your PC is off. For jobs every few hours, a free scheduled GitHub Actions workflow can also work, with the URL stored as a repository secret.
Keep the webhook URL secret
- Don't paste it in a public channel, a screenshot or a code repository. Keep it in an environment variable or a
.envfile that's listed in.gitignore. - If it leaks, delete the webhook (Server Settings > Integrations > Webhooks, open it, Delete Webhook) and create a new one. The old URL stops working right away. There's no way to "change the password" on an existing webhook.
- Use one webhook per tool. If one leaks or misbehaves, you delete just that one, and each tool gets its own name in the channel.
- Keep
"allowed_mentions": {"parse": []}in anything that posts text from outside, like reviews or feed titles. Then a stray@everyonein that text can't ping your whole server.
Common errors and fixes
| What you see | What it means and how to fix it |
|---|---|
403 with error code: 1010 from a Python script | Discord's firewall turned the request away because of its User-Agent. Python's built-in urllib gets this with its default one; set your own User-Agent header, as in the script above. (We hit this ourselves while testing.) |
400 Bad Request | The message is empty, isn't valid JSON, or is over a limit from the table above. Check that you sent Content-Type: application/json, and shorten long text. |
401 or 404 Unknown Webhook | The URL is wrong or the webhook was deleted. Copy the URL again. If it was deleted, make a new one, and stop sending to the old one: Discord asks apps not to keep retrying a webhook that returns 404. |
429 Too Many Requests | You're sending too fast. The response says how long to wait in retry_after (in seconds). Wait that long, then retry. Combining several updates into one message, up to 10 embeds, also helps. |
Works, but @everyone or a role didn't ping | Check allowed_mentions. If you want a ping, allow it on purpose, for example {"parse": ["roles"]}. |
| Error when the channel is a forum | Forum channels need a post to put the message in. Add "thread_name": "Post title" to create a new post, or ?thread_id= in the URL to reply in an existing one. |
Ready-made webhook tools
If you want something useful running in a webhook today, these are free and open source (MIT), use only the Python standard library and need no API keys:
- Review Pulse for Steam posts each new Steam review of a game to your channel. It's handy for game devs who want feedback as it lands. (More about it.)
- Free Games Notifier Lite posts Epic Games Store free games, and can run free on GitHub Actions.
If you'd rather have a finished bot, our Patch Tracker ($12) posts Steam patch notes, and the Gaming Community Kit ($25) combines moderation, welcome messages, free games, Steam deals and patch notes in one bot. Both are one-time purchases, with source code you run yourself.
Sources
- Discord Support: Intro to Webhooks
- Discord Developer Docs: Webhook resource (Execute Webhook, /slack, /github)
- Discord Developer Docs: Embed limits
- Discord Developer Docs: Allowed mentions
- Discord Developer Docs: Rate limits (429 and invalid requests)
- Discord Developer Docs: Permissions (Manage Webhooks)
- GitHub Docs: Creating webhooks
- GitHub Docs: Using secrets in GitHub Actions