19
votes

Is there any way to delete/clear postman environment variable using functions at runtime. I could possibly set to blank or some special value but is there a general way of doing things.

3

3 Answers

20
votes

Sandbox API pm.environment.unset(variableName) also allows to do that.

In case is you want to clear all environment variables at once - you might want to do: pm.environment.clear().

This will clear all your environment values.

Refer: https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmenvironment

21
votes

Ok - so this does it.

postman.clearEnvironmentVariable("key");
0
votes

And the right one syntax is:

pm.environment.unset("key");