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

# Use Vault secrets from a Computer or Sandbox

> Store a secret, authorize one Machine, use HTTPS Authorization substitution, and handle rotation or revocation without exposing the stored value.

Vault holds Account secrets and lets you explicitly authorize a Computer or Sandbox to use them. Secret reads return metadata, never the stored plaintext. The Guest receives a placeholder, and supported outbound HTTPS requests substitute the real value only in the Authorization header to an allowed hostname.

Use Vault for credentials whose target API accepts this pattern. It is not a general-purpose `.env` synchronization service, arbitrary file-secret store inside the Guest, SSH-key manager, or substitute for a third party's authentication setup.

## The three decisions

| Decision | Scope | Example |
| - | - | - |
| Which secret | Account Vault | A token for an external API |
| Which target Machine may use it | Explicit Machine grant | One Computer or one short-lived Sandbox |
| Which destination may receive it | Secret's exact hostname policy | `api.example.com` |

A new Computer or Sandbox does not automatically get every Account secret. A grant cannot widen the secret's hostname policy.

Before creating the secret, choose the intended Machine, confirm its need, and identify the provider's actual API hostname. Do not confuse the provider's website or sign-in host with its API host.

## Create a secret

In the Console, open **Secrets → New secret**. Fill in **Name**, **Environment variable name**, **Allowed API domains** and **Secret value**, then choose **Save secret**. For an explicit Machine grant, open its **Settings** and use **Available secrets → Add secret**; on a Computer, this section is under **Configuration**.

Allowed hosts are exact DNS hostnames: one to twelve entries. Do not include `https://`, paths, ports, IP addresses, or wildcard patterns. For example, `api.example.com` does not authorize `uploads.example.com`.

