Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

51121: Twilsock: Token expiration time exceeds maximum


ERROR: 51121

error-51121 page anchor
ERROR

This error occurs when Twilsock receives an Access Token whose exp value is beyond the allowed lifetime. Twilio Access Tokens are short-lived JWT credentials, and their maximum age is 24 hours.

Possible causes

possible-causes page anchor
  • Your application generated the token with a ttl value greater than 86400 seconds. Twilio interprets ttl in seconds and limits Access Tokens to 24 hours.
  • The token's exp claim is set more than 24 hours after issuance. Twilio uses exp as the expiration timestamp and limits token age to 24 hours.
  • Your token generation logic used the wrong time unit or an incorrect timestamp calculation, which caused the expiration to exceed the allowed range. Access Token lifetime values are expressed in seconds.
  • Generate a new Access Token with a ttl of 86400 seconds or less. Use the shortest lifetime that fits your application.
  • If you set claims directly, verify that exp is no more than 24 hours after iat and that all time values are in seconds.
  • Use a Twilio helper library to create the token so the JWT structure and claims are generated correctly. Twilio recommends helper libraries when troubleshooting invalid Access Tokens.
  • For long-lived SDK sessions, refresh the token before it expires instead of extending a single token beyond the 24-hour limit. Conversations SDK clients can request a new token and call updateToken before expiration.

Additional resources

additional-resources page anchor