Bearer Token Authentication
All API requests must include a valid API key in theAuthorization header:
API Key Format
API keys follow the pattern:| Prefix | Environment | Usage |
|---|---|---|
river_live_ | Production | Live API calls, charged to your account |
river_test_ | Sandbox | Testing, no charges incurred |
Managing API Keys
Create a Key
Create API keys from the Dashboard or via the API:Rotate a Key
To rotate a key, create a new one, update your application, then delete the old key.Delete a Key
Permissions
Each API key can be scoped with fine-grained permissions:| Permission | Description | Example |
|---|---|---|
permissions | Permission object restricting key access | { "video:create": true } |
ipWhitelist | IP addresses allowed to use this key | ["203.0.113.50"] |
spendLimit | Maximum spend limit in USD | 1000 |
Security Best Practices
Use environment variables
Use environment variables
Never hardcode API keys in your source code.
Never commit keys to Git
Never commit keys to Git
Add
.env to your .gitignore file. If a key is accidentally committed, rotate it immediately from the Dashboard.Use scoped keys
Use scoped keys
Create separate keys for different environments and services. Scope each key to only the providers and types it needs.
Set spend limits
Set spend limits
Use
spendLimit to cap usage per key and prevent unexpected charges.Error Responses
| Status | Code | Description |
|---|---|---|
| 401 | AUTH_REQUIRED | No API key provided |
| 401 | AUTH_INVALID_TOKEN | Invalid or malformed API key |
| 401 | AUTH_TOKEN_EXPIRED | API key has expired |
| 403 | KEY_PERMISSION_DENIED | Key lacks required permissions |
| 403 | KEY_REVOKED | Key has been deleted |