AdRelay uses two layers of authentication:
- API Key — Authenticates your requests to the AdRelay API
- OAuth — Connects your ad platform accounts (Google, Meta, TikTok)
API Key Authentication
Every request to the AdRelay API must include your API key in the X-API-Key header.
Getting Your API Key
- Sign in to the AdRelay Dashboard
- Navigate to Settings > API Keys
- Copy your API key
Rotating Your API Key
If your API key is compromised, rotate it immediately. The old key will be invalidated and a new one will be issued.
Rotating your API key immediately invalidates the previous key. Update all applications using the old key before rotating.
Security Best Practices
- Store your API key in environment variables, never in source code
- Rotate your key periodically and immediately if compromised
- Use separate API keys for development and production environments
To manage campaigns on a specific platform, you must first connect that platform’s ad account via OAuth. AdRelay handles the full OAuth lifecycle:
- Initiate — Call the authorize endpoint to get an OAuth URL
- Authorize — User completes the OAuth flow in their browser
- Store — AdRelay stores and manages the OAuth tokens
- Refresh — Tokens are automatically refreshed before expiration
Starting the OAuth Flow
Replace {platform} with one of: google_ads, meta_ads, tiktok_ads.
The response includes a redirect URL that the user should open in their browser to complete authorization.
Token Lifecycle
Error Codes
Example Error Response