Environment variables


Mockoon offers the possibility to access environment variables in your templates using the getEnvVar helper. This allows you to avoid exposing your API keys and certificates in your mock server configuration.

 Environment variables support

Environment variables are accessible everywhere templating helpers are supported.

 Default prefix

By default, only the environment variables prefixed with MOCKOON_ are available, for example, MOCKOON_MY_VARIABLE. You can access the variable in your templates using the getEnvVar helper:

Copy
{{getEnvVar 'MOCKOON_MY_VARIABLE'}}

 Changing or removing the prefix

You can change the prefix or remove it entirely in the application settings:

application settings modal with the prefix input highlighted

Removing the prefix will make all the environment variables accessible in your templates.