Authentication

Secure your API requests with API key authentication

API Key Authentication

All requests to the Omni API require authentication using an API key. This ensures that only authorized users can access the API and helps us track usage for billing purposes.

Obtaining an API Key

You can obtain an API key by signing up for an account on the Omni dashboard. Once you've created an account, you can generate API keys from the dashboard.

API Key Security

Your API key is a secret that grants access to the API. Keep it secure and never share it publicly. If you suspect your API key has been compromised, you can revoke it and generate a new one from the dashboard.

Using Your API Key

To authenticate your API requests, include your API key in the X-API-Key header of your HTTP requests:

X-API-Key: your_api_key_here

Example Request with Authentication

curl -X POST https://api.omnimoderate.com/v1/moderate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key_here" \
  -d '{
    "input": [
      { "type": "text", "text": "This is a sample text to moderate." }
    ]
  }'

Authentication Errors

If you don't include an API key or if the API key is invalid, you'll receive an error response:

Missing API Key

{
  "error": {
    "code": "missing_api_key",
    "message": "API key is required. Please include an X-API-Key header."
  }
}

Invalid API Key

{
  "error": {
    "code": "invalid_api_key",
    "message": "The provided API key is invalid or has been revoked."
  }
}

API Key Management

You can manage your API keys from the Omni dashboard. The dashboard allows you to:

  • Generate new API keys
  • Revoke existing API keys
  • View API key usage statistics
  • Set permissions and restrictions for API keys

API Key Best Practices

  • Never hardcode API keys in client-side code - API keys should be stored securely on your server and never exposed to users
  • Use environment variables - Store API keys in environment variables rather than in your codebase
  • Rotate API keys periodically - Regularly generate new API keys and revoke old ones to minimize the risk of unauthorized access
  • Use different API keys for different environments - Use separate API keys for development, staging, and production environments
  • Monitor API key usage - Regularly check your API key usage to detect any unusual activity

Next Steps