Skip to main content
Every request to a protected SphereScout endpoint must include an 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

For most integrations, API keys are the simpler and more reliable choice. Use JWT tokens only when your application needs to act on behalf of a specific logged-in user.

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.
See API keys for how to create, list, and revoke keys.

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.
Response fields
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 the Authorization header of every request:

Step 3 — Refresh the access token

Access tokens expire after a short period. When a request returns 401 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.
Response fields
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

A 401 response means your credential is missing, invalid, or expired.
What to do:
  • 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/refresh with 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 calling POST /api/auth/login again.

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.