With the [SDK](https://docs.deepest.dev/api-and-sdk/typescript.md), obtain the **new** secret value from your trusted caller's secret store or environment. Do not include the value in source code, a command argument, or logs:

```js theme={null}
import { Deepest } from "@deepest/sdk";

const { DEEPEST_API_URL, DEEPEST_API_KEY, NEW_API_TOKEN, ALLOWED_API_HOST } = process.env;
if (!DEEPEST_API_URL || !DEEPEST_API_KEY || !NEW_API_TOKEN || !ALLOWED_API_HOST) {
  throw new Error("Provide the control API credentials, new value, and exact API hostname.");
}
const deepest = new Deepest({ baseUrl: DEEPEST_API_URL, apiKey: DEEPEST_API_KEY });
const reply = await deepest.vault.create({
  name: "example-api",
  env_name: "EXAMPLE_API_TOKEN",
  allowed_hosts: [ALLOWED_API_HOST],
  value: NEW_API_TOKEN,
});
if (!reply.ok) {
  console.error(reply.error.code, reply.retry, reply.resource_id);
  process.exit(1);
}
const secretId = reply.result.id;
console.log({ secret_id: secretId, env_name: reply.result.env_name });
```

The success response contains metadata including `id`, `name`, `env_name`, `allowed_hosts` and timestamps. It does not echo `value`. Store the returned ID; future operations use it.

If creation returns `UNKNOWN`, list metadata and reconcile the intended name and environment variable before another create. Do not keep creating secrets because a response was lost.

To inspect without revealing plaintext:

```js theme={null}
const list = await deepest.vault.list();
if (!list.ok) throw new Error(list.error.code + " / " + list.retry);
console.log(list.result.map(({ id, name, env_name, allowed_hosts }) => ({
  id, name, env_name, allowed_hosts,
})));

const metadata = await deepest.vault.get(secretId);
if (!metadata.ok) throw new Error(metadata.error.code);
```

## Grant one Machine

For a Computer:

```js theme={null}
const computerId = process.env.COMPUTER_ID;
if (!computerId) throw new Error("Set COMPUTER_ID.");
const target = deepest.computer(computerId);
const granted = await target.secretGrants.grant(secretId);
if (!granted.ok) {
  console.error(granted.error.code, granted.retry, granted.resource_id);
  process.exit(1);
}
console.log(granted.result.disposition);
```

For a Sandbox, use `deepest.sandbox(sandboxId).secretGrants.grant(secretId)`. The same list and revoke methods exist on each target. Each Machine may have up to 16 Vault grants.

Read the returned disposition before using the secret:

| Disposition | Meaning | What you do |
| - | - | - |
| `live` | Applied to the current running instance for supported subsequent use | Verify a fresh connection to the allowed API |
| `next_start` | Target is stopped; it will use the grant on its next explicit Start | Start only when the task requires it |
| `restart_required` | Current instance has not fully applied the requested grant/policy | Save work and arrange an explicit Stop/Start when appropriate |

First authorization on a Running Machine can require restart. Vault never silently restarts your Computer. A successful grant record is not proof that the current process can already use the new environment variable.

After the planned Start, query:

```js theme={null}
const grants = await target.secretGrants.list();
if (!grants.ok) throw new Error(grants.error.code + " / " + grants.retry);
console.log(grants.result.map(({ secret, disposition }) => ({
  secret_id: secret.id,
  env_name: secret.env_name,
  disposition,
})));
```

Confirm the intended secret and current disposition. Avoid dumping all Guest environment variables.

## Use the placeholder inside the Guest

When the grant is active, programs in the Machine use the configured Guest environment variable. The variable contains a placeholder, not the stored value. The platform substitutes that placeholder in a supported outbound HTTPS `Authorization` header for an exact allowed host.

In the Computer or Sandbox, replace the endpoint below with a **non-echo, authorized** provider endpoint on the allowed hostname:

```bash theme={null}
test -n "$EXAMPLE_API_TOKEN" || { printf 'Secret placeholder is not available\n' >&2; exit 1; }

curl --proto '=https' --silent --show-error --fail \
  --header "Authorization: Bearer $EXAMPLE_API_TOKEN" \
  --output api-response.json \
  --write-out '%{http_code}\n' \
  'https://<ALLOWED_API_HOST>/<READ_ONLY_API_PATH>'
```

Choose an endpoint that accepts Bearer authentication; some providers require a different Authorization scheme. The placeholder must appear in the supported header. Do not put it in a URL, request body, custom header, SSH command, or arbitrary file and assume substitution will occur.

Verify the expected provider status and response structure without printing the credential. The example does not bypass provider permissions, subscription requirements, rate limits or billing. It also does not follow redirects: if a provider requires a different hostname, review that actual destination instead of broadening the policy blindly.

For a library, configure its authentication header from `process.env.EXAMPLE_API_TOKEN` or the corresponding Guest environment-variable mechanism. Confirm that the library actually uses the HTTPS Authorization header. A library that requires a different credential transport may not be compatible with Vault's Authorization-header substitution model.

## Rotate a value

Obtain the replacement value from your trusted caller:

```js theme={null}
const newValue = process.env.ROTATED_API_TOKEN;
if (!newValue) throw new Error("Provide ROTATED_API_TOKEN from the trusted caller.");
const rotated = await deepest.vault.rotate(secretId, { value: newValue });
if (!rotated.ok) {
  console.error(rotated.error.code, rotated.retry, rotated.resource_id);
  process.exit(1);
}
console.log(rotated.result.machines);
```

Review the per-Machine effects. Same-policy rotation can apply live to subsequent connections. Existing connections may retain earlier configuration; test with a new connection.

Changing `allowed_hosts` requires a new plaintext value in the same rotation request. This prevents a caller who does not know an existing value from redirecting it merely by changing its destination policy. A host-policy change removes the old live substitution; the new policy applies on the next explicit Start. Honor each Machine's returned disposition and arrange any Stop/Start disruption explicitly.

Rotating the value in Deepest does not revoke the old token at its issuing provider. Complete the provider's own rotation/revocation procedure when needed.

## Revoke a grant or delete a secret

To withdraw one Machine's access while keeping the Account secret:

```js theme={null}
const revoked = await target.secretGrants.revoke(secretId);
if (!revoked.ok) {
  console.error(revoked.error.code, revoked.retry, revoked.resource_id);
  process.exit(1);
}
console.log(revoked.result.disposition);
```

Query the target's grants and verify that a **new** application connection can no longer use the substitution. Existing connections are not guaranteed to lose credentials instantaneously.

To remove the secret from the Account entirely, use `deepest.vault.delete(secretId)` after confirming it is no longer needed. Deletion removes its grants too. It does not delete an external provider account or revoke the provider-issued token. For uncertain results, query metadata and each affected target before more changes.

## Clone, snapshot, restore, and expiry

| Event | Vault consequence |
| - | - |
| New Computer/Sandbox | No automatic grants |
| Clone Computer | Does not copy source Vault grants |
| Disk snapshot | Does not become a backup of Account Vault values or grants |
| Restore same Computer | Uses its current grants; disk rollback does not roll back control-plane authorization |
| Stop/Start | Current authorized values/policies are used on the explicit next start |
| Delete Machine | Removes that Machine's grants |
| Delete secret | Removes all its grants |
| Sandbox expires | It cannot keep computing to use a grant beyond its hard lifetime |

A disk can still contain credentials you manually wrote yourself, including third-party login files. Vault does not retroactively scrub those files or prevent them from being copied by Clone/Snapshot. Keep Account Agent Keys outside untrusted Guest environments.

## What Vault protects—and its limits

Stored secret values are encrypted at rest. List/get responses expose metadata only. The supported request path reduces plaintext copies in Guest environments, source files, prompts, and platform logs.

It does not provide an absolute “a program can never obtain this secret” guarantee. An allowed endpoint could echo credentials or return other sensitive data; an authorized application can misuse its granted provider permissions. Grant minimal provider scope and exact destinations, and do not select an echo endpoint for verification.

An Account-level Agent Key is a strong control credential. Vault does not turn such a key into a Machine-scoped identity or isolate it from all Account-management actions.

## Troubleshoot by evidence

| Failure | Check / recovery |
| - | - |
| `INVALID_REQUEST` during create/rotate | Exact hostnames, required value, valid environment-variable name; avoid wildcard/URL/IP inputs |
| `LIMIT_EXCEEDED` with `secret_grants` / `machine` | Review and remove grants the target no longer needs |
| Placeholder absent | Correct target and env name; inspect disposition; a first grant may require explicit restart |
| Request blocked to another host | Compare the actual destination with exact `allowed_hosts`; do not widen the policy without a reason |
| Provider 401/403 | Token validity, scheme, provider permissions and whether the grant is live |
| `VAULT_UNAVAILABLE` | Custody is unavailable; retain the existing Machine and seek service recovery instead of copying secrets into logs |
| `UNKNOWN / query-first` | Read secret metadata and target grants/dispositions; unknown live effect may need support investigation |

For an Agent: find metadata, select only the target needed for the task, grant explicitly, honor disposition, verify a fresh provider request, and revoke temporary access when it is no longer necessary. Never treat a missing success response as permission to repeat a rotation or restart a working Computer.

Precise field schemas and errors remain in the Vault and Machine Secret Grants sections of the [API reference](https://docs.deepest.dev/api-reference.md). Related tasks: [Sandbox lifecycle](https://docs.deepest.dev/sandboxes/lifecycle.md), [Clone](https://docs.deepest.dev/computers/clone.md), and [Snapshots and restore](https://docs.deepest.dev/computers/snapshots-and-restore.md).


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