# "JWT expired" / Clerk session token expired, explained

> Clerk session tokens are short-lived on purpose, with their exp claim set by a dashboard JWT template setting. The near-expired error almost always traces to a token read once and reused manually instead of re-fetched. The fix.

Source: https://scribase.com/clerk-session-token-expired

Clerk's SDKs are built to re-fetch a fresh session token for you on every request that needs one; a stored, cached, or manually-copied token is the thing that actually goes stale and throws an expiration error, not the session itself.

## Why the token expires

Clerk's own reference describes the token's exp claim as "the time after which the token will expire, as a Unix timestamp. Determined using the Token lifetime JWT template setting in the Clerk Dashboard" — meaning session tokens are intentionally short-lived by design, with the exact lifetime configurable per JWT template rather than fixed.

The error usually surfaces when a token is read once (say, at page load or a background job's start) and reused for later requests, instead of being fetched fresh through the SDK right before each call that needs it.

## Sources

- [Clerk: Session tokens](https://clerk.com/docs/backend-requests/resources/session-tokens)

## The fix

- Call the SDK's token getter (e.g. getToken() client-side, or the server-side session helper) immediately before the request that needs it, rather than storing a token in a variable, cookie, or cache for later reuse across multiple calls.
- For a long-running background job or worker that needs auth beyond a short-lived session token, use a machine-to-machine credential (a Clerk Secret Key backend call, or an M2M token) instead of trying to keep a user session token alive artificially.
- If verification happens on your own backend, check for clock skew between your server and Clerk — a server clock that runs ahead can make a still-valid token look expired early.
- If the lifetime itself is the problem (tokens expiring faster than your use case needs), the Token lifetime setting on the JWT template in the Clerk Dashboard is the documented place to change it, not a client-side workaround.

## Sources

- [Clerk: Session tokens](https://clerk.com/docs/backend-requests/resources/session-tokens)

## One less token to manage

Scribase Auth issues its own session tokens as part of the same project as the database, and a row level security policy reads the signed-in user with auth.uid() directly — there is no separate sync step or second system's token lifetime to coordinate against, the way a Clerk session token has to stay valid long enough to reach a separately-hosted database.

## Sources

- [Scribase pricing](https://scribase.com/pricing)

## FAQ

**Can I make the session token last longer?**

Yes — the Token lifetime setting on the relevant JWT template in the Clerk Dashboard controls the exp claim; this is the documented place to change it.

**Why does my token work right after login but fail later in the same session?**

The token itself expired and your code is reusing the old one instead of fetching a fresh one — the SDK is built to refresh it automatically if you call the token getter again rather than caching the first result.

**Is this the same thing as the user being logged out?**

No — the user's session can still be active while a specific stored token has expired; re-fetching a token through the SDK (not re-authenticating) is usually all that's needed.

**Does a background job need a session token at all?**

Usually not — a backend job that runs with no interactive user present is a better fit for a machine credential (Secret Key backend call) than for trying to keep a short-lived user session token alive.

## Related

- [Clerk vs Supabase Auth](https://scribase.com/clerk-vs-supabase-auth)
- [Clerk webhook signature verification failed](https://scribase.com/clerk-webhook-signature-verification-failed)
- [Clerk rate limit exceeded](https://scribase.com/clerk-rate-limit-exceeded)
- [Clerk alternative](https://scribase.com/clerk-alternative)