Nudg3Docs

Authentication

Learn how to authenticate with the Nudg3 API using API keys

Authentication

The Nudg3 API uses API keys to authenticate requests. All API requests must include a valid API key in the request headers.

API Key Format

Nudg3 API keys follow a specific format:

nudg3_[env]_ak_[key_id]_[random_chars]
PartDescription
nudg3Prefix identifier (always present)
[env]Environment: live for production, test for sandbox
akAPI key type identifier
[key_id]8-character unique key identifier
[random_chars]32-character cryptographically secure random string

Example Key

nudg3_live_ak_a1b2c3d4_xYz9AbCdEf...

The key format allows Nudg3 to quickly identify invalid keys without database lookups, reducing latency for error responses.

Using Your API Key

Include your API key in the Authorization header using the Bearer scheme:

curl https://api.nudg3.ai/api/v1/dashboard \
  -H "Authorization: Bearer nudg3_live_ak_your_key"

Alternatively, you can use the X-API-Key header:

curl https://api.nudg3.ai/api/v1/dashboard \
  -H "X-API-Key: nudg3_live_ak_your_key"

The Authorization: Bearer method is recommended as it follows OAuth 2.0 conventions.

Creating API Keys

  1. Log in to your Nudg3 Dashboard
  2. Go to Settings > API Keys
  3. Click Create New Key
  4. Configure your key:
    • Name: A descriptive name for the key
    • Scopes: Permissions for the key (see below)
    • IP Allowlist (optional): Restrict key usage to specific IPs
  5. Click Create and copy your key

API keys are only shown once at creation. Store them securely!

Scopes and Tiers

API keys have scoped permissions organized into two tiers:

API Tiers

TierScopesDescription
Basic (Tier 1)read:analyticsCore analytics access
Premium (Tier 2)read:analytics + export:dataAnalytics + data exports

Available Scopes

ScopeDescriptionEndpoints
read:analyticsRead analytics data/dashboard, /brands, /prompts, /sources, /urls, /responses, /aio-metrics, /filters
export:dataExport data to CSV/TSV/exports/*

Export endpoints require both read:analytics and export:data scopes. A key with only read:analytics cannot access export endpoints.

Checking Key Scopes

The API returns your key's scopes in the rate limit response headers:

X-API-Scopes: read:analytics,export:data
X-API-Tier: premium

Security Best Practices

Environment Variables

Store API keys in environment variables, not in code:

# .env file
NUDG3_API_KEY=nudg3_live_ak_your_key
// Access in code
const apiKey = process.env.NUDG3_API_KEY;

Key Rotation

Regularly rotate your API keys:

  1. Create a new key with the same scopes
  2. Update your applications to use the new key
  3. Verify everything works
  4. Revoke the old key

IP Allowlisting

For production keys, restrict usage to known IP addresses:

  1. Go to Settings > API Keys
  2. Edit your key
  3. Add allowed IP addresses or CIDR ranges
  4. Save changes

Never Expose Keys

  • Don't commit keys to version control
  • Don't include keys in client-side JavaScript
  • Don't share keys in public forums or documentation
  • Do use environment variables
  • Do use server-side code to make API calls

Revoking Keys

If a key is compromised:

  1. Go to Settings > API Keys
  2. Find the compromised key
  3. Click Revoke
  4. Create a new key
  5. Update your applications

Revoked keys are immediately invalidated. All requests using that key will fail with a 401 error.

Error Responses

Authentication errors return specific error codes:

HTTP CodeErrorDescription
401invalid_api_keyAPI key is invalid or malformed
401expired_api_keyAPI key has been revoked
403insufficient_scopeKey lacks required scope
403ip_not_allowedRequest from non-allowlisted IP

Example error response:

{
  "error": {
    "code": "invalid_api_key",
    "message": "The provided API key is invalid",
    "hint": "Check that you're using the correct key format"
  }
}

Next Steps

On this page