List Vault Environment Fields

Returns only fields marked for environment-variable export in one vault, with their latest stored encrypted payloads.

GET /api/v1/machine/vault/:vaultId/environment-fields

Use this route when a runtime is building project environment JSON and does not need every field on every vault item. The CLI and Node SDK use this endpoint when available, then decrypt the returned field values locally.

Headers

HeaderTypeRequiredDescription
X-API-KeystringYesYour API key

Path Parameters

ParameterTypeRequiredDescription
vaultIdstringYesThe unique identifier of the vault

Response

Success (200 OK)

{
  "vaultId": "507f1f77bcf86cd799439011",
  "fields": [
    {
      "id": "507f1f77bcf86cd799439034",
      "name": "Password",
      "type": "PASSWORD",
      "order": 3,
      "fieldInstanceId": "507f1f77bcf86cd799439054",
      "fieldInstanceIds": ["507f1f77bcf86cd799439054"],
      "assetId": null,
      "assetIds": [],
      "isEnvironmentVariable": true,
      "value": "{\"v\":3,\"iv\":\"...\",\"t\":\"...\",\"d\":\"...\"}",
      "vaultId": "507f1f77bcf86cd799439011",
      "vaultItemId": "507f1f77bcf86cd799439021",
      "vaultItemName": "Production Database"
    }
  ],
  "count": 1
}

Response Fields

FieldTypeDescription
vaultIdstringVault that owns the returned fields
fieldsarrayEnvironment-exportable field values
countnumberTotal number of environment fields returned
fields[].idstringField ID
fields[].namestringField label. This metadata is not end-to-end encrypted.
fields[].typestringField type
fields[].ordernumberField display order
fields[].fieldInstanceIdstring | nullLatest active field-instance ID used for value
fields[].fieldInstanceIdsstring[]Full active field-instance set for the field
fields[].assetIdstring | nullLatest active attached asset ID
fields[].assetIdsstring[]Full active asset set for the field
fields[].isEnvironmentVariableboolean | nullEnvironment-variable export flag
fields[].valuestring | nullField value as stored. In client-encrypted vaults, this is a v3 vault envelope string
fields[].vaultItemIdstringParent vault item ID
fields[].vaultItemNamestringParent vault item name. This metadata is not end-to-end encrypted.

Audit and Activity

This endpoint records access in two places:

  • security audit logs use VAULT_FIELD_ACCESSED with environmentOnly: true
  • vault activity records use ENVIRONMENT_FIELD_READ once for each parent vault item whose environment fields were returned

For AGENT-scoped sessions, the vault activity is attributed to the agent.

Verification Notes

Error Responses

404 Not Found - Vault not found or not accessible

{
  "error": {
    "code": "vault_not_found",
    "message": "The vault with ID \"507f1f77bcf86cd799439011\" was not found or you do not have access to it."
  }
}

Example Request

curl -X GET "https://r4.dev/api/v1/machine/vault/507f1f77bcf86cd799439011/environment-fields" \
  -H "X-API-Key: rk_abc123def456.ghijklmnopqrstuvwxyz"

Use Cases

  • Project env export: Build environment JSON without fetching full item details.
  • Agent runtime boot: Load only fields explicitly marked for environment-variable export.
  • Least data movement: Avoid retrieving sibling fields that the runtime does not need.
endpoint-vault-environment-fields - R4 Docs