Documentation Menu

Webhook returns HTTP 401

HTTP 401 means the receiver did not accept the request credentials. For webhooks, this most often points to a missing signature header, wrong secret, malformed authorization token, or verification against altered bytes.

Distinguish authentication methods

MethodEvidence
HMAC signatureProvider-specific signature header plus raw body.
Bearer tokenAuthorization header with the expected token and scheme.
Basic authenticationAuthorization header and matching server configuration.
Custom shared secretDocumented header or query value; avoid secrets in URLs where possible.

Likely causes

  • The provider and receiver use secrets from different environments.
  • A secret was rotated on one side only.
  • A reverse proxy removes or renames the required header.
  • The receiver verifies a parsed body rather than the original bytes.
  • The signature encoding or prefix does not match the provider contract.

Diagnosis procedure

  1. Identify the authentication scheme configured for this provider and endpoint.
  2. Confirm the required header reached the application without logging the full secret or token.
  3. Compare secret identifiers, environment, rotation time, algorithm, and encoding on both sides.
  4. For HMAC, recompute the digest over the captured raw body and compare it using a timing-safe function.
  5. Review proxy and framework middleware for header or body transformations.
  6. Send a new event after synchronizing credentials.

Return safe errors

Return a short 401 response to the sender, but keep the detailed reason in protected application logs. Do not return the expected signature, secret, or token value.

Verify the fix

  • A newly delivered request includes the expected authentication header.
  • Verification succeeds without exposing credentials in logs.
  • Old credentials no longer work after a completed rotation.

Was this page helpful?

Your feedback helps us improve the docs.