Help Center> API Gateway> User Guide> API Management> Creating an Environment Variable
Updated on 2024-03-07 GMT+08:00

Creating an Environment Variable

You can define environment variables to allow an API to be called in different environments.

Environment variables are manageable and specific to environments. You can add variables in different environments to call different backend services using the same API.

For variables you define during API creation, you must create corresponding variables and values. For example, variable Path is defined for an API, and two variables with the same name are created and assigned values /Stage/test and /Stage/AA in environments 1 and 2, respectively. If the API is published and called in environment 1, the path /Stage/test is used. If the API is published and called in environment 2, the path /Stage/AA is used.

Figure 1 Use of environment variables


  1. Go to the APIG console.
  1. Select a dedicated gateway at the top of the navigation pane.
  1. Choose API Management > API Groups.
  2. Click a group name.
  3. Click the Group Information tab.
  4. In the Environment Variables area, select an environment. If no environment is available, click Create Environment to create one.
  5. Click Add Environment Variable and enter the variable information.

    Environment variable names and values will be displayed in plain text in API requests. Do not include sensitive information in the variable names and values.

    Table 1 Adding an environment variable




    Variable name. Ensure that the name is the same as the name of the variable defined for the API.


    The path to be used in the selected environment.

  6. Click OK.

Follow-Up Operations

After creating an environment variable, you can publish the API in the environment where the variable is located so that the API can be called.