You receive a “Discord Webhook Delivery Failed With 401” error when your automated system tries to send a message to a Discord channel. This 401 status code means the request was unauthorized. Discord rejected the webhook because the authentication token was missing, invalid, or expired. This article explains the three main causes of this error and how to resolve each one.
Key Takeaways: Fixing the 401 Webhook Error
- Webhook URL token mismatch: The token in your request does not match the token Discord issued for that webhook.
- Expired or deleted webhook: The webhook was removed from the channel or the token expired due to a server setting change.
- Incorrect HTTP method or endpoint: Using a POST request to the wrong URL or using a GET request instead of POST.
Why Discord Returns a 401 Error for Webhooks
A Discord webhook URL contains a unique ID and a token. The structure is https://discord.com/api/webhooks/<webhook_id>/<webhook_token>. When your application sends a POST request to this URL, Discord checks that the token matches the stored token for that webhook ID. If the token is wrong, missing, or the webhook no longer exists, Discord returns HTTP 401 Unauthorized.
The 401 error is not a network or server-side issue. It is an authentication failure. Discord does not return 401 for rate limiting or payload size limits. Those return 429 or 413. The 401 error always points to a credential problem.
Cause 1: Webhook Token Does Not Match the ID
The most common cause is a copy-paste error. When you create a webhook in Server Settings > Integrations > Webhooks, Discord generates a URL. If you manually edit this URL, you might change a character in the token. The token is case-sensitive. A single wrong character causes a 401.
Cause 2: Webhook Was Deleted or Regenerated
If someone with Manage Webhooks permission deletes the webhook, the URL becomes invalid. Any POST request to that URL returns 401. Similarly, if a moderator regenerates the webhook token, the old token stops working. The webhook ID stays the same, but the new token replaces the old one.
Cause 3: Wrong HTTP Method or Endpoint
Discord webhooks only accept POST requests. Sending a GET request to the webhook URL returns 401. Also, using the wrong API endpoint, such as /api/webhooks/<id> without the token, triggers a 401. The full endpoint must include both the ID and token.
Steps to Diagnose and Fix the 401 Webhook Error
Step 1: Verify the Webhook URL in Discord
- Open Server Settings
Right-click the server name in the channel list. Select Server Settings from the context menu. - Go to Integrations
In the left sidebar, click Integrations. Under Webhooks, click the webhook that is failing. - Copy the webhook URL
Click Copy Webhook URL. Do not edit this URL. Paste it directly into your application configuration.
Step 2: Check for Token Regeneration
- Open the webhook details
Follow Step 1 to open the webhook page in Integrations. - Look for the regenerated token warning
If someone clicked Regenerate, Discord shows a warning: “The webhook URL has been regenerated. The old URL will no longer work.” Update your application with the new URL.
Step 3: Test the Webhook with cURL
- Open a terminal
On Windows, press Win+R, typecmd, and press Enter. On macOS or Linux, open Terminal. - Run the cURL command
Type:curl -X POST -H "Content-Type: application/json" -d '{"content":"test"}' YOUR_WEBHOOK_URL. Replace YOUR_WEBHOOK_URL with the exact URL from Discord. If you get a 401, the URL is wrong or the webhook is deleted.
Step 4: Confirm the Webhook Exists
- Check the webhook list
In Server Settings > Integrations, scroll to the Webhooks section. If the webhook is missing, someone deleted it. Create a new webhook. - Create a new webhook
Click Create Webhook. Give it a name and assign a channel. Click Copy Webhook URL. Use this new URL in your application.
Step 5: Ensure You Are Using POST
- Check your application code
Look for the HTTP method in your script. It must be POST. If you use GET, PUT, or DELETE, Discord returns 401. - Check the endpoint URL
Ensure the URL ends with/api/webhooks/<id>/<token>. Do not add extra path segments like/slackor/githubunless you are using Discord’s Slack-compatible endpoint. That endpoint is/api/webhooks/<id>/<token>/slackand still requires the token.
If Discord Still Returns 401 After the Main Fix
Webhook URL Contains Line Breaks or Spaces
When copying the webhook URL from Discord, the browser might add a trailing newline. This extra character breaks the token. Paste the URL into a plain text editor like Notepad. Remove any spaces or line breaks before saving the URL in your application configuration.
Application Caches the Old Webhook URL
Some applications cache configuration values. After updating the webhook URL, restart the application or clear the cache. For example, in a Discord bot using discord.py, restart the bot process. In a CI/CD pipeline like GitHub Actions, push a new commit to trigger a fresh build.
Server Boost Level Affects Webhook Limits
Discord limits the number of webhooks per channel based on the server’s boost level. If your server has fewer than 10 webhooks per channel, this is not a problem. Exceeding the limit does not cause a 401 error. It causes Discord to reject the webhook creation, not the delivery. If you cannot create a new webhook, check the channel’s webhook limit under Server Settings > Integrations.
Discord Webhook Authentication Methods: Token vs OAuth2
| Item | Webhook Token | OAuth2 Bot Token |
|---|---|---|
| Authentication type | Token in URL path | Bearer token in Authorization header |
| Scope of access | Single channel only | All channels the bot has access to |
| Token rotation | Manual regeneration in UI | Automatic via Discord Developer Portal |
| Error on invalid token | HTTP 401 Unauthorized | HTTP 401 Unauthorized with error code 50001 |
| Use case | Simple message posting from external services | Full bot interaction with commands and embeds |
Discord webhooks use a simple token embedded in the URL. This token does not expire unless regenerated. OAuth2 bot tokens require a client ID and secret and can be revoked from the developer portal. For simple message delivery, webhooks are easier to set up. For interactive features, use a bot.
To resolve a 401 error, start by copying the webhook URL directly from Server Settings > Integrations. Test it with cURL using a POST request. If the test succeeds, update your application configuration. If the test fails, the webhook was deleted or the token was regenerated. Create a new webhook and update all references. Avoid editing the URL manually. Use the exact URL Discord provides.