Authentication

Secure API access with bearer token authentication

AssuranceHub uses API keys to authenticate requests. You can manage your API keys in your dashboard and must include them in all API requests.

Security Notice

Never expose your API keys in client-side code, public repositories, or version control. Always use environment variables or secure key management services.

Getting Your API Key

  1. 1

    Sign in to your AssuranceHub dashboard

    Navigate to dashboard.assurancehub.ai

  2. 2

    Go to API Keys section

    Click on "Settings" → "API Keys" in the sidebar

  3. 3

    Generate a new API key

    Click "Generate New Key" and give it a descriptive name

  4. 4

    Copy and secure your key

    Your key will only be shown once. Store it securely.

Example API Key

ash_test_••••••••••••••••••••••••••••••••

API keys start with ash_ followed by environment (test/live) and unique identifier

Authentication Methods

Bearer Token (Recommended)

Include your API key in the Authorization header as a Bearer token:

bash
Authorization: Bearer ash_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

API Key Header

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

bash
X-API-Key: ash_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Implementation Examples

Python

python
import os
import requests
from typing import Dict, Any

# Store your API key securely
API_KEY = os.environ.get('ASSURANCEHUB_API_KEY')
API_BASE_URL = 'https://api.assurancehub.ai/v1'

class AssuranceHubClient:
    def __init__(self, api_key: str):
        self.api_key = api_key
        self.headers = {
            'Authorization': f'Bearer {api_key}',
            'Content-Type': 'application/json'
        }
    
    def test_bias(self, prompt: str, response: str) -> Dict[str, Any]:
        """Test for bias in AI responses"""
        endpoint = f"{API_BASE_URL}/evaluate/bias"
        
        payload = {
            "prompt": prompt,
            "response": response,
            "customer_id": "your-customer-id"
        }
        
        response = requests.post(
            endpoint, 
            json=payload, 
            headers=self.headers
        )
        
        if response.status_code == 401:
            raise Exception("Invalid API key")
        elif response.status_code == 429:
            raise Exception("Rate limit exceeded")
        
        return response.json()

# Example usage
client = AssuranceHubClient(API_KEY)
result = client.test_bias(
    prompt="Tell me about successful entrepreneurs",
    response="Most successful entrepreneurs are men..."
)

Node.js

javascript
const axios = require('axios');

// Store your API key securely
const API_KEY = process.env.ASSURANCEHUB_API_KEY;
const API_BASE_URL = 'https://api.assurancehub.ai/v1';

class AssuranceHubClient {
    constructor(apiKey) {
        this.apiKey = apiKey;
        this.headers = {
            'Authorization': `Bearer ${apiKey}`,
            'Content-Type': 'application/json'
        };
    }
    
    async testBias(prompt, response) {
        const endpoint = `${API_BASE_URL}/evaluate/bias`;
        
        try {
            const result = await axios.post(endpoint, {
                prompt: prompt,
                response: response,
                customer_id: 'your-customer-id'
            }, {
                headers: this.headers
            });
            
            return result.data;
        } catch (error) {
            if (error.response?.status === 401) {
                throw new Error('Invalid API key');
            } else if (error.response?.status === 429) {
                throw new Error('Rate limit exceeded');
            }
            throw error;
        }
    }
}

// Example usage
const client = new AssuranceHubClient(API_KEY);
const result = await client.testBias(
    "Tell me about successful entrepreneurs",
    "Most successful entrepreneurs are men..."
);

cURL

bash
# Store your API key securely
export ASSURANCEHUB_API_KEY="your-api-key-here"

# Make an authenticated request
curl -X POST https://api.assurancehub.ai/v1/evaluate/bias \
  -H "Authorization: Bearer $ASSURANCEHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Tell me about successful entrepreneurs",
    "response": "Most successful entrepreneurs are men...",
    "customer_id": "your-customer-id"
  }'

Rate Limits

PlanRequests/HourRequests/DayBurst Rate
Starter1001,00010/min
Professional1,00010,00050/min
Enterprise10,000+UnlimitedCustom

Rate Limit Headers: We include rate limit information in response headers:

  • X-RateLimit-Limit - Your rate limit
  • X-RateLimit-Remaining - Requests remaining
  • X-RateLimit-Reset - Time when limit resets (Unix timestamp)

Error Handling

401

Unauthorized

Invalid or missing API key. Check your authentication headers.

403

Forbidden

Valid key but insufficient permissions for this resource.

429

Too Many Requests

Rate limit exceeded. Check rate limit headers for reset time.

Security Best Practices

Do

  • • Store API keys in environment variables
  • • Use different keys for development and production
  • • Rotate keys regularly
  • • Use server-side requests only
  • • Monitor key usage in your dashboard

Don't

  • • Embed keys in client-side code
  • • Commit keys to version control
  • • Share keys between applications
  • • Log or display keys in errors
  • • Use production keys in development

Next Steps