Understanding JWT exp, iat, and nbf Unix Timestamp Claims
An API returning 401 Unauthorized immediately after a user logs in usually points to a timestamp mistake inside the JSON Web Token. Sending 13-digit JavaScript milliseconds inside an exp field pushes the token thousands of years forward, while clock drift between auth servers triggers premature rejections.
The Three Standard JWT NumericDate Claims
According to IETF RFC 7519, a JWT NumericDate is always a JSON integer representing Unix seconds since January 1, 1970 UTC. Never put milliseconds or ISO strings inside these three registered claims:
| Claim | Full Name | Purpose in Authentication |
|---|---|---|
exp | Expiration Time | Reject the token at or after this exact Unix second. |
iat | Issued At | Records when the token was signed; useful for calculating token age. |
nbf | Not Before | Reject the token before this Unix second arrives. |
Example JWT Payload Using Unix Seconds
Here is a valid payload issued on December 5, 2026 with a 15-minute (900-second) lifespan:
{
"sub": "user_4821",
"iat": 1764892800,
"nbf": 1764892800,
"exp": 1764893700
}
How to Prevent Clock Skew Failures With Leeway
When one microservice issues a JWT and a second server verifies nbf or exp a fraction of a second later, a tiny NTP clock difference can reject a brand-new token. RFC 7519 recommends allowing a small leeway (typically 30 to 60 seconds) during verification.
// Node.js jsonwebtoken verification with 30s clock tolerance
jwt.verify(token, publicKey, {
algorithms: ["RS256"],
clockTolerance: 30
});