Creating Your First Environment
Set up development, staging, and production environments to safely test changes before deploying to production.What is an Environment?
An environment in KnoxCall allows you to use the same route with different configurations for dev, staging, and production. Same route, different configurations per environment:| Aspect | Development | Staging | Production |
|---|---|---|---|
| Target URL | http://localhost:3000 | https://staging-api.example.com | https://api.example.com |
| Secrets | dev_api_key | staging_api_key | prod_api_key |
| Allowed IPs | Your laptop | Staging server | Production servers |
| Rate Limits | Unlimited | 1000/min | 100/min |
Why Use Environments?
✅ Test safely: Try changes in dev/staging before production ✅ Prevent mistakes: Can’t accidentally break production ✅ Easy switching: Change environment with one header ✅ Different security: Relaxed limits for dev, strict for prod ✅ Separate credentials: Dev keys for dev, prod keys for prodUnderstanding Environment Overrides
KnoxCall uses a base + override system:- Base route: Default configuration (usually production)
- Environment overrides: Environment-specific changes
NULL = inherit from base
Example:
Create Environments
By default, KnoxCall creates a “production” environment for you. Let’s add development and staging.Step 1: Navigate to Environments
- Click Resources in sidebar
- Select Environments
- You’ll see “production” already exists
Step 2: Create Development Environment
Click Add Environment Environment Name:- 🟢 Green (
#00ff88) for development
Step 3: Create Staging Environment
Click Add Environment again Environment Name:- 🟡 Yellow (
#ffaa00) for staging
Configure Route for Environments
Now configure your route to use different URLs per environment.Step 1: Edit Your Route
- Navigate to Routes
- Click your route (e.g., “my-first-route”)
- Click Edit
Step 2: Set Base Configuration (Production)
This is your base environment (production): Target Base URL:Step 3: Add Environment Overrides
Now add overrides for development and staging.Development Override
- Click Environment Overrides tab
- Select development environment
- Configure:
Staging Override
- Select staging environment
- Configure:
Step 4: Assign Environment-Specific Clients
Now assign different IP addresses per environment:Development
- Go to Environment Clients tab
- Select “development”
- Assign your laptop/dev machine IP
- Example:
dev-laptop(203.45.67.89)
Staging
- Select “staging”
- Assign staging server IPs
- Example:
staging-server(34.56.78.90)
Production
- Select “production”
- Assign production server IPs
- Example:
prod-server-1,prod-server-2
Use Environments in Requests
Specify the environment via thex-knoxcall-environment header:
Development Request
http://localhost:3000/api/users
Staging Request
https://staging-api.production.com/api/users
Production Request (Default)
https://api.production.com/api/users
JavaScript Examples
With Environment Switching
Environment-Specific Logic
View Environment Activity
In Request Logs
- Navigate to Logs → API Logs
- See Environment badge on each request
- Filter by environment
In Analytics
- Navigate to Analytics
- Group by environment
- Compare traffic across dev/staging/prod
Best Practices
Environment Naming
Recommended names:development(ordev)staging(orstage)production(orprod)
- Capital letters
- Spaces
- Special characters (except hyphens)
Default Environment
Always set production as default! If clients forget the environment header, they should hit production (not dev/staging). This prevents accidental dev traffic in production apps.Environment Colors
Use colors for quick visual identification:- 🔴 Production: Red (
#ff0055) - be careful! - 🟡 Staging: Yellow (
#ffaa00) - caution - 🟢 Development: Green (
#00ff88) - safe to experiment
Separate Secrets Per Environment
Don’t use the same API keys for dev and production! Do create environment-specific secrets:stripe_dev_keystripe_staging_keystripe_prod_key
Different Rate Limits
Development: Unlimited (or very high)- Fast iteration, no throttling during testing
- Test rate limiting behavior
- Protect your backend
Common Issues
Environment Not Found
Error:Environment 'staging' not found
Causes:
- Typo in environment name
- Environment doesn’t exist
- Environment name is case-sensitive
- Check environment name spelling
- Verify environment exists in Environments page
- Use exact lowercase name
Wrong Backend Reached
Symptoms: Development request hits production API Causes:- Missing
x-knoxcall-environmentheader - Typo in header value
- Environment override not configured
- Add header:
x-knoxcall-environment: development - Check header spelling (lowercase)
- Verify environment override has correct target URL
”IP not authorized” in New Environment
Cause: You created a new environment but didn’t assign clients to it Fix:- Go to route → Environment Clients tab
- Select the new environment
- Assign clients (IP addresses)
- Save
NULL vs Empty String
NULL (not set): Inherits from base Empty string"": Overrides with empty value
Example:
Advanced: Temporary Environments
For large features or hotfixes, create temporary environments: Feature branch:Next Steps
Now that you have environments set up:Environment Workflows
Learn safe deployment strategies
Secret Management
Create environment-specific secrets
Environment Clients
Assign different IPs per environment
Rate Limiting
Configure different limits per environment
Related Concepts
- Base Route: Default configuration (usually production)
- Environment Override: Environment-specific changes (NULL = inherit)
- Default Environment: Used when no header specified
- Environment Clients: IP whitelist per environment
📊 Statistics
- Level: beginner
- Time: 10 minutes
🏷️ Tags
environments, configuration, deployment, quickstart