Ana içeriğe geç

Environment Variables Management

bilgi

For detailed information about the Environment Variables concept, you can refer to the Environment Variable core concepts page.

This page contains practical information on how Environment Variables are created, edited, and used. Environment Variables is a feature in the Apinizer API Management Platform that allows you to centrally manage configuration information that needs to use different values in different environments (Development, Test, Production). Thanks to this feature, the same API Proxy configuration can dynamically use different values such as backend addresses, database connection information, and API keys in different environments.

Working Logic

1. Definition Stage

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

2. Usage Stage

Environment variables are used in configuration fields in the ${variableName} format:

  • Example 1: ${BACKEND_URL} for backend address
  • Example 2: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} for database connection string
  • Example 3: ${API_KEY} for API key

3. Runtime Resolution

When the API Proxy is running (runtime):

  1. Expressions in ${variableName} format in the configuration are detected
  2. The variable value of the relevant environment (Environment) is retrieved
  3. The value is automatically decrypted — every value is stored encrypted, so this step also applies to values that are not marked Secret
  4. Variable name is replaced with the actual value
  5. Operation continues with the actual value

Example Scenario:

  • Development Environment: BACKEND_URL = dev-api.example.com
  • Production Environment: BACKEND_URL = api.example.com
  • In Configuration: ${BACKEND_URL}
  • At Runtime in Development: dev-api.example.com
  • At Runtime in Production: api.example.com

Creating Environment Variable (Create)

The visual containing the steps for creating an environment variable is shown below:

Environment Variable Creation

Environment variable creation configurations are explained step by step in the table below:

StepFunction
Step 1: Adding New Environment VariableGo to Environment Variables page
Click the "Create" button in the upper right corner
Environment Variable editing window opens
Step 2: Entering Basic InformationKey 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 SelectionEnvironment-Specific:
Different values can be defined for each environment
Selected when creating a new record
Cannot be changed after the record is created

Global (All Environments):
Same value is used in all environments
Selected when creating a new record
Cannot be changed after the record is created

:::info

Type selection can only be made when creating a new record. The type of existing records cannot be changed.

::: | | Step 4: Value Definition | For Environment-Specific Variables:
Adding Environment: Click "Add Environment" button to add a 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
Setting Secret: Check "Secret" checkbox when the value must never be readable again
Every value is stored encrypted, whether or not it is marked Secret
Values that are not Secret are masked on screen and can be revealed with the eye icon and copied
Secret values can never be displayed once saved
If value is not changed during update, existing value is preserved

For Global Variables:
Global Value: Enter a single value (valid for all environments)
Setting Secret: Check "Secret" checkbox when the value must never be readable again | | Step 5: Saving and Deployment | Form Control: 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 (Environments)
Deployment results are displayed |

Adding New Environment Variable
  1. Go to Environment Variables page
  2. Click the "Create" button in the upper right corner
  3. Environment Variable editing window opens
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
Type Selection

Environment-Specific:

  • Different values can be defined for each environment
  • Selected when creating a new record
  • Cannot be changed after the record is created

Global (All Environments):

  • Same value is used in all environments
  • Selected when creating a new record
  • Cannot be changed after the record is created
bilgi

Type selection can only be made when creating a new record. The type of existing records cannot be changed.

Value Definition

For Environment-Specific Variables:

  1. Adding Environment: Click "Add Environment" button to add a new environment
  2. Environment Selection: Select an environment for each value
    • Existing environments are selected from the list
    • Custom environment name can be entered with "Custom..." option
  3. Entering Value: Enter value for each environment
  4. Setting Secret: Check "Secret" checkbox when the value must never be readable again
    • Every value is stored encrypted in the database, whether or not it is marked Secret
    • Values that are not Secret are masked on screen; they can be revealed with the eye icon and copied
    • Secret values can never be displayed once saved: they are not shown on screen, not returned by the API, and not written as plain text into an export package
    • If value is not changed during update, existing value is preserved

For Global Variables:

  1. Global Value: Enter a single value (valid for all environments)
  2. Setting Secret: Check "Secret" checkbox when the value must never be readable again
Saving and Deployment
  1. Form Control: All required fields must be filled and name must be valid
  2. Click "Save and Deploy" button
  3. 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
  4. Deployment Result:
    • Automatically deployed to all running environments (Environments)
    • Deployment results are displayed
bilgi

All environment variable values are stored encrypted in the database — you do not need to mark a value Secret just to protect it. Mark a value Secret only when nobody should ever be able to read it back:

  • A value that is not Secret: masked on screen, revealable with the eye icon and copyable; returned as plain text by the read APIs and carried as plain text in an export package.
  • A Secret value: can never be displayed once saved; it is not shown on screen, comes back as null from the API, and is not written as plain text into an export package.

Because a Secret value cannot be read back, changing it means typing a new value.

Editing Environment Variable (Edit)

Opening the Edit Modal

The edit modal can be opened in the following ways:

MethodDescription
Clicking from ListClick on the environment variable name
Selection from MenuSelect "Edit" from the menu at the end of the row

Differences in Edit Modal

