Docs

API keys

The anon, service role and custom keys: what each can do, where to use it, and how to rotate and revoke keys.

Updated Oct 13, 2026

Every request carries either an API key or a signed-in user's session. Keys belong to one project; using a key against another project is refused.

API keys pageAPI keys page
Project settings → API keys: the built-in anon and service role keys, custom keys, and the JWT signing key your users' sessions are signed with.

#Key types

KeyUse it inAccess
Anon (publishable)Browsers, mobile apps, public clientsAn anonymous visitor: auth.uid() is empty and your policies decide everything.
Service roleYour servers and CI onlyFull access; bypasses row-level security and the default rules (only a DENY rule you write stops it). Treat it like a database password.
CustomOne integration or jobA role you choose (admin, editor, or viewer — read-only) and an optional expiry; row-level security treats it as anon.

#Sending a key

Use apikey: <key> or Authorization: Bearer <key>. The SDKs do this for you from the second argument of createClient.

#Create, rotate and revoke

  • The full value of a new key is shown once — copy it into your secret store straight away.
  • Rotate creates a replacement and revokes the old key; apps still using the old one stop working, so deploy the new value first.
  • Owners and admins get an email whenever a key is created or revoked.
sov keys list
sov keys create --name ci-deploy --role admin   # printed once
sov keys revoke <key-id>

#Server code and CI

On a server, pass the service role (or a custom) key as the second argument of createClient. The key already names its project, so no org or project ids are needed. In CI, give the CLI the key through an environment variable instead of sov login; saved logins and linked projects are ignored while a key is set.

import { createClient } from '@sovaria/sdk'

const sovaria = createClient(process.env.SOVARIA_URL, process.env.SOVARIA_SERVICE_ROLE_KEY)
const { rows } = await sovaria.data.sql('select count(*) from notes')

SOVARIA_ACCESS_TOKEN works the same way for a short-lived user session token. Every HTTP route is also available as sovaria.api.<area>.<method> in both SDKs; both are generated from one API description, so they send identical requests.

#How Sovaria stores keys and passwords

  • Service role and custom keys are stored only as a keyed hash (HMAC-SHA-256 with a server-side secret). Nobody, including Sovaria staff, can read them back; a lost key must be rotated.
  • The anon key is public by design, so it is also kept encrypted (AES-256-GCM) so the console can show it again.
  • User passwords are hashed with bcrypt (cost 12) and never stored or logged in plain text. MFA secrets are encrypted with AES-256-GCM; backup codes are bcrypt-hashed.
  • OAuth provider secrets, function secrets and database credentials are encrypted at rest and never returned by the API after you save them.

#Verifying user sessions in your own backend

App-user access tokens are JWTs signed with your project's own key (ES256, P-256). Verify them in your own API with the public key set at https://<project-ref>.sovarias.in/auth/v1/.well-known/jwks.json — no call to Sovaria per request needed. Tokens last 15 minutes; the SDK refreshes them for you.

ClaimValue
isshttps://<project-ref>.sovarias.in/auth/v1 — check it, so a token from another project is refused.
audauthenticated
subThe app user's id (the same value as auth.uid() in SQL).
role, app_roles, emailThe user's role and the app roles you assigned under Authentication → Users.
exp, iat, jtiExpiry, issue time and a unique token id.
import { createRemoteJWKSet, jwtVerify } from 'jose'

const issuer = 'https://<project-ref>.sovarias.in/auth/v1'
const jwks = createRemoteJWKSet(new URL(`${issuer}/.well-known/jwks.json`))

export async function userFrom(req) {
  const token = req.headers.authorization?.replace(/^Bearer /, '')
  const { payload } = await jwtVerify(token, jwks, { issuer, audience: 'authenticated' })
  return { id: payload.sub, roles: payload.app_roles ?? [] }
}

#Coming from Firebase or Supabase?

PlatformWhat this is called there
FirebaseFirebase API keys and service accounts
SupabaseSupabase anon and service_role keys
SovariaAPI keys

Moving an existing app? Migrate from Supabase or Firebase imports users (with their passwords), data, files and rules.