Skip to main content
Secrets hold values such as API keys that processes in your sandboxes need. A value is encrypted on your machine before it’s uploaded, and the API never returns it. You pass a secret to a process by name, and the value is decrypted on the host running the sandbox and set in that process’s environment. The same secrets can be filled into login forms in browser sessions, and grouped in vaults so you can pass a whole set by one name.
Secrets are in public preview and are enabled for teams on request. Please contact us at info@hyperbrowser.ai or on our support chat to enable them for your team. A restricted API key needs secrets.manage to create and change secrets and vaults, secrets.read to read their metadata, and secrets.use to pass them to sandboxes. Secrets are available in the Node SDK from 1.2.1 and the Python SDK from 1.12.0; secret types, allowed origins and vaults need Node SDK 1.3.0 and Python SDK 1.13.0. In the dashboard, only team owners and admins can manage them.

Create a secret

Values are strings or bytes and are stored byte for byte, trailing newlines included. The CLI reads values from a file or stdin, never from command-line arguments, so they stay out of your shell history. The SDKs and CLI encrypt the value before uploading it; to do this yourself, see Add a secret version.

Secret types

A secret’s type is set when you create it and can’t change. The seed of a totp secret never reaches a process or a page, only its codes. Spaces, hyphens and lowercase letters in a base32 seed are fine. A URI may set algorithm (SHA1, SHA256 or SHA512), digits (6 or 8) and period (1–300 seconds); the defaults are SHA1, 6 digits and 30 seconds. An op_token is only used to read a 1Password vault’s values, and can’t be an environment variable, a vault entry or a browser credential. Allowed origins only limit where a secret is typed in a browser. They don’t limit sandboxes: any process that names a secret, or a vault holding it, receives its value, or for a totp secret its current code. Keep a secret meant only for browser fills out of vaults you use with sandboxes.

Pass secrets to a command

Pass secrets by name, keyed by the environment variable to set. A plain name uses the latest version.
For long-running processes, pass secrets to sandbox.processes.start. The process handle reports which version each variable received:
To pin a version, pass { name, version } instead of a name, or --secret-version API_KEY=2 in the CLI.

Pass a vault

A vault names a set of variables, so you can pass them all at once. Pass vault with or without secrets:
The vault’s variables come first and secrets is merged over them, so secrets wins when both set a variable. Together they can set at most 32 variables. A variable from either can’t also be set with env. The response lists every variable with its source ({"type": "vault", "name": "app-env"} or {"type": "secrets"}) and, when it replaced one, overrides:
A totp variable also has "secretType": "totp". A variable from a 1Password vault has reference (its op:// path) and tokenSecret instead of name, secretId and version.

Pass secrets to an image’s startup command

When you create a sandbox from an image with a startup command, you can pass secrets, a vault, or both to that command:
The response’s startupSecrets lists what the command received, in the same form as above. Startup secrets work for image launches on Firecracker sandboxes only. Otherwise the create fails with SECRET_STARTUP_UNSUPPORTED: create the sandbox without secrets, and pass them to exec or processes.start.

Rotate and delete

Storing a new value adds a version, and commands use the latest version unless you pin one. Each method takes a secret’s name or ID.
The latest version can’t be deleted on its own; add a newer one or delete the whole secret. A secret a vault uses can’t be deleted, nor a version a vault pins; change the vault first. Deleting doesn’t revoke a value a process, sandbox or snapshot already received. If a value may have leaked, rotate it where it was issued.

How secrets are protected

  • Encrypted before upload. Values are encrypted on your machine and decrypted only by the host running the sandbox that uses them. No endpoint returns a value.
  • One process at a time. A secret is set only in the environment of the process you pass it to; other processes don’t inherit it.
  • Tracked through snapshots. A sandbox that received a secret, and every snapshot taken of it, is marked as containing secrets. Restoring such a snapshot needs the same access as passing secrets.
A process can read its own environment, and so can anything else in the sandbox running as the same user, or as root.

Limits

  • 100 secrets per team, 10 versions per secret, and 32 variables per process or sandbox.
  • Values are 1 byte to 32 KiB of UTF-8 without NUL bytes.
  • Names are 1–128 letters, digits, _ or -, starting with a letter or digit.

Errors

1Password vaults have their own errors.