Skip to main content
Phoenix auth issues short-lived access JWTs and longer-lived refresh tokens. The Rise SDK can manage the session, attach bearer tokens to authenticated requests, refresh before expiry, and persist the rotated token pair. Most Phoenix market and trader read routes are public. You can fetch exchange params, market stats, orderbooks, candles, and trader state without first creating a session. Use auth when your integration needs an identified caller, higher API limits for authenticated traffic, or authenticated workflows. Auth is required for referral-code onboarding with /v1/referral/activate-tx and for notifications.
Auth does not replace Solana transaction signing. Phoenix instructions still need the correct wallet, authority, position authority, or fee payer signature depending on the instruction.

Lifecycle

  1. Request a challenge from Phoenix.
  2. Sign the challenge with the authority wallet.
  3. Exchange the signature for an auth response.
  4. Use Authorization: Bearer <access_token> on authenticated routes.
  5. Refresh with POST /v1/auth/refresh before the access token expires. Refresh returns a new access token and a new refresh token.
  6. Reauthenticate when refresh fails with a terminal auth error, or when the refresh token has expired.
The auth response shape is:
Store the full response. expires_in and refresh_expires_in are in seconds, counted from when the response was issued.

Session lifetime

A session moves through these states:
  1. Signed out. No session exists. Sign in to create one.
  2. Active. The access token is valid. Authenticated requests succeed.
  3. Access token expired. Authenticated requests fail with 401. Call POST /v1/auth/refresh with the refresh token. The refresh route does not need a valid access token.
  4. Refreshed. Refresh returns a new access token and a new refresh token, and the session is active again. The new refresh token is valid for 7 days from the refresh, so a session stays alive for as long as you refresh at least once every 7 days.
  5. Ended. The session ends when you call POST /v1/auth/logout, when 7 days pass without a refresh, or when Phoenix revokes it. Refresh then fails with a terminal error and the user must sign in again.
Refresh rules:
  • A refresh token can be used once. Refresh replaces both tokens, so store the new pair before making the next request.
  • If the same refresh token is sent again within a short window after it was used, for example by two tabs refreshing at once, the API returns the same new token pair. After that window, reusing it fails with invalid_refresh_token.
  • The previous access token is accepted for 30 seconds after a refresh, so requests already in flight do not fail.
  • POST /v1/auth/logout revokes the session and returns 204. The refresh token stops working immediately.

Endpoints

Routes that can benefit from or require auth:
  • Referral-code onboarding: see Trader Onboarding.
  • Notifications over REST or WebSocket.
  • Any protected account, user, or builder workflow marked with bearer auth in the API reference.
  • Authenticated integrations that need higher rate limits than anonymous public traffic.

Wallet login

This TypeScript example is written for a browser wallet that supports signMessage.
In Rust builds with the solana-keypair feature, auth.login_with_wallet_keypair(&keypair).await? wraps the nonce, signing, and login sequence.

Refresh

With a managed SDK session, refresh is normally automatic before authenticated HTTP and WebSocket requests. Manual refresh is still useful when you want to force rotation after loading a saved session.
Terminal refresh failures mean the user must sign in again:
  • invalid_refresh_token
  • refresh_expired
  • session_missing

Auth errors

Auth errors use the standard API error shape:
Common unauthenticated or reauthentication cases: