Environment variables are configuration values defined within a specific environment. They are used as additional configuration parameters that enable customizing requests and switching easily between different contexts. Creating them is not mandatory, but their use facilitates the process of designing and managing APIs.
The API Manager allows creating environment variables to be used in various parts of our platform:
List of interceptors that allow the use of environment variables:
| Spike arrest Rate limit Payload size Billing hits | Time Token Encrypt Data Obfuscation CSRF Token | Service mashup Service callout Internal API Call | Query param Header Destination |
NOTEWhen using environment variables to configure interceptors such as Rate limit, Payload size, or token expiration times, make sure the values remain within the limits recommended by the platform.
See:
TIPImagine several APIs deployed to an environment share the same target destination and, at some point, that destination changes. Without environment variables, it would be necessary to change the target destination in each API. However, if the destination had been set as an environment variable, just change the value of that variable in the specific environment, and all APIs will be automatically updated.
To register environment variables, you must create a variables map (Variables Map) or import an existing one from another environment.
To add a map:
Click the ADD MAP button;
In the screen that opens, define the name for the map.

Now you can create environment variables as key-value pairs, both of type string.

The Type field allows you to change the variable type to one of the options below:
You can also add a certificate corresponding to the communication between the gateway and the backend. When the environment variable is used, it will be applied:
Click the
icon;
Select the registered certificate on the Certificates screen.
To import a map from another environment:
Click the IMPORT MAP button;
When you start typing the environment name, the system will load the necessary information;
After selecting the map, click IMPORT MAP.

The environment variables will be loaded. You will be able to:
On this same tab, you can edit the map's name and description, or delete it.
When you create variables in an environment, they are associated with the environment as a whole, not with a specific API. Therefore, it is important to follow good management and organization practices. We recommend using a clear and consistent naming pattern for all variables. This makes it easier to identify and use them correctly.
Consider two environment variables: one named destination, with a valid address, and one named rateLimit, with value 2.

The environment variable $destination can be used as an API endpoint.
When a request is made, the gateway will direct the call to the configured address.
To set this up, just reference the environment variable as the API's Target Destination, as shown in the image below:

The environment variable $rateLimit can be used in the interceptor of the same name to set the call limit, replacing the configured value (in this case, 2).

IMPORTANT
- Access Target Destination in the Flows section when editing or creating an API. In the diagram representing the request and response flows, click the
button.
- All environment variables must be preceded by the
$symbol when referenced in APIs or interceptors.- The gateway reuses connections by default. For more information, see our FAQ.
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more