Add Enviroment Variables to API

In many cases you might have different API endpoints for different deployment environments such as staging, production and sandbox. This article explains how to configure the same on the yellow.ai:

  1. Go to Studio > Build > API.

  2. Navigate to the API tab for which you wanted to add environment variables. You can also do it while adding a new API.

  3. In the API URL, replace the host URL with a variable.

  4. Add a placeholder for the API endpoint.

    In the example, we have used host as the API placeholder.

  5. On the right sidebar, click on Configure Environment.

  6. Enter API endpoints for each environment.

    drawing

  1. Lastly, before making an API call, select an environment from the dropdown. Based on the environment variables you’ve configured earlier, it’ll replace {{{env.variables}}} placeholder with the value.
https://{{{env.url}}}/data/2.5/weather?q={city name}&appid={API key}

drawing