Globals don't seem to be global across workspaces

We make fairly heavy use of Workspaces and we usually have a set of services managed on our team’s Workspace and a subset of those in our Customer facing workspace. We store API keys in global variables that are then used in our environments depending NON-PROD or PROD. However, I notice that these Globals are not global across workspaces. Is there another construct I should be using to allow for this functionality?

It’s not a huge deal but then I have to copy my keys into a new set of global variables on the other workspace. A slight annoyance.

Hi @lsacco,

Yes, Global variables are accessible across all collections in the workspace where it is defined, if you have a large no. of workspace and you do not want to define the same global variables for each of them, I think the better way to go for your specific use case is to use environment variables and share those environment variables across multiple workspaces, Have a look at the below documentation to learn more about managing environment variables:

1 Like

Yes, we use environments too and then reference globals for things like API keys, but again neither seem to transcend the “Workspace” context. I don’t see anything in your docs regarding that in the way I would think you’d use it. Are you suggesting, copying environments from one workspace to another to accomplish this? Keep in mind too, that the reason we use globals is that they are personal, so those keys are user specific so the user wants to leverage their API key across environments for different reasons.

Hi @lsacco,

No, I am not suggesting copying the environment variables manually, I was referring to sharing environment variables with other workspaces, the link below will take you directly to a “How to” on sharing environment variables

If you need to convert those environment variables to global variables in the respective workspaces, you can do that by adding the following test script in the Pre-request script tab of the first request to be run on the respective workspace:

  env = pm.environment.get("variable_key"); // This fetches the environment variable which you shared to the specific workspace and stores it in env

  pm.globals.set("variable_key", env); // This will set env as a global variable

Ok. I have a meeting with our Postman CSM next week to discuss in more detail. I’m realizing here that what I’m describing is an enhancement request to maintain API keys securely across all workspaces. You wouldn’t want to be storing/copying environment variables over from one to the other that contain API keys, which is what that post describes. This could introduce data leakage. Thanks.

1 Like