# Environment specific vault values (Solved)

**URL:** <https://community.postman.com/t/environment-specific-vault-values-solved/71191>\
**Category:** Help Hub\
**Tags:** variables, vault\
**Created:** [November 13, 2024, 5:39pm UTC](https://community.postman.com/t/environment-specific-vault-values-solved/71191 "2024-11-13T17:39:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliviercuyp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/oliviercuyp/32/30719_2.png) [@oliviercuyp](https://community.postman.com/u/oliviercuyp)\
**Post date:** [November 13, 2024, 5:39pm UTC](https://community.postman.com/t/environment-specific-vault-values-solved/71191/1 "2024-11-13T17:39:45Z")

</div>

There was already the same topic but it was closed due to 30 days inactivity.  
I still wanted to give the work around I’m using since I believe it will help others.

Lets assume you need to access an external api with an api key that differ in test and prod.

Here is the way I have vault variable based on the active environment.  
It is a 3 steps process:

## Define put the api keys in the vault:

- **external\_api\_key\_test:** t3sts3cr3t
- **external\_api\_key\_prod:** pr0ds3cr3t
- …

## Define less sensitive info in the environments

### Test environment variables

- **vault\_suffix:** test
- **external\_api\_base\_url:** [https://test.external-api.com](https://test.external-api.com)
- …

### Prod environment variables

- **vault\_suffix** : prod
- **external\_api\_base\_url** : [https://external-api.com](https://external-api.com)

## Request Authorization (or directly on the collection)

- **Auth Type:** Api Key
- **Key:** api-key
- **Value:** {{vault:external\_api\_key\_{{vault\_suffix}}}} **// Here stands the magic**
- **Add to:** Header

Hope it helped.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 13, 2024, 5:40pm UTC](https://community.postman.com/t/environment-specific-vault-values-solved/71191/2 "2024-12-13T17:40:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
