> ## Documentation Index
> Fetch the complete documentation index at: https://hyperbrowser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Vaults

> Group secrets under one name and pass them to sandboxes and browser sessions together.

A vault maps environment variable names to [secrets](https://hyperbrowser.ai/docs/sandboxes/secrets.md), such as `DB_URL` to `app-db-url`. You pass the vault by name to a sandbox to set all its variables at once, or attach it to a browser session to [fill a login](https://hyperbrowser.ai/docs/sessions/credentials.md) by its entry names. A vault holds no values itself: each entry points at a stored secret. To read values from 1Password instead, pass [1Password fields](https://hyperbrowser.ai/docs/sandboxes/1password.md) with the request.

> [!NOTE]
>
> Vaults are part of [Secrets](https://hyperbrowser.ai/docs/sandboxes/secrets.md), which are enabled for teams on request, and use the same scopes: `secrets.manage` to create and change vaults, `secrets.read` to read them, and `secrets.use` to pass them to sandboxes and sessions.

## Create a vault

Each entry names a secret, and optionally a version to pin. Without a version, the entry follows the secret's latest version.

```typescript Node.js theme={null}
import { Hyperbrowser } from "@hyperbrowser/sdk";

const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });

await client.vaults.create({
  name: "app-env",
  description: "Production app settings",
  entries: {
    DB_URL: { name: "app-db-url" },
    API_KEY: { name: "provider-key", version: 2 },
  },
});
```

```python Python theme={null}
import os
from hyperbrowser import Hyperbrowser

client = Hyperbrowser(api_key=os.environ["HYPERBROWSER_API_KEY"])

client.vaults.create({
    "name": "app-env",
    "description": "Production app settings",
    "entries": {
        "DB_URL": {"name": "app-db-url"},
        "API_KEY": {"name": "provider-key", "version": 2},
    },
})
```

```bash cURL theme={null}
curl -X POST https://api.hyperbrowser.ai/api/vaults \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "app-env",
    "description": "Production app settings",
    "entries": {
      "DB_URL": {"name": "app-db-url"},
      "API_KEY": {"name": "provider-key", "version": 2}
    }
  }'
```

```bash CLI theme={null}
hx vaults create app-env --description "Production app settings" \
  --entry DB_URL=app-db-url --entry API_KEY=provider-key@2
```

Entry names are environment variable names: letters, digits and `_`, not starting with a digit. Any secret type except `op_token` can be an entry. Entries can be [customer-protected secrets](https://hyperbrowser.ai/docs/sandboxes/customer-keys.md); pass such a vault as `vaults.unwrap()` returns it.

## Use a vault

Vault injection into sandbox processes and startup commands is supported for CPU sandboxes. GPU and macOS sandboxes do not support it. Browser credential fill is described separately in [Credential fill](https://hyperbrowser.ai/docs/sessions/credentials.md).

Pass `vault` when you run a command or create a sandbox. The vault's variables come first, and any `secrets` you also pass are merged over them:

```typescript Node.js theme={null}
const sandbox = await client.sandboxes.create({ imageName: "node" });
const result = await sandbox.exec("node app.js", { vault: "app-env" });
```

```python Python theme={null}
sandbox = client.sandboxes.create({"image_name": "node"})
result = sandbox.exec("node app.js", vault="app-env")
```

```bash cURL theme={null}
curl -X POST https://api.hyperbrowser.ai/api/sandbox/SANDBOX_ID/processes \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "node app.js", "vault": "app-env"}'
```

```bash CLI theme={null}
hx vm exec <sandbox-id> --vault app-env -- node app.js
```

See [Pass a vault](https://hyperbrowser.ai/docs/sandboxes/secrets.md#pass-a-vault) for the merge rules and what the response reports. To fill a login in a browser session, attach the vault with `credentials: [{ vault: "github-login" }]` and fill by entry name; see [Credential fill](https://hyperbrowser.ai/docs/sessions/credentials.md).

## Change a vault

An update replaces only the entries you pass; `null` removes one. Vault methods take a name or ID.

```typescript Node.js theme={null}
await client.vaults.update("app-env", {
  entries: {
    API_KEY: { name: "provider-key" }, // follow the latest version again
    DB_URL: null,                      // remove the variable
  },
});

const { vaults } = await client.vaults.list();
const vault = await client.vaults.get("app-env");
await client.vaults.delete("app-env");
```

```python Python theme={null}
client.vaults.update("app-env", {
    "entries": {
        "API_KEY": {"name": "provider-key"},  # follow the latest version again
        "DB_URL": None,                       # remove the variable
    },
})

vaults = client.vaults.list().vaults
vault = client.vaults.get("app-env")
client.vaults.delete("app-env")
```

```bash cURL theme={null}
curl -X PATCH https://api.hyperbrowser.ai/api/vaults/VAULT_ID \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"entries": {"API_KEY": {"name": "provider-key"}, "DB_URL": null}}'
```

```bash CLI theme={null}
hx vaults update app-env --entry API_KEY=provider-key --remove DB_URL
hx vaults ls
hx vaults get app-env
hx vaults delete app-env
```

The API addresses vaults by ID; find one by name with `GET /api/vaults?search=app-env`. A vault returns its entries with each secret's `name`, `secretId` and pinned `version` (`null` follows the latest). Changing or deleting a vault doesn't affect processes that already started. A browser session attaches the vault itself, so each fill uses the vault's entries as they are at that moment.

## Limits

* 100 vaults per team and 32 entries per vault.
* Names are 1–128 letters, digits, `_` or `-`, starting with a letter or digit, and unique within your team.

## Errors

| Code | Status | Meaning |
| - | - | - |
| `VAULT_NOT_FOUND` | 404 | No vault with that name or ID. |
| `VAULT_NAME_TAKEN` | 409 | A vault with this name exists. |
| `VAULT_LIMIT_REACHED`, `VAULT_ENTRY_LIMIT_REACHED` | 409 | Your team has 100 vaults, or the vault would have more than 32 entries. |
| `SECRET_NOT_FOUND`, `SECRET_VERSION_NOT_FOUND` | 404 | An entry names a missing secret or version. |
| `SECRET_TYPE_MISMATCH` | 409 | An entry names an `op_token` secret. |
| `SECRET_REQUIRES_CUSTOMER_UNWRAP` | 400 | The vault has customer-protected entries and was passed by name. Pass what `vaults.unwrap()` returns. |
| `SECRET_VAULT_CHANGED` | 409 | An entry changed since you unwrapped the vault. Unwrap it again. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.