Bearer token authentication
Include your access token in theAuthorization header on every request to a protected endpoint:
401 Unauthorized:
Obtaining an access token
There are two ways to get an access token depending on your signup flow.Email-verified signup (two-step)
Use this flow when registering a new user by email:POST /api/v1/auth/request-verification— send a verification emailPOST /api/v1/auth/verify-token— confirm the token is valid and prefill the formPOST /api/v1/auth/complete-signup— create the account and receive an access token
complete-signup response includes the access_token you use for subsequent requests.
Firebase-based signup
If you authenticate users through Firebase (e.g. Google Sign-In, Apple Sign-In), exchange the Firebase ID token for an Astral access token:access_token and expires_at timestamp.
Token expiration and refresh
Access tokens expire. Check theexpires_at field in the auth response and refresh before expiry:
API key authentication for organizations
Organization integrations (e.g. importing data, managing members in bulk) can authenticate with an API key instead of a user token. Pass the key in theX-API-Key header:
401 Unauthorized:
API keys are only shown once at creation time. Store them securely — they cannot be retrieved after that point.
Making an authenticated request
Here is a complete example that fetches the current user’s profile after sign-in:Common authentication errors
| Status | Error | Cause |
|---|---|---|
401 | No authentication token provided | Authorization header is absent |
401 | No API key provided | X-API-Key header is absent |
401 | Invalid API key | The API key does not match any active key |
401 | token validation error | Token is expired, malformed, or revoked |
403 | Insufficient permissions | Token is valid but the user lacks the required role |