# Secrets

Never store sensitive values like API keys, passwords, or tokens as plaintext in workflow files or configuration. Namespace Secrets provide a secure way to store and manage sensitive information across your workloads.

## Encryption at Rest

All secrets stored in Namespace are encrypted at rest using industry-standard encryption algorithms. Your sensitive data is never stored in plaintext on our systems.

## Comprehensive Audit Logging

Every secret access — whether revealed, created, updated, or deleted — emits a detailed, immutable [audit log](/content/docs/security/auditlog.md). This provides complete visibility into how and when your secrets are being used, supporting compliance and security monitoring requirements.

## Managing Secrets

You can manage secrets using the [CLI](/content/docs/reference/cli/vault-add.md), the [VaultService API](https://buf.build/namespace/cloud/docs/main:namespace.cloud.vault.v1beta), or the [Namespace Dashboard](https://cloud.namespace.so/workspace/vars).

Secrets are **versioned** — each update creates a new version. You can use optimistic concurrency control to prevent concurrent modifications by passing the current version when updating or deleting a secret.

Secrets can optionally be marked as **revealable** at creation time. Only revealable secrets can have their value retrieved later via the API or CLI. This setting is immutable after creation.

**Labels** can be attached to secrets at creation time for organization and filtering. Labels are immutable and shared across all versions of a secret.

### List Secrets

View all your secrets and configuration values in your vault.

**Namespace CLI**

List your secrets with the CLI:

```bash theme={null}
nsc vault list
```

See the [CLI docs](/content/docs/reference/cli/vault-list.md) for more.

**Dashboard**

Open your workspace [Vault](https://cloud.namespace.so/workspace/vars) to see your secrets.

### Create Secret

Add new secrets to your vault.

**Namespace CLI**

Create a secret with the CLI, and provide the secret value when prompted:

```bash theme={null}
nsc vault add --description "key description"
```

See the [CLI docs](/content/docs/reference/cli/vault-add.md) for more.

**Dashboard**

Open [Vault](https://cloud.namespace.so/workspace/vars) and press "New Secret" to create a secret.

[Guide: how to create a secret](https://app.guideflow.com/embed/1pz32xxbvk)

#### Create from File

For non-interactive creation, you can store the secret value in a file:

```text secret.txt theme={null}
here-goes-my-key
```

Then provide it with the `--from_file` flag:

```bash theme={null}
nsc vault add --from_file secret.txt --description "secret from file"
```

### Update Secret

**Namespace CLI**

Update a secret with `--object_id`; you'll be prompted for the new value:

```bash theme={null}
nsc vault set --object_id sec_abcde12345
```

For non-interactive update, provide the value with a file:

```bash theme={null}
nsc vault set --object_id sec_abcde12345 --from_file key.txt
```

See the [CLI docs](/content/docs/reference/cli/vault-set.md) for more.

**Dashboard**

Find the secret in your [Vault](https://cloud.namespace.so/workspace/vars), expand the menu next to it and choose Edit.

[Guide: how to update a secret](https://app.guideflow.com/embed/np1e27dbek)

### Delete Secret

**Namespace CLI**

Delete a secret with `--object_id`:

```bash theme={null}
nsc vault delete --object_id sec_abcde12345
```

See the [CLI docs](/content/docs/reference/cli/vault-delete.md) for more.

**Dashboard**

Find the secret in your [Vault](https://cloud.namespace.so/workspace/vars), expand the menu next to it and choose Delete.

[Guide: how to delete a secret](https://app.guideflow.com/embed/yr44qxytlr)

## Using Secrets

Secrets can be provided as environment variables. They are resolved at creation time and injected into the container's environment.

No secrets are injected by default — they must be explicitly requested.

### In Instances

Use the `env_vars` field in `ContainerRequest` with `from_secret_id` set to the secret's object ID:

```json theme={null}
{
  "env_vars": [
    { "name": "DATABASE_URL", "from_secret_id": "secret-object-id" }
  ]
}
```

### In Devboxes

Reference secrets from a [Blueprint](/content/docs/devbox/blueprint.md). Open a Blueprint from the [Blueprints page](https://cloud.namespace.so/workspace/devboxes/blueprints), and under **Environment**, press **+ Add secret**. Enter the environment variable name, pick the secret from your vault, and save the Blueprint.

Then create a Devbox from the Blueprint:

**CLI**

```bash theme={null}
devbox create --blueprint my-blueprint
```

**TS SDK**

```typescript theme={null}
const devbox = await client.devboxes.create({
  name: "my-devbox",
  blueprint: "my-blueprint",
});
```

**Dashboard**

On the [Blueprints page](https://cloud.namespace.so/workspace/devboxes/blueprints), open the `...` menu next to the Blueprint, select **Create Devbox**, give it a name, and press **Create Devbox**.

After the Devbox is created, the secret value is available through the configured environment variable name.
