Slack API · error code

Slack error invalid_auth: Authentication cannot be validated

ConfigurationHTTP 200Tokens & authentication

Last verified against Slack API reference - chat.postMessage errors

What Slack returns
Some aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.

What error invalid_auth means

Slack received a token but could not validate the authentication, and its documented description names the two branches explicitly: "Either the provided token is invalid or the request originates from an IP address disallowed from making the request." Most developers only ever consider the first branch, which is why the second one — IP allowlisting — produces the confusing cases where the same token works from a laptop and fails from production.

On the token branch, "invalid" means the string itself does not resolve to a live credential. Common shapes: the token was truncated or gained whitespace when pasted into a secrets manager; it belongs to a different app or a different workspace than the one you are calling about; it is the wrong kind of token entirely, such as an xapp- app-level token (valid only for Socket Mode and app-level connections) sent to a Web API method that needs an xoxb- bot token; or it is a stale value from an earlier install that has since been superseded. A token that was valid and was then explicitly killed usually returns token_revoked instead, but the boundary is not something to rely on — treat invalid_auth on a previously working integration as "re-check the whole credential path".

On the IP branch, an Org or workspace admin can restrict where API requests for an app may originate. When your traffic leaves from an address outside that allowlist — a new NAT gateway after an infrastructure change, a different egress IP per serverless invocation, a CI runner — Slack answers invalid_auth even though the token is perfectly good. The error string gives you no hint which branch you are on, so the diagnostic below separates them deliberately.

In the official SDKs this surfaces like any other platform error: Node's @slack/web-api rejects with error.code === ErrorCode.PlatformError and the body in error.data; Python's slack_sdk raises SlackApiError with e.response["error"] == "invalid_auth". Neither retries it, because retrying an authentication failure cannot succeed.

What it looks like

{"ok": false, "error": "invalid_auth"}

Why it happens

  • The token string is corrupted: truncated, wrapped, or carrying invisible whitespace from a copy-paste into a secrets manager or CI variable.
  • The token belongs to a different app or workspace than the one the request targets (staging token in production is the classic).
  • The wrong token type is in use — an xapp- app-level token or a webhook URL fragment where an xoxb- bot token is required.
  • The request originates from an IP address outside an allowlist configured by a workspace or org admin.
  • The token predates a reinstall and a newer token has replaced it, with the old value still cached in a long-lived process.

How to fix Slack error invalid_auth

  1. 1Run auth.test with the exact token from the failing environment: curl -s -H "Authorization: Bearer $TOKEN" https://slack.com/api/auth.test. If it fails from your laptop too, the token itself is bad.
  2. 2Compare the token byte-for-byte with the value shown under OAuth & Permissions (or your last oauth.v2.access response); check length and the xoxb-/xoxp- prefix.
  3. 3Confirm the token type matches the method: Web API methods need bot or user tokens, never app-level xapp- tokens.
  4. 4If auth.test succeeds locally but fails from production, ask the workspace admin whether an IP allowlist is configured, and add your egress IPs.
  5. 5After any reinstall, redeploy with the newly issued token and restart long-lived processes so no cached copy survives.
  6. 6Rotate the token (reinstall the app) if you cannot account for its history — a mangled secret is not worth archaeologizing.

How to stop it recurring

Validate credentials at boot with auth.test and log the resolved team and bot_id, which catches wrong-workspace tokens immediately. Keep staging and production apps as separate Slack apps with separate tokens so a cross-environment paste is impossible to miss. When infrastructure changes your egress IPs, treat Slack IP allowlists as part of the migration checklist. A broader walkthrough is in Slack bot not responding.

Official reference: Slack API reference - chat.postMessage errors. See all Slack error codes or the Slack limits and quotas.

Related codes

Error invalid_auth - quick answers

What does Slack error invalid_auth mean?

Slack received a token but could not validate the authentication, and its documented description names the two branches explicitly: "Either the provided token is invalid or the request originates from an IP address disallowed from making the request." Most developers only ever consider the first branch, which is why the second one — IP allowlisting — produces the confusing cases where the same token works from a lapt

How do I fix Slack error invalid_auth?

1. Run auth.test with the exact token from the failing environment: curl -s -H "Authorization: Bearer $TOKEN" https://slack.com/api/auth.test. If it fails from your laptop too, the token itself is bad. 2. Compare the token byte-for-byte with the value shown under OAuth & Permissions (or your last oauth.v2.access response); check length and the xoxb-/xoxp- prefix. 3. Confirm the token type matches the method: Web API methods need bot or user tokens, never app-level xapp-…

Stop debugging Slack by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.