# Postman env: set only current value with Postman API

**URL:** <https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641>\
**Category:** Help Hub\
**Tags:** environments, postman-api\
**Created:** [October 29, 2019, 5:09pm UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641 "2019-10-29T17:09:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KrisBr4](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/krisbr4/32/3859_2.png) [@KrisBr4](https://community.postman.com/u/KrisBr4)\
**Post date:** [October 29, 2019, 5:09pm UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/1 "2019-10-29T17:09:42Z")

</div>

I would love to streamline the on-boarding process for new users on my team.

**Requirement:** We keep all environment variables in the **current value** column to avoid syncing the values to the cloud and protect sensitive information.

**What we currently do:** The new dev manually creates 5 different environments, then switches to each one and runs some scripts given to them by a team mate in the “pre-request script” tab. This populates all variables for that environment. Then they repeat this process for each environment.

**What I want to do:** Use the Postman Api to create a collection that makes this process simpler. Ideally one request that creates many collections and populates ONLY the current values.

Is there a way to set variables in environments that are not selected?  
Can you set ONLY the current value with the API?

I’m open to suggestions.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 30, 2019, 5:22pm UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/2 "2019-10-30T17:22:56Z")

</div>

Hey @KrisBr4,

Welcome to the community! 🌟

Creating those different `environment` files with placeholder `variable names` should be easy enough using the `Create Environment` endpoint on the [Postman API](https://docs.api.getpostman.com/). You _could_ create a Collection and run that in the `Collection Runner` or with `Newman`.

`POST https://api.getpostman.com/environments?apikey=<yourAPIKey>`

The `Request` Body could be something simple like:

```
{
    "environment": {
        "name": "{{envName}}",
		"values": [
			{
				"key": "{{varOne}}",
				"value": "",
				"enabled": true
			},
			{
				"key": "{{varTwo}}",
				"value": "",
				"enabled": true
			}
		]
    }
}

```

You can then create a `Data File` containing the different names and the Runner would iterate over those and fill in the `variable` placeholders in the `request Body` and create the Environments.

Something simple like this:

```
[
  {
    "envName": "Environment One",
    "varOne": "username",
    "varTwo": "password"
  },
  {
    "envName": "Environment Two",
    "varOne": "username",
    "varTwo": "password"
  },
  {
    "envName": "Environment Three",
    "varOne": "username",
    "varTwo": "password"
  }
]

```

I think you’re going to struggle to add _only_ `current` values, using the Postman API though.

Those values are only supposed to be known locally so once you add these to a request, which calls the Postman API - Those values are no longer _just_ known locally and are synced to the cloud.

---

<div class="post-metadata">

**Author:** ![maintenance-partici1](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@maintenance-partici1](https://community.postman.com/u/maintenance-partici1)\
**Post date:** [October 13, 2022, 4:04am UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/3 "2022-10-13T04:04:45Z")

</div>

Still not able to update environment variables ‘current value’ with API. any updates solution on this ??

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 13, 2022, 10:39am UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/4 "2022-10-13T10:39:12Z")

</div>

This wouldn’t populate just the `current` value, when using the Postman API.

> Those values are only supposed to be known locally so once you add these to a request, which calls the Postman API - Those values are no longer _just_ known locally and are synced to the cloud.

---

<div class="post-metadata">

**Author:** ![darkings1990](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@darkings1990](https://community.postman.com/u/darkings1990)\
**Post date:** [November 12, 2023, 1:37pm UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/5 "2023-11-12T13:37:30Z")

</div>

I developed an IDEA plugin and in my plugin, I can update requests or environment to Postman using Postman API.

When I change the environment value and then use Update Environment API to update the environment, then I run the request in Postman and this request will use the old environment value but not the updated one. So update environment API has no value even if the workspace is private.

So, is there any plan to develop an API that can update **Current Value** of environment

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [November 12, 2023, 4:59pm UTC](https://community.postman.com/t/postman-env-set-only-current-value-with-postman-api/8641/6 "2023-11-12T16:59:06Z")

</div>

> [@darkings1990](#):
>
> So, is there any plan to develop an API that can update **Current Value** of environment

I very much doubt it, as the current value is not synced to the cloud or included if you export the environment to a json file to include in your code repository.

This is for a good reason, as this is where you store confidential information like tokens, client secrets and passwords and these shouldn’t be sycned to the Postman cloud or included in your code repository. These artefacts should be stored in a key vault or another secure location.

The idea is that you cut and paste these when working with them locally.

You would automate the process in your continuous integration tool when running the pipelines. One of the first steps in the pipeline would be to retreive these secrets and send them to the CI tool in the command line (so its only really automated at this point).
