Securing Your API Routes
Learn best practices for securing your KnoxCall routes.Authentication Methods
1. OAuth 2.1 Access Tokens (Recommended)
Short-lived Bearer tokens (kc_…) minted from an OAuth client — nothing long-lived to leak or rotate. The SDKs mint, cache, and refresh them automatically.
When to use:
- Internal services
- Server-to-server communication
- New integrations
- Register an OAuth client under Settings → Security → OAuth Clients (on a developer machine,
knoxcall logindoes this for you) - Mint a token via
POST /oauth/token— or skip this step and let the SDK handle it - Clients send:
Authorization: Bearer kc_…plusx-knoxcall-route: <route-slug>
x-knoxcall-key: tk_… instead. See Authentication.
2. JWT Tokens
Token-based authentication with expiration. When to use:- User-facing applications
- Mobile apps
- Web applications
- Configure JWT settings in route
- Set token expiration
- Add public key for verification
3. Signature Verification
Request signing for tamper protection. When to use:- Webhooks
- High-security applications
- Payment processing
- Enable signature verification
- Share signing secret with clients
- Clients sign requests with HMAC-SHA256
IP Allowlisting
Restrict access to specific IP addresses:- Navigate to route settings
- Add allowed IPs:
- Only these IPs can access the route
Rate Limiting
Protect against abuse and DDoS: Configuration:- Requests: Number of requests allowed
- Window: Time window (e.g., 60 seconds)
- Burst: Allow short bursts
- 100 requests per minute
- Burst: 120 requests
CORS Configuration
Configure cross-origin resource sharing:Security Best Practices
1. Use HTTPS Only
- Never send credentials over HTTP
- Enforce HTTPS in your application
2. Rotate Keys Regularly
- Prefer short-lived OAuth tokens (
kc_…) — they expire after an hour, so there is nothing to rotate - If you use long-lived API keys, rotate them every 90 days
- Update clients before expiration
3. Principle of Least Privilege
- Only grant necessary permissions
- Use different keys for different services
4. Monitor for Anomalies
- Set up alerts for unusual activity
- Watch for failed auth attempts
- Monitor for rate limit violations
5. Keep Secrets Secure
- Never commit secrets to git
- Use environment variables
- Rotate secrets immediately if compromised
Common Security Mistakes
❌ Don’t do this:- Hardcode API keys in frontend code
- Use same key for all environments
- Ignore rate limiting
- Skip signature verification for webhooks
- Store keys in backend environment variables
- Use different keys for dev/staging/prod
- Always enable rate limiting
- Verify webhook signatures
Audit Logs
Review security events:- Go to Audit Logs
- Filter by event type
- Look for suspicious activity
📊 Statistics
- Views: 1
- Helpful: 0 👍
- Level: intermediate
🏷️ Tags
security, authentication, api-keys, best-practices