Skip to content

Environment variables

The following environment variables are supported:

Variable name Purpose Default Description/example(s)
IMPOSTER_ADD_ENGINE_RESPONSE_HEADERS Add response headers for server and unique request ID. true false
IMPOSTER_AUTO_BASE_PATH Automatically set the base path for each configuration file, based on its relative path from the configuration root directory. false true
IMPOSTER_CACHE_DIR Path to a directory in which to store cached data, such as remote specifications. <Java temporary directory>/imposter-cache /path/to/dir
IMPOSTER_CONFIG_DIR The path to the configuration directory. Can be specified as a comma-separated list. See configuration location. Empty /path/to/config/dir - See Configuration Location.
IMPOSTER_CONFIG_SCAN_RECURSIVE Scan for configuration files recursively within the configuration directories. See recursive configuration discovery. false true
IMPOSTER_CONFIG_DISCOVER_ENVFILES Discover envfiles. See below. true false
IMPOSTER_ESCAPE_COLONS_IN_PATH Escape colons in paths. false true
IMPOSTER_FEATURES Enables or disables features. See Features documentation. Per default features. metrics=false,stores=true
IMPOSTER_IGNORE_CONFIG_ERRORS Log errors encountered during configuration parsing or plugin configuration instead of throwing an exception. Defaults to false, as skipping a configuration might also skip the security conditions it contains. false boolean
IMPOSTER_JS_PLUGIN Sets the JavaScript implementation. js-graal Can be changed to js-nashorn plugin, if installed.
IMPOSTER_LOG_LEVEL Sets logging level. DEBUG INFO, DEBUG, TRACE
IMPOSTER_LOG_REQUEST_BODY Include request in structured log entries. false true - See Metrics, logs and telemetry.
IMPOSTER_LOG_REQUEST_HEADERS Comma separated list of request headers to add to structured log entries. Empty X-Correlation-ID,User-Agent - See Metrics, logs and telemetry.
IMPOSTER_LOG_RESPONSE_BODY Include response in structured log entries. false true - See Metrics, logs and telemetry.
IMPOSTER_LOG_RESPONSE_HEADERS Comma separated list of response headers to add to structured log entries. Empty Server,Content-Type - See Metrics, logs and telemetry.
IMPOSTER_LOG_SUMMARY Log a JSON formatted summary message on each request. false true
IMPOSTER_LOG_SUMMARY_PRETTY Pretty print the summary log JSON. false true
IMPOSTER_NORMALISE_HEADER_KEYS Forces header keys to be lowercased. true boolean
IMPOSTER_OPENAPI_EXPOSE_SPEC Expose the OpenAPI specification and UI. See OpenAPI plugin. true false
IMPOSTER_OPENAPI_REMOTE_FILE_CACHE Locally cache remote OpenAPI specifications. See OpenAPI plugin. false true
IMPOSTER_OPENAPI_SPEC_PATH_PREFIX Overrides the default specification path prefix. See OpenAPI plugin. /_spec /openapi-spec
IMPOSTER_OPENAPI_VALIDATION_DEFAULT_BEHAVIOUR The default behaviour for OpenAPI validation issues. See OpenAPI validation. IGNORE See OpenAPI validation.
IMPOSTER_PLUGIN_ARGS Comma separated map of plugin arguments. Analogous to --pluginArg command line argument. Empty openapi.scheme=https,openapi.title=Mocks
IMPOSTER_PLUGIN_CLASSLOADER_STRATEGY Sets the classloader strategy for plugins. Parent-first child
IMPOSTER_PLUGIN_DIR Path to a directory containing additional plugin JAR files. Empty Used by Stores and Plugins.
IMPOSTER_PREFER_EXACT_MATCH_ROUTES Prefer routes with exact matches over those with path placeholders when matching requests. true boolean
IMPOSTER_STORE_DRIVER Sets the store driver plugin. store-inmem See Stores.
IMPOSTER_STORE_KEY_PREFIX Sets a prefix for store keys. Empty See Stores.
IMPOSTER_SCRIPT_CACHE_ENTRIES The number of precompiled scripts to cache. Precompiled scripts execute faster, but the cache uses memory. 20 30
IMPOSTER_SCRIPT_PRECOMPILE Precompile scripts at startup. true boolean
IMPOSTER_RESPONSE_FILE_CACHE_ENTRIES The number of response files to cache in memory. Cached response files don't require disk I/O, but the cache uses memory. 20 30
IMPOSTER_YAML_CODE_POINT_LIMIT The maximum number of characters to parse in a YAML file. The default is 3MB. Note that the size depends on the file encoding. 3145728 (3MB) 10485760 (10MB)

Note: other features may include their own environment variables. See the feature specific documentation for more details.

Setting environment variables using a file

You can use an environment file ('envfile') to pass environment variables to Imposter. To do this, add a file named .env adjacent to your configuration files, for example:

$ ls
.env
imposter-config.yaml

$ cat .env
IMPOSTER_LOG_LEVEL=info
OTHER_ENV_VAR=example