Authentication

Sessions and tokens

Access tokens live for one hour; refresh tokens for 30 days and rotate on every refresh. Reusing a replaced refresh token revokes the whole family.

The token pair

TokenFormatDefault lifetimeUse
accessTokenHS256 JWT1 hourBearer token on Data API and user endpoints
refreshTokenOpaque, stored hashed30 daysExchange for a new pair; never sent to the Data API

The access token’s claims include sub (the user id), email, session_id, amr (how the session authenticated: pwd, mfa, oauth, or empty for anonymous), and the expiry. Both lifetimes are configurable per project.

The session lifecycle

Email and password return an access JWT and a refresh token.

accessToken · 1 h

Illustration with fictional tokens. It does not query CubiBase.

Refreshing

Refresh · request
POST https://example-project.api.cubibase.com/auth/v1/token?grant_type=refresh_token
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "refreshToken": "<REFRESH_TOKEN>"
}
  • A refresh issues a new access token and a new refresh token, and retires the old one.
  • The session id stays the same across refreshes, so the Console shows one session, not dozens.
  • Store the new pair atomically: the old refresh token is dead the moment the response arrives.

Revocation is immediate

Every Data API request checks that the session behind the token is still live and the user is not banned. Revoking a session (logout, or the Console’s Sessions screen) or banning a user takes effect on the next request — not when the access token expires.

Logout · request
POST https://example-project.api.cubibase.com/auth/v1/logout
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "refreshToken": "<REFRESH_TOKEN>"
}
SituationNext request returns
Session revoked401 session_revoked
User banned403 user_banned
Project requires MFA, session lacks it401 mfa_required
Access token expired401 invalid_token

Additional resources