# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/programming/postman/environment-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
