Admin API: Environment variables


This endpoint allows you to manage the environment variables, without restarting the mock server or the application.

 Get an environment variable value

To get the value of an environment variable, call the /mockoon-admin/env-vars endpoint with the following parameters:

  • Method: GET
  • URL: /mockoon-admin/env-vars/:key, where :key is the name of the variable, including or not the MOCKOON_ prefix, or the custom prefix defined in the application settings.

Example request:

Copy
GET /mockoon-admin/env-vars/MOCKOON_ENV_VAR

Example response:

Copy
{ "key": "MOCKOON_ENV_VAR", "value": "variableValue" }

 Set or update an environment variable

To set or update an environment variable, call the /mockoon-admin/env-vars endpoint with the following parameters:

  • Method: POST, PUT or PATCH
  • URL: /mockoon-admin/env-vars
  • Body: JSON object with the following properties:
    • key: the name of the variable, including the MOCKOON_ prefix, or the custom prefix defined in the application settings.
    • value: the value of the variable.

Example request:

Copy
POST /mockoon-admin/env-vars Content-Type: application/json { "key": "MOCKOON_ENV_VAR", "value": "myValue" }