This page covers day-to-day secrets operation: the supported credential surface, required behavior and precedence, activation and recovery signals, and the audit, configure, and apply workflow.

Supported credential surface

Canonical supported and unsupported credentials are listed in SecretRef Credential Surface.

Runtime-minted or rotating credentials and OAuth refresh material are intentionally excluded from read-only SecretRef resolution.

Required behavior and precedence

Warning and audit signals:

Google Chat serviceAccount accepts inline JSON or a SecretRef. Doctor moves the retired sibling serviceAccountRef into this canonical field when it is unset.

Activation triggers

Secret activation runs on:

Activation contract:

Degraded and recovered signals

When reload-time activation fails after a healthy state, Apus enters degraded secrets state, emitting one-shot system events and log codes:

Behavior:

Command-path resolution

Command paths can opt into supported SecretRef resolution via a gateway snapshot RPC. Two broad behaviors apply:

Strict command paths

For example `apus memory` remote-memory paths and `apus qr --remote` when it needs remote shared-secret refs. They read from the active snapshot and fail fast when a required SecretRef is unavailable.

Read-only command paths

For example `apus status`, `apus status --all`, `apus channels status`, `apus channels resolve`, `apus security audit`, and read-only doctor/config repair flows. They also prefer the active snapshot, but degrade instead of aborting when a targeted SecretRef is unavailable.

Read-only behavior:

- When the gateway is running, these commands read from the active snapshot first.
- If gateway resolution is incomplete or the gateway is unavailable, they attempt a targeted local fallback for that command surface.
- If a targeted SecretRef is still unavailable, the command continues with degraded read-only output and an explicit diagnostic that the ref is configured but unavailable in this command path.
- This degraded behavior is command-local only; it does not weaken runtime startup, reload, or send/auth paths.

Agent turns using the matching prepared Gateway snapshot do not re-resolve every model and tool credential at turn startup. A configured-unavailable provider therefore does not block a turn using a healthy provider. Selecting the unavailable provider still fails closed before environment or auth-profile fallback, and explicitly targeted channel/account credentials remain strict.

Standalone agent commands without config-ref preparation and calls with a different config retain strict command-scoped resolution. A local non-delivery agent command does not resolve unrelated channel or Gateway credentials.

Other notes:

Audit and configure workflow

Default operator flow:

Audit current state

```bash
apus secrets audit --check
```

Configure and apply SecretRefs

```bash
apus secrets configure --apply
```

Re-audit

```bash
apus secrets audit --check
```

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 remains even when runtime APIs return redacted values.

If you save a plan instead of applying during configure, apply that saved plan with apus secrets apply --from <plan-path> before the re-audit.

secrets audit
Findings include:

- Plaintext values at rest (`apus.json`, SQLite auth-profile rows, `.env`, and generated `agents/*/agent/models.json`).
- Plaintext sensitive provider header residues in generated `models.json` entries.
- Unresolved refs.
- Precedence shadowing (SQLite auth profiles taking priority over `apus.json` refs).
- Store residue (a stored name still has an equivalent plaintext value in config).

Initially missing generated `models.json` files are skipped. When reading an existing file, audit enforces a 5 MiB limit and reports leaf symlinks, non-regular files, and read or parse failures as `REF_UNRESOLVED`. Parse diagnostics identify the file without echoing its contents.

Exec note: by default, audit skips exec SecretRef resolvability checks to avoid command side effects. Use `apus secrets audit --allow-exec` to execute exec providers during audit.

Header residue note: sensitive provider header detection is name-heuristic based (common auth/credential header names and fragments such as `authorization`, `x-api-key`, `token`, `secret`, `password`, and `credential`).
secrets configure
Interactive helper that:

- Configures `secrets.providers` first (`env`/`file`/`exec`/`store`, add/edit/remove).
- Lets you select supported secret-bearing fields in `apus.json` plus the SQLite auth-profile store for one agent scope.
- Can create a new auth-profile mapping directly in the target picker.
- Captures SecretRef details (`source`, `provider`, `id`).
- Runs preflight resolution and can apply immediately.

Exec note: preflight skips exec SecretRef checks unless `--allow-exec` is set. If you apply directly from `configure --apply` and the plan includes exec refs/providers, keep `--allow-exec` set for the apply step too.

Helpful modes:

- `apus secrets configure --providers-only`
- `apus secrets configure --skip-provider-setup`
- `apus secrets configure --agent <id>`

`configure` apply defaults:

- Scrub matching static credentials from SQLite auth-profile rows for targeted providers.
- Leave retired `auth.json` untouched; run `apus doctor --fix` to migrate and archive it.
- Scrub matching known secret lines from the effective state and active-config `.env` files (deduplicated when both paths match).
secrets apply
Apply a saved plan:

```bash
apus secrets apply --from /tmp/apus-secrets-plan.json
apus secrets apply --from /tmp/apus-secrets-plan.json --allow-exec
apus secrets apply --from /tmp/apus-secrets-plan.json --dry-run
apus secrets apply --from /tmp/apus-secrets-plan.json --dry-run --allow-exec
```

Exec note: dry-run skips exec checks unless `--allow-exec` is set; write mode rejects plans containing exec SecretRefs/providers unless `--allow-exec` is set.

For strict target/path contract details and exact rejection rules, see [Secrets Apply Plan Contract](/gateway/secrets-plan-contract).

One-way safety policy

Apus intentionally does not write rollback backups containing historical plaintext secret values.

Safety model:

Legacy auth compatibility notes

For static credentials, runtime no longer depends on plaintext legacy auth storage.

Control UI

Open Settings → Secrets to list, add, edit, bulk-import, or soft-delete team-scoped entries. Choose Protected secret for write-only values used by SecretRefs or destination-bound Gateway egress. Choose Agent-readable environment only when Gateway-hosted agent commands must receive plaintext and the agent may print, transmit, or persist it. Bulk Add accepts dotenv NAME=VALUE assignments, including quoted multiline values. Protect credential-like names automatically defaults credential-shaped names to protected mode.

This store page manages values only. Configure the corresponding store SecretRef on a supported field through its settings form or the raw editor. Identity-scoped entries are reserved for a later release and are not exposed by this page.