Environment Variable Concept
Environment variables are used to securely store sensitive information (passwords, API keys, certificates) or configuration values. In Apinizer, environment variables are defined at the project level and can be of two types:- Global (All Environments): Uses the same value in all environments
- Environment-Specific: Different values can be defined for each environment
Encryption Support
Level-Based
Security
Reusability
Environment Variable Resolution Flow
The following diagram shows how environment variables are resolved at runtime and how values are retrieved according to the environment:Environment Variable Types
Encrypted
Unencrypted
Encrypted Variables
Encrypted Variables
- Passwords: Database passwords, API keys
- Certificates: SSL/TLS certificates
- Tokens: OAuth tokens, JWT secrets
- Other Sensitive Information: All values requiring security
Unencrypted Variables
Unencrypted Variables
- URLs: Backend API URLs
- Port Numbers: Port values
- Flags: Boolean values
- Other Configurations: General configuration values
Environment Variable Levels
Environment-Level
Project-Level
Environment-Level Usage Scenarios
Environment-Level Usage Scenarios
- Environment-based backend URLs
- Environment-based API keys
- Environment-based configuration values
- Environment-based database connection information
Project-Level Usage Scenarios
Project-Level Usage Scenarios
- Project-based configuration values
- Project-based API keys
- Project-based general settings
- Project-based common values
Environment Variable Priority Order
Variable resolution order (from highest to lowest):1. Environment-Level Encrypted
2. Environment-Level Unencrypted
3. Project-Level Encrypted
4. Project-Level Unencrypted
Working Logic
1. Definition
- Global: Same value in all environments
- Environment-Specific: Different value for each environment
2. Usage
${variableName} format- Backend address:
${BACKEND_URL} - Database:
jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} - API key:
${API_KEY}
3. Runtime Resolution
- Variable expressions are detected
- Environment value is retrieved
- Secrets are decrypted
- Replaced with actual value
Example Scenario
Example Scenario
- Development:
BACKEND_URL = dev-api.example.com - Production:
BACKEND_URL = api.example.com - In configuration:
${BACKEND_URL}
- In Development environment:
dev-api.example.com - In Production environment:
api.example.com
Environment Variable Usage Format
Environment variables are referenced in configuration fields using a special format.Format Structure
| Format | Description | Example |
|---|---|---|
${variableName} | Basic usage format | ${BACKEND_URL} |
text${variableName} | Combining with text | https://${API_HOST} |
${variableName}text | Combining with text | ${API_PORT}/api |
text${variable1}text${variable2} | Multiple variables | jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} |
Format Rules
Start Character
${End Character
}Variable Name
Case Sensitivity
Environment Variable Usage Locations
Environment variables can be used in various configuration fields in the Apinizer platform. Environment Variable Selection Dialog is only available in certain fields.API Proxy - Routing
Database Connection
LDAP Connection
API Proxy - Routing Details
API Proxy - Routing Details
| Feature | Description |
|---|---|
| Location | API Proxy > Upstream/Routing Tab > Define Address(es) |
| Field | Backend API address input field |
| Usage | Environment-based routing in Backend API addresses |
| Access | By clicking the list icon button on the right side of the address input field |
Database Connection Details
Database Connection Details
| Feature | Description |
|---|---|
| Location | Administration > Connection Management > Connection Pool Def DB |
| Fields | JDBC URL, Username, Password |
| Usage | Environment-based management in database connection information |
| Dialog Access | By clicking the list icon button on the right side of each field |
| Secret Usage | Password field must be marked as secret |
LDAP Connection Details
LDAP Connection Details
| Feature | Description |
|---|---|
| Location | Administration > Connection Management > Connection Pool Def LDAP |
| Fields | LDAP URL, Bind DN, Bind Password |
| Usage | Environment-based management in LDAP connection information |
| Dialog Access | By clicking the list icon button on the right side of each field |
| Secret Usage | Bind Password must be marked as secret |
Usage Scenarios and Examples
Backend API Address Management
Backend API Address Management
- Key Name:
BACKEND_API_URL - Type: Environment-Specific
- Development:
https://dev-api.example.com - Test:
https://test-api.example.com - Production:
https://api.example.com
- Address:
${BACKEND_API_URL}
- In Development environment, requests go to
https://dev-api.example.com - In Test environment, requests go to
https://test-api.example.com - In Production environment, requests go to
https://api.example.com
Database Connection Management
Database Connection Management
DB_HOST: Development=dev-db.example.com, Production=prod-db.example.comDB_PORT: Global=3306DB_NAME: Development=dev_db, Production=prod_dbDB_USER: Development=dev_user, Production=prod_userDB_PASSWORD: Development=dev_pass, Production=prod_pass(Secret)
- Connection String:
jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} - Username:
${DB_USER} - Password:
${DB_PASSWORD}
- Development:
jdbc:mysql://dev-db.example.com:3306/dev_db - Production:
jdbc:mysql://prod-db.example.com:3306/prod_db
API Key Management
API Key Management
- Key Name:
EXTERNAL_SERVICE_API_KEY - Type: Environment-Specific
- Development:
dev-key-abc123(Secret) - Production:
prod-key-xyz789(Secret)
- Header Name:
X-API-Key - Header Value:
${EXTERNAL_SERVICE_API_KEY}
- Development:
X-API-Key: dev-key-abc123 - Production:
X-API-Key: prod-key-xyz789
Environment Variable Creation
Environment variable creation steps:Step 1: Adding New Environment Variable
Step 1: Adding New Environment Variable
- Go to Environment Variables page
- Click the “Create” button in the upper right corner
- Environment Variable editing window opens
Step 2: Entering Basic Information
Step 2: Entering Basic Information
- Key Name (Variable Name):
- Required field
- Must be unique within the project
- Name check is performed automatically
- Valid name: Green checkmark
- Existing name: Red warning sign
- Description:
- Optional field
- Describes what the variable is used for
Step 3: Type Selection
Step 3: Type Selection
- Environment-Specific:
- Different values can be defined for each environment
- Selected when creating new record
- Cannot be changed after record is created
- Global (All Environments):
- Same value used in all environments
- Selected when creating new record
- Cannot be changed after record is created
Step 4: Value Definition
Step 4: Value Definition
- Adding Environment: Click “Add Environment” button to add new environment
- Environment Selection: Select an environment for each value
- Existing environments are selected from the list
- Custom environment name can be entered with “Custom…” option
- Entering Value: Enter value for each environment
- Secret Setting: Check “Secret” checkbox for sensitive information
- Secret values are masked after saving (
***********) - Secret values are stored encrypted
- If value is not changed during update, existing value is preserved
- Secret values are masked after saving (
- Global Value: Enter a single value (valid for all environments)
- Secret Setting: Check “Secret” checkbox for sensitive information
Step 5: Saving and Deployment
Step 5: Saving and Deployment
- Form Validation: All required fields must be filled and name must be valid
- Click “Save and Deploy” button
- Confirmation Dialog:
- You are asked to enter the variable name again (for security)
- Affected components are listed:
- API Proxy Routing settings
- Policy Configuration settings
- Connector settings
- Other configuration settings
- Deployment Result:
- Automatically deployed to all running environments
- Deployment results are shown
Environment Variable Editing
Opening the Edit Modal
The edit modal can be opened in the following ways:| Method | Description |
|---|---|
| Clicking from List | Click on the environment variable name |
| Selecting from Menu | Select “Edit” from the menu at the end of the row |
Differences in Edit Modal
| Feature | New Record | Edit |
|---|---|---|
| Modal Title | ”Add Environment Variable" | "Edit Environment Variable” |
| Type Selection | Active (can be changed) | Inactive (cannot be changed) |
| Secret Values | Visible normally | Visible masked (***********) |
| Secret Checkbox | Active | Inactive for saved secrets |
Best Practices
Security
Security
- Always store sensitive information encrypted
- Use encrypted for passwords, API keys, certificates
- Regularly change passwords
Organization
Organization
- Name variables consistently
- Properly separate environment and project level variables
- Create documentation
Management
Management
- Clean up unused variables
- Regularly review variable usage
- Perform version control