FeatureNew RecordEdit
Modal Title"Add Environment Variable""Edit Environment Variable"
Type SelectionActive (changeable)Inactive (cannot be changed)
Non-Secret ValuesEntered masked, revealable with the eye iconMasked; revealable with the eye icon and copyable
Secret ValuesEntered masked, revealable with the eye iconRead-only mask (************); no eye or copy button
Secret CheckboxActiveInactive for saved secrets

Environment Variables Usage

Environment variables can be used in various configuration fields in the Apinizer API Manager platform. This section explains in detail how environment variables are used, in which configurations they can be used, and practical examples.

Usage Format

Environment variables are referenced in configuration fields using a special format.

Format Structure

FormatDescriptionExample
${variableName}Basic usage format${BACKEND_URL}
text${variableName}Combining with texthttps://${API_HOST}
${variableName}textCombining with text${API_PORT}/api
text${variable1}text${variable2}Multiple variablesjdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}

Format Rules

RuleDescription
Starting CharacterMust start with ${
Ending CharacterMust end with }
Variable NameVariable name is in the middle (without spaces)
Case SensitivityVariable name is case-sensitive
Special CharactersDot (.), underscore (_) can be used in variable name

Usage Locations

Environment variables can be used in various configuration fields in the Apinizer platform. However, the Environment Variable Selection Dialog is only available in certain fields.

1. API Proxy - Routing

Usage Area: Upstream Routing addresses

FeatureDescription
LocationAPI Proxy > Upstream/Routing Tab > Define Address(es)
FieldBackend API address input field
UsageEnvironment-based routing in backend API addresses
AccessBy clicking the list icon button on the right of the address input field

Usage Scenario: To use different backend addresses in different environments

2. Database Connection

Usage Area: Database connection configuration

FeatureDescription
LocationAdministration > Connection Management > Connection Pool Def DB
FieldsJDBC URL, Username, Password
UsageEnvironment-based management in database connection information
Dialog AccessBy clicking the list icon button on the right of each field
Secret UsagePassword field must be marked as secret

Usage Scenario: To use different database connection information in different environments

3. LDAP Connection

Usage Area: LDAP connection configuration

FeatureDescription
LocationAdministration > Connection Management > Connection Pool Def LDAP
FieldsLDAP URL, Bind DN, Bind Password
UsageEnvironment-based management in LDAP connection information
Dialog AccessBy clicking the list icon button on the right of each field
Secret UsageBind Password must be marked as secret

Usage Scenario: To use different LDAP connection information in different environments

4. AI Gateway — Copy to Clipboard via Button (MCP Gateway, A2A Gateway, LLM Providers, Vector DBs)

Usage Area: Inline MCP server / A2A agent authentication settings in the AI Gateway module, plus LLM/VectorDB connection information

FeatureDescription
LocationMCP Gateway — an MCP Gateway's MCP Routing tab, or the MCP Call (LLM) / MCP Call (Fixed) policy's inline server fields (Endpoint, Bearer Token or OAuth2 client credentials) · A2A Gateway — an A2A Gateway's A2A Routing tab, or the A2A Call (LLM) / A2A Call (Fixed) policy's inline agent fields (Endpoint, Bearer Token or OAuth2 client credentials) · AI Gateway > LLM Providers (Endpoint URL, API Key, API Secret, Organization ID) · AI Gateway > RAG > Vector DBs tab (Default Collection Name)
FieldsThe corresponding text inputs on the screens above
UsageEnvironment-based management of authentication and LLM/VectorDB connection information
Dialog AccessYes — a "Variable" button (code icon) in the page's top toolbar opens the "Select Environment Variable" dialog; clicking a variable in the list copies its value (as ${variableName}) to the clipboard, which you then paste into the target field yourself (there is no per-field auto-fill; the button is a single, page-wide entry point)
Secret UsageSensitive fields such as API Key, API Secret, Bearer Token, and OAuth2 client secret are stored as secrets; when a field holds an environment variable expression (typed or pasted), encryption is skipped and the value is resolved from the environment variable at runtime

Usage Scenario: To run the same AI Gateway configuration with different LLM provider keys or different MCP/A2A server credentials in different environments

5. AI Gateway — Manual Entry (AI RAG Injection Policy)

Usage Area: Connection/template fields of the AI RAG Injection policy

FeatureDescription
LocationAI RAG Injection policy (Collection Name, Injection Template, Embedding Model)
FieldsThe corresponding text inputs on the policy above
UsageEnvironment-based management of RAG connection information
Dialog AccessNone — the Environment Variable Selection Dialog is not offered on these fields; you enter the variable name directly into the field as ${VARIABLE_NAME}
Secret UsageNone of this policy's fields are marked as secret; when a field holds an environment variable expression, the value is resolved from the environment variable at runtime

Usage Scenario: To run the same AI Gateway configuration with different RAG collection names in different environments

bilgi

For security reasons, the regex/pattern fields in the AI Prompt Guard policy do not support environment variable resolution; the value entered in these fields is used as-is.

Usage Scenarios and Examples

Problem: Different backend API addresses are used in different environments.

Solution:

  1. Creating Environment Variable:
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
  1. Usage in Routing:
Address: ${BACKEND_API_URL}
  1. Result:
  • 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