Creating Your First Secret
Learn how to store sensitive credentials securely and inject them into backend requests without exposing them to clients.What is a Secret?
A secret in KnoxCall is an encrypted credential (API key, password, token) that’s injected into your backend requests server-side. Your clients never see the actual value.Why Use Secrets?
Without KnoxCall secrets:Secret Types
KnoxCall supports two types of secrets:1. String Secrets (Most Common)
Simple encrypted values:- API keys (Stripe, SendGrid, Twilio)
- Passwords (database, services)
- Tokens (auth tokens, webhook secrets)
- Any sensitive string value
2. OAuth2 Secrets (Advanced)
Full OAuth2 flow with automatic token refresh:- Google OAuth tokens (auto-refreshes when expired)
- Shopify, HubSpot, Microsoft, Slack OAuth
- Stores access token, refresh token, and expiry
- Handles token rotation automatically
How Secrets Work
Create Your First Secret
Step 1: Navigate to Secrets
- Click Resources in the sidebar
- Select Secrets
- Click Add Secret
Step 2: Choose Secret Type
Select String Secret (for this guide)Step 3: Fill in Details
Secret Name:Step 4: Save
Click Create Secret The value is immediately encrypted using AES-256-GCM. You’ll never see the plaintext value again in the UI!Use Secret in a Route
Now let’s inject your secret into backend requests.Step 1: Edit Your Route
- Navigate to Routes
- Click your route (e.g., “stripe-payments”)
- Click Edit
Step 2: Inject Secret in Headers
Find the Inject Headers section and add:{{secret:name}}
secret:is required prefixnameis your secret name (e.g.,stripe_prod_key)
Step 3: Or Inject Secret in Body
For POST/PUT/PATCH requests, inject into JSON body:Step 4: Save Route
Click Save ChangesTest Your Secret
Make a Request
What Happens
- KnoxCall receives your request
- Loads route “stripe-payments”
- Sees
{{secret:stripe_prod_key}}in header template - Decrypts secret server-side
- Replaces template with actual value:
- Forwards request to Stripe API with real key
- Returns response to you
View in Logs
- Navigate to Logs → API Logs
- Find your request
- Click to expand details
- Notice: Request headers show
{{secret:stripe_prod_key}}(template) - But backend received actual decrypted value
Multiple Secrets in One Route
You can use multiple secrets in a single route:Environment-Specific Secrets
Use different secrets per environment (dev/staging/prod):Create Environment-Specific Secrets
-
Development:
- Name:
stripe_dev_key - Value:
sk_test_abc123...
- Name:
-
Staging:
- Name:
stripe_staging_key - Value:
sk_test_xyz789...
- Name:
-
Production:
- Name:
stripe_prod_key - Value:
sk_live_abc123...
- Name:
Configure Route Per Environment
Base route (production):Secret Versioning
KnoxCall tracks secret versions for rollback:Rotate a Secret
- Navigate to Secrets
- Click your secret (e.g., “stripe_prod_key”)
- Click Add New Version
- Enter new value:
- Save
- New version becomes active immediately
- Old version preserved (for rollback if needed)
- All routes using this secret now use new value
- Zero downtime! No code changes needed
View Version History
- Open secret details
- Click Version History tab
- See all versions with timestamps
- Can rollback to previous version if needed
Common Use Cases
Payment APIs
Email/SMS Services
Webhooks
Database Credentials
Printing Services
Security Best Practices
Naming Conventions
✅ Good names:- Service (stripe, sendgrid)
- Purpose (api_key, webhook_secret)
- Environment (prod, staging, dev)
Secret Rotation
Recommended rotation schedule:- Critical secrets (payment APIs): Every 90 days
- Less critical: Every 180 days
- Development: Annually
- Generate new key in third-party service (Stripe, etc.)
- Create new version in KnoxCall
- Test in staging first
- Deploy to production
- Wait 24-48 hours
- Revoke old key in third-party service
Separation by Environment
✅ Do:- Different secrets for dev/staging/prod
- Never use prod secrets in development
- Test secret rotation in staging first
- Reuse production secrets in development
- Share secrets across unrelated services
- Commit secrets to git (even encrypted)
Access Control
- Only give team members access to secrets they need
- Use least privilege principle
- Audit secret access regularly
- Delete unused secrets promptly
Monitoring
- Set up alerts for failed secret decryption
- Monitor secret usage in logs
- Track secret rotation dates
- Get notified when secrets expire
Troubleshooting
Secret Not Found Error
Error:Secret 'stripe_key' not found
Causes:
- Typo in secret name
- Secret was deleted
- Wrong syntax (forgot
secret:prefix)
- Check secret exists: Secrets page
- Verify name spelling matches exactly
- Check template syntax:
{{secret:name}}(not{{name}})
Template Not Replaced
Symptoms: Backend receives literal{{secret:stripe_key}} instead of actual value
Causes:
- Wrong template syntax
- Secret referenced but not found
- Header injection disabled
- Check logs - see what was actually sent
- Verify template syntax is correct
- Test secret exists and name matches
- Check inject headers is enabled
Wrong Value Injected
Symptoms: Backend gets wrong API key Causes:- Using wrong environment
- Secret not configured for environment
- Old version being used
- Check which environment request used
- Verify secret configured for that environment
- Check secret version (maybe need to create new version)
- Look at logs to see which value was injected
Next Steps
Now that you understand secrets:OAuth2 Integration
Set up OAuth with auto-refresh
Secret Best Practices
Advanced secret rotation & monitoring
Environment Overrides
Use different secrets per environment
Method-Specific Config
Different secrets per HTTP method
Related Concepts
- Secret Versioning: Track changes and rollback if needed
- Environment Overrides: Different secrets per dev/staging/prod
- Template System:
{{secret:name}}syntax for injection - Encryption: AES-256-GCM with envelope encryption
- OAuth2 Secrets: Automatic token refresh for OAuth flows
📊 Statistics
- Level: beginner
- Time: 10 minutes
🏷️ Tags
secrets, security, credentials, encryption, quickstart