Discord ‘Webhook Token Invalid’ Error: Token Rotation Steps
🔍 WiseChecker

Discord ‘Webhook Token Invalid’ Error: Token Rotation Steps

You see the error ‘Webhook Token Invalid’ when your Discord bot or integration tries to send a message to a channel. This happens because the webhook token has been changed by Discord or by a manual rotation. Discord rotates webhook tokens automatically under certain conditions, and the old token stops working immediately. This article explains why the token becomes invalid and provides step-by-step instructions to rotate and update your webhook tokens.

Key Takeaways: Fixing the ‘Webhook Token Invalid’ Error

  • Channel > Integrations > Webhooks > Copy Webhook URL: Get the current valid webhook URL and token directly from Discord.
  • Server Settings > Integrations > Webhooks > Edit > Regenerate: Manually rotate the webhook token when you suspect it is compromised or outdated.
  • Update your bot code or integration settings: Replace the old token in your application or third-party service with the new one.

Why the Webhook Token Becomes Invalid

A Discord webhook consists of two parts: a numeric ID and a secret token. The token is a long string of characters that authenticates the webhook when sending messages. If the token changes, any application using the old token receives the ‘Webhook Token Invalid’ error.

Discord automatically rotates the webhook token when any of these events occur:

  • A server administrator manually regenerates the token from the webhook settings page.
  • The webhook is deleted and recreated by an administrator or bot.
  • Discord performs a security rotation on its backend, though this is rare.
  • An integration or bot uses the webhook with an outdated token after a server moderation action.

The error message does not specify which field is invalid. It only says ‘Webhook Token Invalid’, which means the token portion of the URL does not match what Discord expects. The webhook ID itself rarely changes, but the token is the sensitive part that must remain secret.

Steps to Rotate and Update the Webhook Token

You must have the Manage Webhooks permission on the Discord server to perform these steps. If you are not a server administrator or moderator, contact the server owner.

  1. Open the channel where the webhook is used
    Navigate to the text channel that receives messages from the webhook. Right-click the channel name or click the gear icon next to it to open Channel Settings.
  2. Go to Integrations > Webhooks
    In the left sidebar, click Integrations. Under Webhooks, you will see a list of all webhooks created for that channel. Click the webhook that is producing the error.
  3. Copy the current webhook URL
    Click the Copy Webhook URL button. This copies the full URL including the new token. Paste this URL into a text file or password manager so you can use it later.
  4. Regenerate the token manually if needed
    If you suspect the token was compromised, click the Regenerate button below the webhook name. A confirmation dialog appears. Click Regenerate to confirm. The old token stops working immediately. Copy the new webhook URL after regeneration.
  5. Update your bot code or third-party integration
    Open your application that sends messages via the webhook. Replace the old webhook URL with the new one. If you use a third-party service like GitHub, Zapier, or IFTTT, go to that service’s settings and update the webhook URL.
  6. Test the webhook
    Send a test message from your application or use the Discord webhook tester in the webhook settings. Click the Test Webhook button in Discord to verify the new token works. If the message appears in the channel, the rotation was successful.

If the Webhook Was Deleted

If the webhook was deleted entirely, you cannot recover the old ID or token. You must create a new webhook from scratch. Go to Channel Settings > Integrations > Webhooks > Create Webhook. Give it a name and avatar, then copy the new URL. Update your application with this new URL.

If You Do Not Have Manage Webhooks Permission

Contact a server administrator or moderator who has the Manage Webhooks permission. They can perform the steps above and provide you with the new webhook URL. Do not ask for the token to be sent via direct message; ask them to paste it into a private channel that only you can see.

If the Error Persists After Token Rotation

Webhook URL Contains Extra Characters

When copying the webhook URL, ensure you copy the entire string. Some applications accidentally truncate the URL or add whitespace. Paste the URL into a plain text editor and verify it matches what Discord shows. The URL format is: https://discord.com/api/webhooks/ID/TOKEN

Bot Uses an Outdated Cached Token

If your bot caches the webhook URL in memory or a configuration file, it may still use the old token. Restart the bot and clear any cached data. Check your bot’s configuration file for hardcoded webhook URLs and update them.

Third-Party Service Has a Delay

Some third-party services cache webhook URLs for several minutes. After updating the URL, wait up to five minutes and try again. If the error continues, remove the webhook from the service and add it again with the new URL.

Webhook ID Changed

Rarely, the entire webhook ID changes if the webhook was deleted and recreated. Verify that the ID in your application matches the ID in the Discord webhook settings. The ID is the numeric part of the URL between /webhooks/ and the token.

Webhook Token Update Methods: Manual vs Programmatic

Item Manual Rotation via Discord UI Programmatic Rotation via API
Permission needed Manage Webhooks on the server Manage Webhooks on the server and a bot token with proper scopes
Steps Open channel settings, regenerate token, copy URL Send PATCH request to /webhooks/ID with new token parameter
Speed Immediate, requires manual copy-paste Immediate, can be automated in code
Risk of error Low, as you see the new URL directly Medium, requires correct API endpoint and authentication
Best for Single webhook or occasional updates Multiple webhooks or frequent rotations in production

The manual method is recommended for most users because it is simple and does not require coding. The programmatic method is useful for bot developers who need to rotate tokens for many webhooks at once.

The ‘Webhook Token Invalid’ error is fixed by obtaining the current token from Discord and updating your application. Always copy the full webhook URL from the Discord interface to avoid typos. For automated systems, consider storing the webhook URL in a secure environment variable and updating it programmatically when Discord rotates the token. If the error continues, check for cached data in your application or third-party service.