Skip to contentSkip to navigationSkip to topbar
Page toolsOn this pageProducts used
Looking for more inspiration?Visit the
Error
Twilio error

20151: Authentication Failed

Twilio API Documentation and Error CodesAPI

Description

description page anchor

This error indicates that authentication with the provided JWT failed when Twilio attempted to validate the token for an API/SDK request. It is listed in Twilio's Error and Warning Dictionary as Authentication Failed under API errors. Twilio Access Tokens are JWTs used to authenticate client-side SDKs, and incorrect or invalid tokens will fail authentication.

Possible causes

possible-causes page anchor
  • Invalid JWT header.
  • Invalid iss or sub values in the token.
  • Invalid claim set in the token payload.
  • Token time-related issues, such as expiration set in the future, expired or invalid expiration, or expiration exceeding the maximum allowed lifetime.
  • Re-generate the Access Token on your server using the correct API Key SID and secret, and ensure the token header and payload are properly formed: typ must be JWT, alg must be HS256, and cty must be twilio-fpa;v=1; include required claims like iss (API Key SID), sub (Account SID), iat, and appropriate grants.
  • Verify token lifetime settings: set exp within the permitted window (tokens are short‑lived and have a maximum age of 24 hours) and avoid setting nbf in the future relative to the server time. If needed, reissue a fresh token.
  • Use the Twilio Console Debugger and error logs to inspect the specific event and any accompanying, more granular token error codes to pinpoint the underlying cause.

Additional resources

additional-resources page anchor