Skip to main content

Authentication

Learn how to authenticate with the Outcry AI API using API keys, understand scopes, and follow security best practices.

API Key Format

All API requests require authentication using API keys. Outcry AI uses a prefix system to identify key types:
  • Live keys (oc_live_...) charge your account and create real videos
  • Test keys (oc_test_...) simulate API calls without charges (coming soon)
Never share your API keys publicly! If a key is compromised, revoke it immediately from your dashboard.

Authentication Methods

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

Using OpenAI SDK

The OpenAI SDK automatically handles authentication. Just pass your API key:

API Key Scopes

Each API key has specific permissions (scopes) that control what it can access. When creating a key, select only the scopes you need.

Available Scopes

Scope Best Practices

Principle of least privilege: Only grant the scopes your application actually needs. This limits damage if a key is compromised.
Example scenarios:
  1. Video generation service:
    • video:write - Create videos
    • video:read - Check status
    • webhook:write - Set up notifications
    • ❌ Don’t need video:delete or chat:*
  2. Analytics dashboard:
    • video:read - View video data
    • chat:read - View chat history
    • ❌ Don’t need any :write scopes
  3. Video management tool:
    • video:read - View videos
    • video:delete - Remove videos
    • ❌ Don’t need video:write or webhook:*

Creating API Keys

From Dashboard

  1. Log in to outcryai.com
  2. Navigate to Settings > API Keys
  3. Click Create New Key
  4. Configure your key:
    • Name: Descriptive name (e.g., “Production Server”, “Development”)
    • Scopes: Select required permissions
    • Rate Limit (optional): Custom rate limit (default: 100 req/min)
    • Expiration (optional): Auto-expire after X days
  5. Click Create
  6. Copy your key immediately - it won’t be shown again!

Key Management

  • View keys: See all your API keys and their scopes
  • Revoke keys: Immediately invalidate compromised keys
  • Rotate keys: Create new key → migrate code → revoke old key
  • Monitor usage: See which keys are being used most
API keys are shown only once when created. If you lose a key, you must create a new one.

Security Best Practices

1. Use Environment Variables

Never hardcode API keys in your source code. Use environment variables:
Add .env to .gitignore:
.gitignore

2. Rotate Keys Regularly

Rotate API keys every 90 days or when:
  • An employee with access leaves
  • A key may have been exposed
  • Moving from development to production
  • Migrating to new infrastructure
Zero-downtime rotation:
  1. Create new API key
  2. Deploy code with new key
  3. Monitor for 24 hours
  4. Revoke old key

3. Use Different Keys per Environment

Never use the same API key across environments:

4. Implement Key Vaulting

For production applications, store API keys in a secrets management system:
  • AWS Secrets Manager
  • HashiCorp Vault
  • Azure Key Vault
  • Google Secret Manager
Example with AWS Secrets Manager:

5. Restrict API Key Access

  • Backend only: Never expose API keys in frontend JavaScript
  • Server-side rendering: Load keys server-side only
  • Proxy pattern: Create your own API that calls Outcry AI
❌ Never do this:
✅ Do this instead:

6. Monitor API Key Usage

Track usage to detect anomalies:
  1. Dashboard analytics: View usage by key in your dashboard
  2. Usage alerts: Set up alerts for unusual spikes
  3. Audit logs: Review access patterns regularly
  4. Credit alerts: Get notified when balance is low

Rate Limiting

All API keys are subject to rate limits to ensure fair usage and protect the service.

Default Rate Limits

Rate Limit Headers

Every API response includes rate limit headers:
  • X-RateLimit-Limit: Total requests allowed per window
  • X-RateLimit-Remaining: Requests remaining in current window
  • X-RateLimit-Reset: Unix timestamp when limit resets

Handling Rate Limits

When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
Best practices:
  1. Respect rate limits: Check headers and slow down if needed
  2. Implement exponential backoff: Wait longer between retries
  3. Cache results: Don’t make duplicate requests
  4. Batch operations: Combine multiple operations where possible
  5. Use webhooks: Don’t poll - use webhooks for async operations
Example with exponential backoff:

Authentication Errors

401 Unauthorized

Cause: Invalid or missing API key
Solutions:
  • Verify your API key is correct
  • Check that the key hasn’t been revoked
  • Ensure you’re using the correct key type (live vs test)
  • Verify the Authorization header format

403 Forbidden

Cause: Valid API key but missing required scope
Solutions:
  • Check which scopes your key has
  • Create a new key with the required scopes
  • Update your existing key’s scopes (requires re-creating)

Testing Authentication

Test your authentication setup with a simple request:
If authentication works, you’ll receive:

Next Steps

Quickstart

Make your first authenticated API request

Video API

Learn how to create videos with authenticated requests

Webhooks

Set up webhooks with HMAC authentication

Error Handling

Handle authentication errors gracefully