Skip to main content

How to persist variable values

Persisting variable values will replace initial values with current values.

Note: For enhanced privacy of your environment variable data, the automatically persist variable values option in Settings has been removed from v8.0.8 (Release Notes) and current values of variables no longer automatically persist to initial values when modified.

This article helps you achieve one of the following options:

Persist all current values

Select on Persist All button in the variable edit screens.

Persist only some of the current values

  1. Uncheck the variables you do not want to persist current values in the variable edit screens.
  2. Select on Persist All button.

Programmatically update initial values from pre-request or test scripts

From a script, send a request to the Update Environment endpoint of Postman API.

Example:

const requestOptions = {
url: 'https://api.getpostman.com/environments/<environment_uid>',
method: 'PUT',
header: {
'X-API-Key':'<your-API-key>'
},
body: {
mode: 'raw',
raw: JSON.stringify({
'environment': {
'name': 'New Env Name',
'values': [
{
'key': 'var-one',
'value': 'one'
},
{
'key': 'var-two',
'value': 'two'
}]
}
})
}
}

pm.sendRequest(requestOptions, (error, response) => {
if (error) {
console.log(error)
}
})
 


Have more questions? Submit a request