Authentication
Pick the right auth mode. API keys for backends, Supabase tokens for user apps.
The SDK supports three ways to authenticate, in order of precedence:
apiKey: static team API key.getToken: async function that returns a token per request.- No auth, only public endpoints like
/healthwill respond.
All of them send the token as Authorization: Bearer <token>.
Team API keys
Use these for server code, cron jobs and scripts where the credential belongs
to a team, not a person. Never in a browser: Aden refuses a key sent from one
(403 server_only).
const aden = createAdenClient({
apiKey: process.env.ADEN_API_KEY,
})- Format:
aden_followed by 64 hex characters. - Bound to one team. Pass that team as
teamIdon list endpoints; any other team is refused. - Read only keys can only read. Read & write keys can also change milestones, tasks, contacts, webhooks and app data.
- Reaches these endpoints only.
- Rate-limited by the team's plan. See Rate limits.
Supabase session tokens
Use these for apps where a real person logs in. You re-use the Supabase access token the user already has, so Row Level Security policies apply.
import { createClient } from '@supabase/supabase-js'
import { createAdenClient } from '@adenspace/sdk'
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
export const aden = createAdenClient({
getToken: async () => {
const { data } = await supabase.auth.getSession()
return data.session?.access_token ?? null
},
})getToken runs on every request, so refreshes and sign-outs are picked up
automatically.
Custom providers
getToken is just an async function. Plug it into any auth stack:
const aden = createAdenClient({
getToken: async () => {
const token = await auth0.getAccessTokenSilently({
audience: 'https://aden.space/api/v1',
})
return token ?? null
},
})Return null to make an unauthenticated request.
What each mode can do
| Scenario | API key | Session token |
|---|---|---|
| Read tracks, albums, shows, posts | ✅ | ✅ |
| Change milestones, tasks, contacts | ✅ (Read & write key) | ✅ |
| Create tracks, upload audio, collaborators | ❌ | ✅ |
Chat, team management, auth.me, user.* | ❌ | ✅ |
| From a browser | ❌ | ✅ |
| Teams reached | Its own team | The person's teams |
| Rate limit bucket | Team plan | Per person and app |
Storing keys safely
- Never put a key in client-side code. Aden refuses a key from a browser, and a mobile app leaks it to anyone who unpacks it.
- For apps people sign in to, use Supabase tokens.
- Revoke a key on Team → API if you suspect it leaked. It stops working within a minute.
Was this helpful?