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

20157: Expiration Time Exceeds Maximum Time Allowed


ERROR: 20157

error-20157 page anchor
API, IAM
ERROR

This error occurs when the expiration time used while creating an Access Token JWT exceeds 24 hours, which is the maximum allowed lifetime. This behavior is documented on the error page and the Access Tokens overview, which states tokens are "configurable for up to 24 hours."

Possible causes

possible-causes page anchor
  • The ttl parameter provided when generating the Access Token is greater than 86400 seconds (24 hours). The Access Tokens overview sets a 24-hour maximum and specifies ttl is expressed in seconds.
  • The token's exp claim is set so that its lifetime exceeds 24 hours relative to issuance; Access Tokens are JWTs that include an exp claim as shown in Twilio's examples.
  • Passing time values in milliseconds instead of seconds for ttl, inadvertently creating a value above the 24-hour maximum. Twilio materials indicate ttl is in seconds and blog guidance notes the maximum must be given as 86400 seconds.
  • Set the Access Token ttl to a value at or below 86400 seconds, and in general keep it as short as feasible for your application (best practice noted by Twilio).
  • If you manually construct tokens, compute exp so that it does not exceed 24 hours after issuance, or rely on the helper to set exp based on ttl. Twilio's examples show the exp claim and parameterization for ttl.
  • Ensure you are providing ttl in seconds, not milliseconds; for example, 3600 for one hour or 86400 for the maximum. Twilio documentation specifies ttl is in seconds, and the Twilio blog reiterates the 24-hour limit as 86400 seconds.
  • Implement short-lived tokens with periodic refresh in clients where applicable; Twilio recommends shorter token lifetimes and details token refresh patterns (for example, in Sync SDK guidance).

Additional resources

additional-resources page anchor