Sessions and tokens
Access tokens, refresh tokens, how long a session lives, and how to end one, including sessions that never expire.
A signed-in person or machine holds two things.
| What it is | Lifetime | Where it lives | |
|---|---|---|---|
| Access token | A JWT signed by the project, sent on every request | 1 hour by default | In memory (the SDK) |
| Refresh token | syp_rt_…, a long random string that gets a new access token | As long as the session | Secure storage, or an HttpOnly cookie |
The access token
Signed with EdDSA (Ed25519). Your own servers can verify it without calling the engine, with the public keys at /.well-known/jwks.json.
{
"iss": "https://<ref>.data.sypnia.com/auth/v1",
"sub": "7c0e…",
"aud": "authenticated",
"role": "authenticated",
"exp": 1795000000, "iat": 1794996400, "jti": "…",
"session_id": "b1f2…",
"aal": "aal1",
"amr": [{ "method": "password", "timestamp": 1794996400 }],
"email": "ana@example.com",
"app_metadata": { "provider": "email" },
"user_metadata": { "name": "Ana" }
}role is the database role the Data API uses. user_metadata is left out when it is larger than 2 kB, to keep tokens small; read it with getUser().
The refresh token rotates
Every use returns a new refresh token and retires the old one. If a retired token comes back after the reuse window (10 seconds, for two tabs refreshing at once), the engine assumes it was stolen: it ends the whole session and writes refresh_token_reuse to the audit log. The person signs in again; the thief’s copy is dead.
How long a session lives
Each project has a session policy. Every value can be changed in the console or with the API, and each limit can be never:
| Setting | Default | Values |
|---|---|---|
access_token_ttl | 3 600 s | 300 to 86 400 s |
session_lifetime | never | seconds (at least 60), or never |
inactivity_timeout | never | seconds since the last refresh (at least 60), or never |
single_session | off | on: a new sign-in ends the user’s other sessions |
refresh_reuse_interval | 10 s | 0 to 60 s |
A value outside its range is refused with 400 invalid_session_policy, and the message names the field and its range; the same goes for a client’s own policy. A new policy applies to sessions that start after it; the settings are cached for up to a minute.
Machines signed in with the device flow follow their client’s policy instead, so an agent can keep a session that never expires while your users’ sessions end after 30 days.
Ending sessions
signOut()ends this device;signOut({ scope: 'others' })the others;signOut({ scope: 'global' })all.- A person lists their devices with
sessions.list()and ends any of them. - An admin (secret key or the console) can end every session of a user, ban a user until a date, or delete them.
- Changing a password ends every other session.
Signing keys
Each project has its own Ed25519 keys, encrypted at rest (with AWS KMS in Sypnia Cloud, or with your master key when you self-host). To rotate: a new key is published in the JWKS first, used for signing 24 hours later, and the old one stays published until every token it signed has expired. No one is signed out.