opyeb JWTScope

Guides · Token basics

exp, nbf and iat: time claims that decide whether a token works

Updated 28 Nov 2026 · 7 min read

Three registered claims carry time: exp (expiration time), nbf (not before) and iat (issued at). All three are NumericDate values — seconds since 1970-01-01T00:00:00Z, as a JSON number, without a timezone. A token with "exp": 1795862400 is valid until 2026-11-28 08:00:00 UTC. Writing "2026-11-28T08:00:00Z" or a value in milliseconds is a specification violation that different libraries handle differently, which makes it a reliable source of confusing bugs.

The semantics are simple. A verifier must not accept a token when the current time is at or after exp, and must not accept it before nbf. iat records when the issuer created the token; it is informational for most services but useful for detecting tokens that claim to come from the future and for calculating age.

Clock skew is real

Two machines rarely agree on the exact second. Container hosts drift, virtual machines pause, and a laptop that has been asleep can be minutes off. If an issuer stamps iat from its clock and a verifier compares it with its own, a token can arrive apparently from the future. If exp is calculated as one hour after iat, the same drift also shortens or lengthens the accepted window.

The practical answer is a small symmetric allowance, usually 30 to 120 seconds, applied to exp, nbf and iat. The allowance should be a named configuration value so that its size is visible in review. An allowance of an hour is not clock skew; it is a policy that keeps expired tokens alive far too long.

Consider a token with iat 1795858800 and exp 1795862400 — one hour. At 07:59:30 UTC a verifier with a 60-second skew accepts it. At 08:00:30 it still accepts it under that allowance, because 08:00:30 minus 60 seconds is before exp. At 08:01:01 it rejects it. Without the allowance, the window would end exactly at 08:00:00, and a verifier whose clock is 20 seconds fast would reject valid tokens for the last 20 seconds of every hour.

ClaimMeaningValue typeEnforced by the verifier?
expToken must not be accepted at or after this timeNumericDate secondsYes, with skew
nbfToken must not be accepted before this timeNumericDate secondsYes, with skew
iatWhen the issuer created the tokenNumericDate secondsUsually only a future check
auth_timeWhen the user actually authenticated (OIDC)NumericDate secondsPolicy dependent

Lifetime is a security parameter

A signed token cannot be un-signed. If a token with a 30-day expiry is stolen, the attacker can use it for 30 days unless the service keeps a deny list or rotates a signing key. That is why access tokens are short: five to fifteen minutes for high-value APIs, up to an hour for ordinary ones. Refresh tokens, which are stored server-side and can be revoked, carry the long-lived part of the session.

A very short lifetime has a cost too. Every expiry means another refresh round trip, and a clock that jumps can cause a burst of 401 responses. A common compromise is 15 minutes for access tokens with refresh rotation, plus a small skew allowance. The audit on this page flags lifetimes above one day as medium and above 30 days as high.

Debugging the three time failures

  1. Expired token. The decoded exp is in the past. Check the issuer's lifetime setting and whether the client refreshes before the expiry rather than after a 401.
  2. Not yet valid. nbf or iat is ahead of the verifier's clock. Compare the server clock with NTP and check whether the issuer writes milliseconds.
  3. Immediately expired. exp equals or precedes iat, often because one field was set from seconds and the other from milliseconds, or because a negative lifetime was passed to the library.

The claim table in the verifier shows each of these as a UTC timestamp next to a relative phrase such as in 12.4 min or 3.1 h ago. That makes an off-by-a-thousand error obvious: an expiry that reads 1970 or the year 56000 is a units bug, not a policy choice.

What not to put in exp

Do not use exp as a session timeout for inactivity. It is an absolute time fixed at issue. If you need idle timeout, track last activity on the server or issue short tokens and refresh them only while the user is active. Do not extend exp by editing the token, which invalidates the signature; issue a new token instead.

Also resist the temptation to give machine-to-machine tokens multi-year lifetimes to avoid refresh logic. A long-lived credential in a config file is exactly the credential that leaks in a repository and stays valid after the incident is closed. Client-credentials flows can mint a new short token on each start, and the cost is one request.

Check time on the server, never only in the browser. A client-side expiry check is a convenience for the user interface, not an access control.

Sources

Questions

Should a verifier reject a token exactly at exp?

The specification says the token must not be accepted on or after exp. In practice allow a small clock skew — 30 to 120 seconds is common — because issuer and verifier clocks drift. The skew must be a configured constant, not an open-ended grace period.

Is nbf required?

No, but when present it must be honoured. A token with nbf in the future is not yet valid. Some systems use nbf instead of iat to avoid the ambiguity of an issued-at time that is only informational.

How long should an access token live?

Minutes rather than days. Five to sixty minutes is the usual range, with a refresh token used to obtain a new access token. The longer the lifetime, the longer a stolen token stays useful, because a signed token cannot be revoked without a server-side deny list.

Decode a token and the claim table shows each time claim as a UTC date and as a countdown.

Open the verifier

Written against the JOSE specifications (RFC 7515–7519), RFC 7636 and RFC 8037; every example can be reproduced in the verifier linked above.

Back to the guides