What if you could change one value and fix all your API tests at once?
Why Collection variables in Postman? - Purpose & Use Cases
Imagine you are testing many API requests in Postman, and each request needs the same information like an API key or a server address. You write this information again and again in every request.
This manual way is slow and tiring. If the API key changes, you must update it in every request one by one. This causes mistakes and wastes time.
Collection variables let you store common information once for all requests in a collection. When you change the variable, all requests use the new value automatically.
Set API key in each request header manually.Use {{api_key}} variable in headers, set once in collection variables.It makes managing shared data easy and error-free across many API requests.
When testing a website's API, you store the login token as a collection variable. All requests use it, so when the token updates, you change it once and all tests stay current.
Manual repetition of data is slow and error-prone.
Collection variables store shared data once for all requests.
Updating a variable updates all requests automatically.