# Accessing global variables when running collection using Newman

**URL:** <https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133>\
**Category:** Help Hub\
**Created:** [March 2, 2020, 8:31pm UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133 "2020-03-02T20:31:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcarva](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dcarva](https://community.postman.com/u/dcarva)\
**Post date:** [March 2, 2020, 8:31pm UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133/1 "2020-03-02T20:31:22Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

Hello!

I am using newman to run requests from a postman collection file. This file was created using the Postman export feature. Ex:

> newman run “Tests.postman\_collection.json”

I have created some global variables inside of Postman, and I call those in the GET request url. Ex:

> https://{{instance}}.testing.devops.com/

This all works when I run from the Postman UI. But when I run from command line, it doesn’t replace “{{instance}}” with the global variable named “instance”. Is there another step I can take to make this work? Or, do I have to hard code the values in the exported collection file?

Thanks in advance!  
dcarva

---

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [March 3, 2020, 1:32am UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133/2 "2020-03-03T01:32:11Z")

</div>

Hi, @dcarva! Welcome.

Globals can be passed as a command line parameter, either as a JSON file path/URL (via `--globals`) or individually (via `--global-var`). See here: [https://github.com/postmanlabs/newman/#newman-run-collection-file-source-options](https://github.com/postmanlabs/newman/#newman-run-collection-file-source-options).

---

<div class="post-metadata">

**Author:** ![dcarva](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dcarva](https://community.postman.com/u/dcarva)\
**Post date:** [March 3, 2020, 1:28pm UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133/3 "2020-03-03T13:28:07Z")

</div>

Thank you! That works for me.

---

<div class="post-metadata">

**Author:** ![madhusudan](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@madhusudan](https://community.postman.com/u/madhusudan)\
**Post date:** [May 12, 2020, 4:50am UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133/5 "2020-05-12T04:50:16Z")

</div>

Hi, @dcarva,  
can please share the step by step to run this, im facing same proble  
i have more then 10 api and every api dependes on other api response.  
its working when run using postman but not newman

---

<div class="post-metadata">

**Author:** ![navigation-observer2](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@navigation-observer2](https://community.postman.com/u/navigation-observer2)\
**Post date:** [November 2, 2023, 9:46am UTC](https://community.postman.com/t/accessing-global-variables-when-running-collection-using-newman/11133/6 "2023-11-02T09:46:32Z")

</div>

First, export environment and global variables as JSON files  
Then, you can use this command

> newman run Automation.postman\_collection.json --globals “” --environment “”
