# Updating environment variables via postman API does not reflect on Postman UI

**URL:** <https://community.postman.com/t/updating-environment-variables-via-postman-api-does-not-reflect-on-postman-ui/85179>\
**Category:** Help Hub\
**Tags:** variables, environments, setenvironmentvariab\
**Created:** [October 1, 2025, 5:16am UTC](https://community.postman.com/t/updating-environment-variables-via-postman-api-does-not-reflect-on-postman-ui/85179 "2025-10-01T05:16:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaustubh-agrawal](https://avatars.discourse-cdn.com/v4/letter/k/bc8723/32.png) [@kaustubh-agrawal](https://community.postman.com/u/kaustubh-agrawal)\
**Post date:** [October 1, 2025, 5:16am UTC](https://community.postman.com/t/updating-environment-variables-via-postman-api-does-not-reflect-on-postman-ui/85179/1 "2025-10-01T05:16:01Z")

</div>

I am trying to run a Newman runner on CI/CD. For that i need some environment variables to be updated during runtime like `firebase_tokens` and all.

In the CI/CD:

1. I am generating the required secrets.
2. Then updating the postman environment variables.
3. Then i run Newman runner.

The steps 1 and 3 are working as intended.  
But the problem, is that the secrets that I am generating in the step 1 is not reflecting on the Postman UI as well as on the runner.

From what I can see in the Postman API docs,  
The code to update the environment variables goes like this:

`///////////////////////////`  
`// POSTMAN`  
`///////////////////////////`

```javascript
const postmanAPIKey = process.env.POSTMAN_API_KEY;
const environmentId = process.env.POSTMAN_ENVIRONMENT_ID;

if (!postmanAPIKey || !environmentId) {
  console.error("Missing POSTMAN_API_KEY or POSTMAN_ENVIRONMENT_ID");
  return;
}

const response = await fetch(
  `https://api.getpostman.com/environments/${environmentId}`,
  {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
      "X-Api-Key": postmanAPIKey,
    },
  }
).catch((err) => {
  console.error("Failed to get environment", err.message);
  process.exit(1);
});

const data = await response.json();
const updatedEnvs = data.environment.values;

const updates = [{ key: "firebase_auth_token", value: token, enabled: true }];

for (const update of updates) {
  const existingEnv = updatedEnvs.find((env) => env.key === update.key);
  if (existingEnv) {
    existingEnv.value = update.value;
    existingEnv.enabled = true;
    existingEnv.type = existingEnv.type || "default"; // ensure type stays valid
  } else {
    updatedEnvs.push({
      key: update.key,
      value: update.value,
      enabled: true,
      type: "default",
    });
  }
}

console.log("updatedEnvs:", JSON.stringify(updatedEnvs, null, 2));

await fetch(`https://api.getpostman.com/environments/${environmentId}`, {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": postmanAPIKey,
  },
  body: JSON.stringify({
    environment: {
      id: data.environment.id,
      name: data.environment.name,
      values: updatedEnvs,
    },
  }),
}).catch((err) => {
  console.error("Failed to update environment", err.message);
  process.exit(1);
});

console.log("Environment updated successfully");

```

I also read the following post. I could also confirm i have all the env’s are shared in my environment file.

> [@Some postman env variables not being used in github CI runs](https://community.postman.com/t/some-postman-env-variables-not-being-used-in-github-ci-runs/85152/13):
>
> I have added a console log before the test and unfortunately the output is completely blank. I was hoping that would have given some clarity but sadly not. The full suite is working properly when run in the Postman UI, so I know for sure the variables are being called properly. Also confirmed in the Variables in request tab that I’m pulling down the correct value. I’ve manually looked through, but I’ll add a second console log at the very top of the suite to see if I can narrow things down.
