Authorization header. The API supports two authentication methods: API keys for server-to-server integrations and JWT bearer tokens for user-session-based applications. Both use the same header format — only the credential type differs.
Choose an authentication method
API key authentication
API keys are long-lived credentials that you generate in the Dashboard or via the API. Include your API key directly as the Bearer token in every request.JWT token authentication
JWT authentication involves three steps: logging in to obtain tokens, using the access token in requests, and refreshing the access token before it expires.Step 1 — Obtain tokens
Send a POST request to/api/auth/login with your account credentials. The response contains an access token and a refresh token.
Request
string
required
Your account email address. The field is named
username in the request body.string
required
Your account password.
string
required
Short-lived JWT access token. Use this as your Bearer token in subsequent requests.
string
required
Long-lived refresh token. Use this to obtain a new access token when the current one expires. Store this token securely — treat it like a password.
object
Account information returned at login.
Step 2 — Use the access token
Include the access token as a Bearer token in theAuthorization header of every request:
Step 3 — Refresh the access token
Access tokens expire after a short period. When a request returns401 Unauthorized, exchange your refresh token for a new access token by calling POST /api/token/refresh.
Request
string
required
The refresh token you received when you logged in.
string
required
A new short-lived access token. Replace the expired token in your application with this value.
string
A new refresh token, if token rotation is enabled. Update your stored refresh token if this field is present in the response.
Error responses
401 Unauthorized
A401 response means your credential is missing, invalid, or expired.
- API key: Verify the key is correctly copied and has not been revoked in the Dashboard.
- JWT access token: The token has expired. Call
POST /api/token/refreshwith your refresh token to get a new access token. - JWT refresh token: If the refresh call also returns
401, the refresh token has expired or been invalidated. Re-authenticate by callingPOST /api/auth/loginagain.
Full JWT refresh pattern
The following Python example shows a complete pattern for handling token expiry automatically:Python
Summary
For server-to-server integrations, use an API key — it requires no token management and works with a single header on every request. Reserve JWT tokens for applications where individual users log in with their own SphereScout credentials.