> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/programming/postman/environment-variables.md).

# Environment Variables

* Environment variables allow developers to switch between DEV and PROD for example
* It allows for definition of different variables based on needs
* Allows to define variables dynamically

#### To define Environment variables such as the URL:

<figure><img src="/files/eyOigjsxmzJlWtKV85AS" alt=""><figcaption></figcaption></figure>

* After this has been defined, you can call it in the operation path:

<figure><img src="/files/45GKjU41PI64oJYWCAtd" alt=""><figcaption></figcaption></figure>

#### It also became harder to test our API since we have added the login logic and protected routes

* So to save some time, we can automate the definition of the JWT as an environment variable through code
* This should be done under the <mark style="color:orange;">`login`</mark> path operation as to define it directly as you log in
* Navigate to the <mark style="color:orange;">`Tests`</mark> tab and select <mark style="color:purple;">`Set an environment variable`</mark>
* Use the following code to set it dynamically

```python
pm.environment.set("JWT", pm.response.json().access_token);
```

* The above code sets the environment variable as <mark style="color:orange;">`JWT`</mark> with the value fetching first the response, then transforming it into a JSON output from which the variable named in the return output is called&#x20;
* In our case <mark style="color:orange;">`access_token`</mark> but can be anything as it's app defined under the route return

<figure><img src="/files/nvOUZ0r58MAg1lsuVsZJ" alt=""><figcaption></figcaption></figure>

* After this is defined, we can call it under the authorization tab as `{{JWT}}` to always have it update on login

<figure><img src="/files/8I1gh5v5akl7IYPzVXKy" alt=""><figcaption></figcaption></figure>
