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)
Authentication Methods
Bearer Token (Recommended)
Include your API key in theAuthorization header using the Bearer scheme:
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
Example scenarios:-
Video generation service:
- ✅
video:write- Create videos - ✅
video:read- Check status - ✅
webhook:write- Set up notifications - ❌ Don’t need
video:deleteorchat:*
- ✅
-
Analytics dashboard:
- ✅
video:read- View video data - ✅
chat:read- View chat history - ❌ Don’t need any
:writescopes
- ✅
-
Video management tool:
- ✅
video:read- View videos - ✅
video:delete- Remove videos - ❌ Don’t need
video:writeorwebhook:*
- ✅
Creating API Keys
From Dashboard
- Log in to outcryai.com
- Navigate to Settings > API Keys
- Click Create New Key
- 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
- Click Create
- 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
Security Best Practices
1. Use Environment Variables
Never hardcode API keys in your source code. Use environment variables:.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
- Create new API key
- Deploy code with new key
- Monitor for 24 hours
- 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
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
6. Monitor API Key Usage
Track usage to detect anomalies:- Dashboard analytics: View usage by key in your dashboard
- Usage alerts: Set up alerts for unusual spikes
- Audit logs: Review access patterns regularly
- 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 windowX-RateLimit-Remaining: Requests remaining in current windowX-RateLimit-Reset: Unix timestamp when limit resets
Handling Rate Limits
When you exceed the rate limit, you’ll receive a429 Too Many Requests response:
- Respect rate limits: Check headers and slow down if needed
- Implement exponential backoff: Wait longer between retries
- Cache results: Don’t make duplicate requests
- Batch operations: Combine multiple operations where possible
- Use webhooks: Don’t poll - use webhooks for async operations
Authentication Errors
401 Unauthorized
Cause: Invalid or missing API key- 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
Authorizationheader format
403 Forbidden
Cause: Valid API key but missing required scope- 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: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