2026-02-24 16:26:59 -06:00
---
2026-02-25 20:29:39 -06:00
summary: "CLI reference for `openclaw secrets` (reload, audit, configure, apply)"
2026-02-24 16:26:59 -06:00
read_when:
- Re-resolving secret refs at runtime
2026-02-25 20:29:39 -06:00
- Auditing plaintext residues and unresolved refs
- Configuring SecretRefs and applying one-way scrub changes
2026-02-24 16:26:59 -06:00
title: "secrets"
---
# `openclaw secrets`
2026-03-02 20:58:20 -06:00
Use `openclaw secrets` to manage SecretRefs and keep the active runtime snapshot healthy.
2026-02-27 00:19:56 +01:00
Command roles:
- `reload` : gateway RPC (`secrets.reload` ) that re-resolves refs and swaps runtime snapshot only on full success (no config writes).
2026-03-02 20:58:20 -06:00
- `audit` : read-only scan of configuration/auth stores and legacy residues for plaintext, unresolved refs, and precedence drift.
- `configure` : interactive planner for provider setup, target mapping, and preflight (TTY required).
- `apply` : execute a saved plan (`--dry-run` for validation only), then scrub targeted plaintext residues.
2026-02-27 00:19:56 +01:00
Recommended operator loop:
```bash
openclaw secrets audit --check
openclaw secrets configure
openclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-run
openclaw secrets apply --from /tmp/openclaw-secrets-plan.json
openclaw secrets audit --check
openclaw secrets reload
```
Exit code note for CI/gates:
2026-03-02 20:58:20 -06:00
- `audit --check` returns `1` on findings.
- unresolved refs return `2` .
2026-02-24 16:26:59 -06:00
Related:
- Secrets guide: [Secrets Management ](/gateway/secrets )
2026-03-02 20:58:20 -06:00
- Credential surface: [SecretRef Credential Surface ](/reference/secretref-credential-surface )
2026-02-24 16:26:59 -06:00
- Security guide: [Security ](/gateway/security )
## Reload runtime snapshot
Re-resolve secret refs and atomically swap runtime snapshot.
```bash
openclaw secrets reload
openclaw secrets reload --json
```
Notes:
- Uses gateway RPC method `secrets.reload` .
2026-02-27 00:19:56 +01:00
- If resolution fails, gateway keeps last-known-good snapshot and returns an error (no partial activation).
2026-02-24 16:26:59 -06:00
- JSON response includes `warningCount` .
2026-02-25 20:29:39 -06:00
## Audit
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
Scan OpenClaw state for:
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
- plaintext secret storage
- unresolved refs
2026-03-02 20:58:20 -06:00
- precedence drift (`auth-profiles.json` credentials shadowing `openclaw.json` refs)
- legacy residues (legacy auth store entries, OAuth reminders)
2026-02-24 16:26:59 -06:00
```bash
2026-02-25 20:29:39 -06:00
openclaw secrets audit
openclaw secrets audit --check
openclaw secrets audit --json
2026-02-24 16:26:59 -06:00
```
2026-02-25 20:29:39 -06:00
Exit behavior:
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
- `--check` exits non-zero on findings.
2026-03-02 20:58:20 -06:00
- unresolved refs exit with higher-priority non-zero code.
2026-02-24 19:34:29 -06:00
2026-02-27 00:19:56 +01:00
Report shape highlights:
- `status` : `clean | findings | unresolved`
- `summary` : `plaintextCount` , `unresolvedRefCount` , `shadowedRefCount` , `legacyResidueCount`
- finding codes:
- `PLAINTEXT_FOUND`
- `REF_UNRESOLVED`
- `REF_SHADOWED`
- `LEGACY_RESIDUE`
2026-02-25 20:29:39 -06:00
## Configure (interactive helper)
2026-02-24 19:34:29 -06:00
2026-03-02 20:58:20 -06:00
Build provider and SecretRef changes interactively, run preflight, and optionally apply:
2026-02-24 16:26:59 -06:00
```bash
2026-02-25 20:29:39 -06:00
openclaw secrets configure
openclaw secrets configure --plan-out /tmp/openclaw-secrets-plan.json
openclaw secrets configure --apply --yes
2026-02-25 23:17:31 -06:00
openclaw secrets configure --providers-only
openclaw secrets configure --skip-provider-setup
2026-03-02 20:58:20 -06:00
openclaw secrets configure --agent ops
2026-02-25 20:29:39 -06:00
openclaw secrets configure --json
2026-02-24 16:26:59 -06:00
```
2026-02-25 23:17:31 -06:00
Flow:
- Provider setup first (`add/edit/remove` for `secrets.providers` aliases).
- Credential mapping second (select fields and assign `{source, provider, id}` refs).
- Preflight and optional apply last.
Flags:
- `--providers-only` : configure `secrets.providers` only, skip credential mapping.
- `--skip-provider-setup` : skip provider setup and map credentials to existing providers.
2026-03-02 20:58:20 -06:00
- `--agent <id>` : scope `auth-profiles.json` target discovery and writes to one agent store.
2026-02-25 23:17:31 -06:00
2026-02-25 20:29:39 -06:00
Notes:
2026-02-24 16:26:59 -06:00
2026-02-27 00:19:56 +01:00
- Requires an interactive TTY.
- You cannot combine `--providers-only` with `--skip-provider-setup` .
2026-03-02 20:58:20 -06:00
- `configure` targets secret-bearing fields in `openclaw.json` plus `auth-profiles.json` for the selected agent scope.
- `configure` supports creating new `auth-profiles.json` mappings directly in the picker flow.
- Canonical supported surface: [SecretRef Credential Surface ](/reference/secretref-credential-surface ).
2026-02-25 20:29:39 -06:00
- It performs preflight resolution before apply.
2026-02-27 00:19:56 +01:00
- Generated plans default to scrub options (`scrubEnv` , `scrubAuthProfilesForProviderTargets` , `scrubLegacyAuthJson` all enabled).
2026-03-02 20:58:20 -06:00
- Apply path is one-way for scrubbed plaintext values.
2026-02-27 00:19:56 +01:00
- Without `--apply` , CLI still prompts `Apply this plan now?` after preflight.
2026-03-02 20:58:20 -06:00
- With `--apply` (and no `--yes` ), CLI prompts an extra irreversible confirmation.
2026-02-24 16:26:59 -06:00
2026-02-26 00:54:14 -06:00
Exec provider safety note:
- Homebrew installs often expose symlinked binaries under `/opt/homebrew/bin/*` .
- Set `allowSymlinkCommand: true` only when needed for trusted package-manager paths, and pair it with `trustedDirs` (for example `["/opt/homebrew"]` ).
2026-03-02 20:58:20 -06:00
- On Windows, if ACL verification is unavailable for a provider path, OpenClaw fails closed. For trusted paths only, set `allowInsecurePath: true` on that provider to bypass path security checks.
2026-02-26 00:54:14 -06:00
2026-02-25 20:29:39 -06:00
## Apply a saved plan
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
Apply or preflight a plan generated previously:
2026-02-24 16:26:59 -06:00
```bash
2026-02-25 20:29:39 -06:00
openclaw secrets apply --from /tmp/openclaw-secrets-plan.json
openclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-run
openclaw secrets apply --from /tmp/openclaw-secrets-plan.json --json
2026-02-24 16:26:59 -06:00
```
2026-02-26 14:32:04 +01:00
Plan contract details (allowed target paths, validation rules, and failure semantics):
- [Secrets Apply Plan Contract ](/gateway/secrets-plan-contract )
2026-02-27 00:19:56 +01:00
What `apply` may update:
- `openclaw.json` (SecretRef targets + provider upserts/deletes)
- `auth-profiles.json` (provider-target scrubbing)
- legacy `auth.json` residues
- `~/.openclaw/.env` known secret keys whose values were migrated
2026-02-25 20:29:39 -06:00
## Why no rollback backups
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
`secrets apply` intentionally does not write rollback backups containing old plaintext values.
Safety comes from strict preflight + atomic-ish apply with best-effort in-memory restore on failure.
2026-02-24 16:26:59 -06:00
2026-02-25 20:29:39 -06:00
## Example
2026-02-24 16:26:59 -06:00
```bash
2026-02-25 20:29:39 -06:00
openclaw secrets audit --check
openclaw secrets configure
openclaw secrets audit --check
2026-02-24 16:26:59 -06:00
```
2026-02-26 00:54:14 -06:00
2026-03-02 20:58:20 -06:00
If `audit --check` still reports plaintext findings, update the remaining reported target paths and rerun audit.