OpenClaw supports additive SecretRefs so supported credentials do not need to be stored as plaintext in configuration.Documentation Index
Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
Plaintext still works. SecretRefs are opt-in per credential.
Goals and runtime model
Secrets are resolved into an in-memory runtime snapshot.- Resolution is eager during activation, not lazy on request paths.
- Startup fails fast when an effectively active SecretRef cannot be resolved.
- Reload uses atomic swap: full success, or keep the last-known-good snapshot.
- SecretRef policy violations (for example OAuth-mode auth profiles combined with SecretRef input) fail activation before runtime swap.
- Runtime requests read from the active in-memory snapshot only.
- After the first successful config activation/load, runtime code paths keep reading that active in-memory snapshot until a successful reload swaps it.
- Outbound delivery paths also read from that active snapshot (for example Discord reply/thread delivery and Telegram action sends); they do not re-resolve SecretRefs on each send.
Agent-access boundary
SecretRefs protect credentials from being persisted in supported config and generated model surfaces, but they are not a process-isolation boundary. If a plaintext credential remains on disk in a path the agent can read, the agent can bypass API-level redaction by using file or shell tools to inspect that file. For production deployments where agent-accessible files are in scope, treat SecretRef migration as complete only when all of these are true:- supported credentials use SecretRefs instead of plaintext values
- legacy plaintext residue has been scrubbed from
openclaw.json,auth-profiles.json,.env, and generatedmodels.jsonfiles openclaw secrets audit --checkis clean after the migration- any remaining unsupported or rotating credentials are protected by operating system isolation, container isolation, or an external credential proxy
Active-surface filtering
SecretRefs are validated only on effectively active surfaces.- Enabled surfaces: unresolved refs block startup/reload.
- Inactive surfaces: unresolved refs do not block startup/reload.
- Inactive refs emit non-fatal diagnostics with code
SECRETS_REF_IGNORED_INACTIVE_SURFACE.
Examples of inactive surfaces
Examples of inactive surfaces
- Disabled channel/account entries.
- Top-level channel credentials that no enabled account inherits.
- Disabled tool/feature surfaces.
- Web search provider-specific keys that are not selected by
tools.web.search.provider. In auto mode (provider unset), keys are consulted by precedence for provider auto-detection until one resolves. After selection, non-selected provider keys are treated as inactive until selected. - Sandbox SSH auth material (
agents.defaults.sandbox.ssh.identityData,certificateData,knownHostsData, plus per-agent overrides) is active only when the effective sandbox backend issshfor the default agent or an enabled agent. gateway.remote.token/gateway.remote.passwordSecretRefs are active if one of these is true:gateway.mode=remotegateway.remote.urlis configuredgateway.tailscale.modeisserveorfunnel- In local mode without those remote surfaces:
gateway.remote.tokenis active when token auth can win and no env/auth token is configured.gateway.remote.passwordis active only when password auth can win and no env/auth password is configured.
gateway.auth.tokenSecretRef is inactive for startup auth resolution whenOPENCLAW_GATEWAY_TOKENis set, because env token input wins for that runtime.
Gateway auth surface diagnostics
When a SecretRef is configured ongateway.auth.token, gateway.auth.password, gateway.remote.token, or gateway.remote.password, gateway startup/reload logs the surface state explicitly:
active: the SecretRef is part of the effective auth surface and must resolve.inactive: the SecretRef is ignored for this runtime because another auth surface wins, or because remote auth is disabled/not active.
SECRETS_GATEWAY_AUTH_SURFACE and include the reason used by the active-surface policy, so you can see why a credential was treated as active or inactive.
Onboarding reference preflight
When onboarding runs in interactive mode and you choose SecretRef storage, OpenClaw runs preflight validation before saving:- Env refs: validates env var name and confirms a non-empty value is visible during setup.
- Provider refs (
fileorexec): validates provider selection, resolvesid, and checks resolved value type. - Quickstart reuse path: when
gateway.auth.tokenis already a SecretRef, onboarding resolves it before probe/dashboard bootstrap (forenv,file, andexecrefs) using the same fail-fast gate.
SecretRef contract
Use one object shape everywhere:- env
- file
- exec
providermust match^[a-z][a-z0-9_-]{0,63}$idmust match^[A-Z][A-Z0-9_]{0,127}$
Provider config
Define providers undersecrets.providers:
Env provider
Env provider
- Optional allowlist via
allowlist. - Missing/empty env values fail resolution.
File provider
File provider
- Reads local file from
path. mode: "json"expects JSON object payload and resolvesidas pointer.mode: "singleValue"expects ref id"value"and returns file contents.- Path must pass ownership/permission checks.
- Windows fail-closed note: if ACL verification is unavailable for a path, resolution fails. For trusted paths only, set
allowInsecurePath: trueon that provider to bypass path security checks.
Exec provider
Exec provider
- Runs configured absolute binary path, no shell.
- By default,
commandmust point to a regular file (not a symlink). - Set
allowSymlinkCommand: trueto allow symlink command paths (for example Homebrew shims). OpenClaw validates the resolved target path. - Pair
allowSymlinkCommandwithtrustedDirsfor package-manager paths (for example["/opt/homebrew"]). - Supports timeout, no-output timeout, output byte limits, env allowlist, and trusted dirs.
- Windows fail-closed note: if ACL verification is unavailable for the command path, resolution fails. For trusted paths only, set
allowInsecurePath: trueon that provider to bypass path security checks.
File-backed API keys
Do not putfile:... strings in the config env block. The env block is
literal and non-overriding, so file:... is not resolved.
Use a file SecretRef on a supported credential field instead:
mode: "singleValue", the SecretRef id is "value". For
mode: "json", use an absolute JSON pointer such as
"/providers/xai/apiKey".
See SecretRef credential surface for
the config fields that accept SecretRefs.
Exec integration examples
1Password CLI
1Password CLI
Bitwarden Secrets Manager (`bws`)
Bitwarden Secrets Manager (`bws`)
Use a resolver wrapper when you want SecretRef ids to map to Bitwarden
Secrets Manager item keys. The repository includes
The resolver batches requested ids, runs
scripts/secrets/openclaw-bws-resolver.mjs; install or copy it to an absolute
trusted path on the host that runs the Gateway.Requirements:- Bitwarden Secrets Manager CLI (
bws) installed on the Gateway host. BWS_ACCESS_TOKENavailable to the Gateway service.PATHpassed to the resolver, orBWS_BINset to the absolutebwsbinary path.
bws secret list, and returns
values for matching secret key fields. Use keys that satisfy the exec
SecretRef id contract, such as openclaw/providers/openai/apiKey; env-var
style keys with underscores are rejected before the resolver runs. If more
than one visible Bitwarden secret has the same requested key, the resolver
fails that id as ambiguous instead of choosing one. After updating config,
verify the resolver path:HashiCorp Vault CLI
HashiCorp Vault CLI
password-store (`pass`)
password-store (`pass`)
Use a small resolver wrapper when you want SecretRef ids to map directly to
Then configure the exec provider and point Keep the secret on the first line of the
pass entries. Save this as an executable in an absolute path that passes
your exec-provider path checks, for example
/usr/local/bin/openclaw-pass-resolver. The #!/usr/bin/env node shebang
resolves node from the resolver process PATH, so include PATH in
passEnv. If pass is not on that PATH, set PASS_BIN in the parent
environment and include it in passEnv too:apiKey at the pass entry path:pass entry, or customize the
wrapper if you want to return the full pass show output instead. After
updating config, verify both the static audit and the exec resolver path:sops
sops
MCP server environment variables
MCP server env vars configured viaplugins.entries.acpx.config.mcpServers support SecretInput. This keeps API keys and tokens out of plaintext config:
${MCP_SERVER_API_KEY} and SecretRef objects are resolved during gateway activation before the MCP server process is spawned. As with other SecretRef surfaces, unresolved refs only block activation when the acpx plugin is effectively active.
Sandbox SSH auth material
The coressh sandbox backend also supports SecretRefs for SSH auth material:
- OpenClaw resolves these refs during sandbox activation, not lazily during each SSH call.
- Resolved values are written to temp files with restrictive permissions and used in generated SSH config.
- If the effective sandbox backend is not
ssh, these refs stay inactive and do not block startup.
Supported credential surface
Canonical supported and unsupported credentials are listed in:Runtime-minted or rotating credentials and OAuth refresh material are intentionally excluded from read-only SecretRef resolution.
Required behavior and precedence
- Field without a ref: unchanged.
- Field with a ref: required on active surfaces during activation.
- If both plaintext and ref are present, ref takes precedence on supported precedence paths.
- The redaction sentinel
__OPENCLAW_REDACTED__is reserved for internal config redaction/restore and is rejected as literal submitted config data.
SECRETS_REF_OVERRIDES_PLAINTEXT(runtime warning)REF_SHADOWED(audit finding whenauth-profiles.jsoncredentials take precedence overopenclaw.jsonrefs)
serviceAccountReftakes precedence over plaintextserviceAccount.- Plaintext value is ignored when sibling ref is set.
Activation triggers
Secret activation runs on:- Startup (preflight plus final activation)
- Config reload hot-apply path
- Config reload restart-check path
- Manual reload via
secrets.reload - Gateway config write RPC preflight (
config.set/config.apply/config.patch) for active-surface SecretRef resolvability within the submitted config payload before persisting edits
- Success swaps the snapshot atomically.
- Startup failure aborts gateway startup.
- Runtime reload failure keeps the last-known-good snapshot.
- Write-RPC preflight failure rejects the submitted config and keeps both disk config and active runtime snapshot unchanged.
- Providing an explicit per-call channel token to an outbound helper/tool call does not trigger SecretRef activation; activation points remain startup, reload, and explicit
secrets.reload.
Degraded and recovered signals
When reload-time activation fails after a healthy state, OpenClaw enters degraded secrets state. One-shot system event and log codes:SECRETS_RELOADER_DEGRADEDSECRETS_RELOADER_RECOVERED
- Degraded: runtime keeps last-known-good snapshot.
- Recovered: emitted once after the next successful activation.
- Repeated failures while already degraded log warnings but do not spam events.
- Startup fail-fast does not emit degraded events because runtime never became active.
Command-path resolution
Command paths can opt into supported SecretRef resolution via gateway snapshot RPC. There are two broad behaviors:- Strict command paths
- Read-only command paths
For example
openclaw memory remote-memory paths and openclaw qr --remote when it needs remote shared-secret refs. They read from the active snapshot and fail fast when a required SecretRef is unavailable.- Snapshot refresh after backend secret rotation is handled by
openclaw secrets reload. - Gateway RPC method used by these command paths:
secrets.resolve.
Audit and configure workflow
Default operator flow: Do not treat the migration as complete until the re-audit is clean. If the audit still reports plaintext values at rest, the agent-access risk is still present even when runtime APIs return redacted values. If you save a plan instead of applying duringconfigure, apply that saved plan
with openclaw secrets apply --from <plan-path> before the re-audit.
secrets audit
secrets audit
Findings include:
- plaintext values at rest (
openclaw.json,auth-profiles.json,.env, and generatedagents/*/agent/models.json) - plaintext sensitive provider header residues in generated
models.jsonentries - unresolved refs
- precedence shadowing (
auth-profiles.jsontaking priority overopenclaw.jsonrefs) - legacy residues (
auth.json, OAuth reminders)
- By default, audit skips exec SecretRef resolvability checks to avoid command side effects.
- Use
openclaw secrets audit --allow-execto execute exec providers during audit.
- Sensitive provider header detection is name-heuristic based (common auth/credential header names and fragments such as
authorization,x-api-key,token,secret,password, andcredential).
secrets configure
secrets configure
Interactive helper that:
- configures
secrets.providersfirst (env/file/exec, add/edit/remove) - lets you select supported secret-bearing fields in
openclaw.jsonplusauth-profiles.jsonfor one agent scope - can create a new
auth-profiles.jsonmapping directly in the target picker - captures SecretRef details (
source,provider,id) - runs preflight resolution
- can apply immediately
- Preflight skips exec SecretRef checks unless
--allow-execis set. - If you apply directly from
configure --applyand the plan includes exec refs/providers, keep--allow-execset for the apply step too.
openclaw secrets configure --providers-onlyopenclaw secrets configure --skip-provider-setupopenclaw secrets configure --agent <id>
configure apply defaults:- scrub matching static credentials from
auth-profiles.jsonfor targeted providers - scrub legacy static
api_keyentries fromauth.json - scrub matching known secret lines from
<config-dir>/.env
secrets apply
secrets apply
Apply a saved plan:Exec note:
- dry-run skips exec checks unless
--allow-execis set. - write mode rejects plans containing exec SecretRefs/providers unless
--allow-execis set.
One-way safety policy
Safety model:- preflight must succeed before write mode
- runtime activation is validated before commit
- apply updates files using atomic file replacement and best-effort restore on failure
Legacy auth compatibility notes
For static credentials, runtime no longer depends on plaintext legacy auth storage.- Runtime credential source is the resolved in-memory snapshot.
- Legacy static
api_keyentries are scrubbed when discovered. - OAuth-related compatibility behavior remains separate.
Web UI note
Some SecretInput unions are easier to configure in raw editor mode than in form mode.Related
- Authentication — auth setup
- CLI: secrets — CLI commands
- Environment Variables — environment precedence
- SecretRef Credential Surface — credential surface
- Secrets Apply Plan Contract — plan contract details
- Security — security posture