Persist variables in Postman

In Postman, variables enhance flexibility by allowing you to store and reuse values across your API requests, collections, environments, and scripts. Understanding how to manage these variables effectively ensures consistency and efficiency in your workflows. If you’re familiar with the basics of variables in Postman, you will see there are many different ways to work with variables in Postman, just like in programming. Let’s examine a few scenarios for persisting variable values.

Persist Variables Between Local Sessions

Postman distinguishes between Current Value and Initial Value for variables:

  • Current Value: Used during your active session; not saved or synced with Postman Cloud.
  • Initial Value: Saved and shared across sessions and with your team.

When you run a workflow in a collection that modifies the values of a variable and you need the values you started with to persist across session runs you need to:

  • Update the Initial Value to match the Current Value.
  • Use the “Persist All” option in the variable editor to apply changes across all variables.

This approach ensures that your variable values are maintained across different sessions and accessible to team members.

Persist Variables Throughout a Collection Run

For temporary variables needed only during a collection run, but not afterwards, you can use local variables :

  • Utilize local variables within scripts using pm.variables.set() and pm.variables.get().
  • These variables override other scopes during the run and do not persist afterward.

When running collections using the Collection Runner.

  • Enable the “Keep variable values” option to retain changes made to variables during the run.
  • Disabling this option means any changes will be discarded after the run completes.

This setup is beneficial for scenarios where variable values need to be consistent throughout a run but not beyond.


Working with variables can be tricky. By effectively managing variable persistence, you can enhance the reliability and efficiency of your API testing and development workflows in Postman. How do you manage variables in your workflows?