Skip to content

API reference

Environments API

Named, versioned sets of environment variables and secret files that VMYard applies to machines.

On this page

List environments

GET /v1/environments

  • API key: Authorization: Bearer vmy_… with preset read_only, use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie.
  • Who: Any member.

Parameters

NameInTypeRequiredDescription
X-Organization-IDheaderstring (uuid)NoOrganization context. Required with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
200—EnvironmentList
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
Request
curl "$VMYARD_API_URL/v1/environments" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
Response 200
{
  "items": [
    {
      "created_at": "string",
      "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "current_version": {
        "change": {},
        "created_at": "string",
        "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
        "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
        "files": [
          {
            "path": "notes/todo.txt",
            "size": 0
          }
        ],
        "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
        "vars": [
          "string"
        ],
        "version": 0
      },
      "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "is_default": false,
      "name": "staging",
      "safe_for_third_parties": false,
      "updated_at": "string"
    }
  ]
}

Create an environment

POST /v1/environments

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
X-Organization-IDheaderstring (uuid)NoOrganization context. Required with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, CreateEnvironmentRequest)

FieldTypeRequiredDescription
filesSecretFileInput[]No
is_defaultboolean | nullNoDefaults to true when the organization has no default environment.
namestring | nullNoLowercase DNS label, unique in the organization. Defaults to base.
safe_for_third_partiesbooleanNo
varsmap of stringNoVariable names (^[A-Za-z_][A-Za-z0-9_]{0,127}$) to values.

Responses

StatusDescriptionBody
201The created environment (not the list)EnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403A role other than owner/admin, or an API key without full_accessProblemDetails
409environment_name_taken or environment_limit_reachedProblemDetails
413The request body is too large (body_too_large).ProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
503environments_unavailable: no encryption keys configuredProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/environments" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "staging",
  "vars": {
    "DATABASE_URL": "postgres://app@db.internal/app",
    "LOG_LEVEL": "info"
  },
  "files": [
    {
      "path": "secrets/service-account.json",
      "contents": "{\"type\": \"service_account\"}"
    }
  ]
}'
Response 201
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Get an environment

GET /v1/environments/{environment_id}

  • API key: Authorization: Bearer vmy_… with preset read_only, use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie.
  • Who: Any member.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
200—EnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
Request
curl "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Change an environment

PATCH /v1/environments/{environment_id}

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, UpdateEnvironmentRequest)

FieldTypeRequiredDescription
is_defaultboolean | nullNotrue makes this the default; false leaves the organization without one.
namestring | nullNo
safe_for_third_partiesboolean | nullNo

Responses

StatusDescriptionBody
200Metadata only; no new versionEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
409Conflicts with the current state, such as a reused idempotency key with another body (idempotency_conflict).ProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
Request
curl -X PATCH "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "is_default": true
}'
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Delete an environment

DELETE /v1/environments/{environment_id}

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
204Deleted; machines keep the versions they have—
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
Request
curl -X DELETE "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID" \
  -H "Authorization: Bearer $VMYARD_API_KEY"

Set a variable

PUT /v1/environments/{environment_id}/vars/{key}

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
keypathstringYes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, SetVariableRequest)

FieldTypeRequiredDescription
valuestringYesAt most 32 KiB without NUL.

Responses

StatusDescriptionBody
200A new version was writtenEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
503Not available on this server.ProblemDetails
Request
curl -X PUT "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/vars/$KEY" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "value": "info"
}'
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Remove a variable

DELETE /v1/environments/{environment_id}/vars/{key}

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
keypathstringYes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
200A new version was writtenEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Unknown environment or variable_not_foundProblemDetails
503Not available on this server.ProblemDetails
Request
curl -X DELETE "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/vars/$KEY" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Set a secret file

PUT /v1/environments/{environment_id}/files

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, SecretFileInput)

FieldTypeRequiredDescription
contentsstringYes
pathstringYesRelative to /work: no leading /, ~, ., .., or empty components, and not under .vmyard.
encodingFileEncodingDtoNo

Responses

StatusDescriptionBody
200A new version was writtenEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
413The request body is too large (body_too_large).ProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
503Not available on this server.ProblemDetails
Request
curl -X PUT "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/files" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "path": "secrets/token.txt",
  "contents": "s3cr3t\n"
}'
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

Remove a secret file

DELETE /v1/environments/{environment_id}/files

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, RemoveFileRequest)

FieldTypeRequiredDescription
pathstringYes

Responses

StatusDescriptionBody
200A new version was writtenEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Unknown environment or file_not_foundProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
503Not available on this server.ProblemDetails
Request
curl -X DELETE "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/files" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "path": "secrets/token.txt"
}'
Response 200
{
  "created_at": "string",
  "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "current_version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  },
  "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "is_default": false,
  "name": "staging",
  "safe_for_third_parties": false,
  "updated_at": "string"
}

List versions

GET /v1/environments/{environment_id}/versions

  • API key: Authorization: Bearer vmy_… with preset read_only, use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie.
  • Who: Any member.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
200—EnvironmentVersionList
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
Request
curl "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/versions" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
Response 200
{
  "items": [
    {
      "change": {},
      "created_at": "string",
      "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "files": [
        {
          "path": "notes/todo.txt",
          "size": 0
        }
      ],
      "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "vars": [
        "string"
      ],
      "version": 0
    }
  ]
}

Reveal values

POST /v1/environments/{environment_id}/reveal

  • API key: Authorization: Bearer vmy_… with preset full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner or Admin.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, RevealRequest)

FieldTypeRequiredDescription
version_idstring (uuid) | nullNoA version of this environment; omitted reveals the current version.

Responses

StatusDescriptionBody
200Values and file contents; audited as environment.revealedRevealedEnvironmentDto
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403A role other than owner/admin, or an API key without full_accessProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
503Not available on this server.ProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/reveal" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
Response 200
{
  "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "files": [
    {
      "contents": "string",
      "encoding": "text",
      "path": "notes/todo.txt"
    }
  ],
  "vars": {},
  "version": {
    "change": {},
    "created_at": "string",
    "created_by": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "files": [
      {
        "path": "notes/todo.txt",
        "size": 0
      }
    ],
    "id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
    "vars": [
      "string"
    ],
    "version": 0
  }
}

Upgrade machines

POST /v1/environments/{environment_id}/upgrade

  • API key: Authorization: Bearer vmy_… with preset use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner, Admin, or Operator.

Parameters

NameInTypeRequiredDescription
environment_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, UpgradeEnvironmentRequest)

FieldTypeRequiredDescription
machine_idsstring (uuid)[] | nullNoMachines to upgrade; omitted upgrades every running machine created with this environment. At most 100.

Responses

StatusDescriptionBody
202One apply operation per upgraded machine; repeating the request replays themUpgradeEnvironmentResponse
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
409environment_upgrade_conflict: a machine changed meanwhile; retryProblemDetails
422A machine is not one created with this environmentProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/environments/$ENVIRONMENT_ID/upgrade" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "machine_ids": [
    "0b6f6c55-2f1d-4f0e-9a51-6f0f4cba7a10"
  ]
}'
Response 202
{
  "environment_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "operations": [
    {
      "machine_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "operation_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "operation_url": "/v1/operations/6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f"
    }
  ],
  "skipped": [
    {
      "machine_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
      "reason": "not_running"
    }
  ],
  "version": 0,
  "version_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f"
}