API ReferenceAuthentication

Authentication Admin

The Nucleus API supports two authentication methods.

Method 1: JWT Token

JWT tokens are issued when a user logs in through the Nucleus web interface or the login endpoint.

Obtaining a token:

curl -X POST https://api.nucleusanalytica.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "your-password"}'

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": "...",
    "email": "user@example.com",
    "role": "admin"
  }
}

Using the token:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

JWT tokens expire after 7 days. After expiration, you must log in again to obtain a new token.

Method 2: API Key

API keys are created by admins in Settings > API Keys. They do not expire until manually deleted.

Using an API key:

Authorization: Bearer YOUR_API_KEY

API keys are used the same way as JWT tokens in the Authorization header.

⚠️

API keys have the same access level as the admin who created them. Treat them like passwords — never share them in emails or commit them to code repositories.

Which Method to Use

Use CaseRecommended Method
Web application loginJWT token
Server-to-server integrationAPI key
Partner data accessAPI key
Automated scriptsAPI key

Token Validation

If a token is invalid or expired, the API returns:

{
  "error": "Unauthorized"
}

HTTP status code: 401.