{"id":751,"date":"2026-03-21T23:08:58","date_gmt":"2026-03-21T15:08:58","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/configuration\/"},"modified":"2026-03-21T23:30:47","modified_gmt":"2026-03-21T15:30:47","slug":"configuration","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/configuration\/","title":{"rendered":"\u914d\u7f6e\u8bf4\u660e"},"content":{"rendered":"<h1>Configuration<\/h1>\n<p>OpenClaw reads an optional <strong>JSON5<\/strong> config from <code>~\/.openclaw\/openclaw.json<\/code>.<\/p>\n<p>If the file is missing, OpenClaw uses safe defaults. Common reasons to add a config:<\/p>\n<ul>\n<li>Connect channels and control who can message the bot<\/li>\n<li>Set models, tools, sandboxing, or automation (cron, hooks)<\/li>\n<li>Tune sessions, media, networking, or UI<\/li>\n<\/ul>\n<p>See the <a href=\"\/gateway\/configuration-reference\">full reference<\/a> for every available field.<\/p>\n<p>\n  <strong>New to configuration?<\/strong> Start with <code>openclaw onboard<\/code> for interactive setup, or check out the <a href=\"\/gateway\/configuration-examples\">Configuration Examples<\/a> guide for complete copy-paste configs.\n<\/p>\n<h2>Minimal config<\/h2>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n\/\/ ~\/.openclaw\/openclaw.json<br \/>\n{<br \/>\n  agents: { defaults: { workspace: &#8220;~\/.openclaw\/workspace&#8221; } },<br \/>\n  channels: { whatsapp: { allowFrom: [&#8220;+15555550123&#8221;] } },<br \/>\n}<\/p>\n<pre><code>\n## Editing config\n\n&lt;Tabs&gt;\n  &lt;Tab title=&quot;Interactive wizard&quot;&gt;\n    ```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    openclaw onboard       # full onboarding flow\n    openclaw configure     # config wizard\n    ```\n  &lt;\/Tab&gt;\n\n  &lt;Tab title=&quot;CLI (one-liners)&quot;&gt;\n    ```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    openclaw config get agents.defaults.workspace\n    openclaw config set agents.defaults.heartbeat.every &quot;2h&quot;\n    openclaw config unset plugins.entries.brave.config.webSearch.apiKey\n    ```\n  &lt;\/Tab&gt;\n\n  &lt;Tab title=&quot;Control UI&quot;&gt;\n    Open [http:\/\/127.0.0.1:18789](http:\/\/127.0.0.1:18789) and use the **Config** tab.\n    The Control UI renders a form from the config schema, with a **Raw JSON** editor as an escape hatch.\n  &lt;\/Tab&gt;\n\n  &lt;Tab title=&quot;Direct edit&quot;&gt;\n    Edit `~\/.openclaw\/openclaw.json` directly. The Gateway watches the file and applies changes automatically (see [hot reload](#config-hot-reload)).\n  &lt;\/Tab&gt;\n&lt;\/Tabs&gt;\n\n## Strict validation\n\n&lt;Warning&gt;\n  OpenClaw only accepts configurations that fully match the schema. Unknown keys, malformed types, or invalid values cause the Gateway to **refuse to start**. The only root-level exception is `$schema` (string), so editors can attach JSON Schema metadata.\n&lt;\/Warning&gt;\n\nWhen validation fails:\n\n* The Gateway does not boot\n* Only diagnostic commands work (`openclaw doctor`, `openclaw logs`, `openclaw health`, `openclaw status`)\n* Run `openclaw doctor` to see exact issues\n* Run `openclaw doctor --fix` (or `--yes`) to apply repairs\n\n## Common tasks\n\n&lt;AccordionGroup&gt;\n  &lt;Accordion title=&quot;Set up a channel (WhatsApp, Telegram, Discord, etc.)&quot;&gt;\n    Each channel has its own config section under `channels.&lt;provider&gt;`. See the dedicated channel page for setup steps:\n\n    * [WhatsApp](\/channels\/whatsapp) \u2014 `channels.whatsapp`\n    * [Telegram](\/channels\/telegram) \u2014 `channels.telegram`\n    * [Discord](\/channels\/discord) \u2014 `channels.discord`\n    * [Slack](\/channels\/slack) \u2014 `channels.slack`\n    * [Signal](\/channels\/signal) \u2014 `channels.signal`\n    * [iMessage](\/channels\/imessage) \u2014 `channels.imessage`\n    * [Google Chat](\/channels\/googlechat) \u2014 `channels.googlechat`\n    * [Mattermost](\/channels\/mattermost) \u2014 `channels.mattermost`\n    * [Microsoft Teams](\/channels\/msteams) \u2014 `channels.msteams`\n\n    All channels share the same DM policy pattern:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      channels: {\n        telegram: {\n          enabled: true,\n          botToken: &quot;123:abc&quot;,\n          dmPolicy: &quot;pairing&quot;,   \/\/ pairing | allowlist | open | disabled\n          allowFrom: [&quot;tg:123&quot;], \/\/ only for allowlist\/open\n        },\n      },\n    }\n    ```\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Choose and configure models&quot;&gt;\n    Set the primary model and optional fallbacks:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      agents: {\n        defaults: {\n          model: {\n            primary: &quot;anthropic\/claude-sonnet-4-6&quot;,\n            fallbacks: [&quot;openai\/gpt-5.2&quot;],\n          },\n          models: {\n            &quot;anthropic\/claude-sonnet-4-6&quot;: { alias: &quot;Sonnet&quot; },\n            &quot;openai\/gpt-5.2&quot;: { alias: &quot;GPT&quot; },\n          },\n        },\n      },\n    }\n    ```\n\n    * `agents.defaults.models` defines the model catalog and acts as the allowlist for `\/model`.\n    * Model refs use `provider\/model` format (e.g. `anthropic\/claude-opus-4-6`).\n    * `agents.defaults.imageMaxDimensionPx` controls transcript\/tool image downscaling (default `1200`); lower values usually reduce vision-token usage on screenshot-heavy runs.\n    * See [Models CLI](\/concepts\/models) for switching models in chat and [Model Failover](\/concepts\/model-failover) for auth rotation and fallback behavior.\n    * For custom\/self-hosted providers, see [Custom providers](\/gateway\/configuration-reference#custom-providers-and-base-urls) in the reference.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Control who can message the bot&quot;&gt;\n    DM access is controlled per channel via `dmPolicy`:\n\n    * `&quot;pairing&quot;` (default): unknown senders get a one-time pairing code to approve\n    * `&quot;allowlist&quot;`: only senders in `allowFrom` (or the paired allow store)\n    * `&quot;open&quot;`: allow all inbound DMs (requires `allowFrom: [&quot;*&quot;]`)\n    * `&quot;disabled&quot;`: ignore all DMs\n\n    For groups, use `groupPolicy` + `groupAllowFrom` or channel-specific allowlists.\n\n    See the [full reference](\/gateway\/configuration-reference#dm-and-group-access) for per-channel details.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Set up group chat mention gating&quot;&gt;\n    Group messages default to **require mention**. Configure patterns per agent:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      agents: {\n        list: [\n          {\n            id: &quot;main&quot;,\n            groupChat: {\n              mentionPatterns: [&quot;@openclaw&quot;, &quot;openclaw&quot;],\n            },\n          },\n        ],\n      },\n      channels: {\n        whatsapp: {\n          groups: { &quot;*&quot;: { requireMention: true } },\n        },\n      },\n    }\n    ```\n\n    * **Metadata mentions**: native @-mentions (WhatsApp tap-to-mention, Telegram @bot, etc.)\n    * **Text patterns**: safe regex patterns in `mentionPatterns`\n    * See [full reference](\/gateway\/configuration-reference#group-chat-mention-gating) for per-channel overrides and self-chat mode.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Tune gateway channel health monitoring&quot;&gt;\n    Control how aggressively the gateway restarts channels that look stale:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      gateway: {\n        channelHealthCheckMinutes: 5,\n        channelStaleEventThresholdMinutes: 30,\n        channelMaxRestartsPerHour: 10,\n      },\n      channels: {\n        telegram: {\n          healthMonitor: { enabled: false },\n          accounts: {\n            alerts: {\n              healthMonitor: { enabled: true },\n            },\n          },\n        },\n      },\n    }\n    ```\n\n    * Set `gateway.channelHealthCheckMinutes: 0` to disable health-monitor restarts globally.\n    * `channelStaleEventThresholdMinutes` should be greater than or equal to the check interval.\n    * Use `channels.&lt;provider&gt;.healthMonitor.enabled` or `channels.&lt;provider&gt;.accounts.&lt;id&gt;.healthMonitor.enabled` to disable auto-restarts for one channel or account without disabling the global monitor.\n    * See [Health Checks](\/gateway\/health) for operational debugging and the [full reference](\/gateway\/configuration-reference#gateway) for all fields.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Configure sessions and resets&quot;&gt;\n    Sessions control conversation continuity and isolation:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      session: {\n        dmScope: &quot;per-channel-peer&quot;,  \/\/ recommended for multi-user\n        threadBindings: {\n          enabled: true,\n          idleHours: 24,\n          maxAgeHours: 0,\n        },\n        reset: {\n          mode: &quot;daily&quot;,\n          atHour: 4,\n          idleMinutes: 120,\n        },\n      },\n    }\n    ```\n\n    * `dmScope`: `main` (shared) | `per-peer` | `per-channel-peer` | `per-account-channel-peer`\n    * `threadBindings`: global defaults for thread-bound session routing (Discord supports `\/focus`, `\/unfocus`, `\/agents`, `\/session idle`, and `\/session max-age`).\n    * See [Session Management](\/concepts\/session) for scoping, identity links, and send policy.\n    * See [full reference](\/gateway\/configuration-reference#session) for all fields.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Enable sandboxing&quot;&gt;\n    Run agent sessions in isolated Docker containers:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      agents: {\n        defaults: {\n          sandbox: {\n            mode: &quot;non-main&quot;,  \/\/ off | non-main | all\n            scope: &quot;agent&quot;,    \/\/ session | agent | shared\n          },\n        },\n      },\n    }\n    ```\n\n    Build the image first: `scripts\/sandbox-setup.sh`\n\n    See [Sandboxing](\/gateway\/sandboxing) for the full guide and [full reference](\/gateway\/configuration-reference#agents-defaults-sandbox) for all options.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Enable relay-backed push for official iOS builds&quot;&gt;\n    Relay-backed push is configured in `openclaw.json`.\n\n    Set this in gateway config:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      gateway: {\n        push: {\n          apns: {\n            relay: {\n              baseUrl: &quot;https:\/\/relay.example.com&quot;,\n              \/\/ Optional. Default: 10000\n              timeoutMs: 10000,\n            },\n          },\n        },\n      },\n    }\n    ```\n\n    CLI equivalent:\n\n    ```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    openclaw config set gateway.push.apns.relay.baseUrl https:\/\/relay.example.com\n    ```\n\n    What this does:\n\n    * Lets the gateway send `push.test`, wake nudges, and reconnect wakes through the external relay.\n    * Uses a registration-scoped send grant forwarded by the paired iOS app. The gateway does not need a deployment-wide relay token.\n    * Binds each relay-backed registration to the gateway identity that the iOS app paired with, so another gateway cannot reuse the stored registration.\n    * Keeps local\/manual iOS builds on direct APNs. Relay-backed sends apply only to official distributed builds that registered through the relay.\n    * Must match the relay base URL baked into the official\/TestFlight iOS build, so registration and send traffic reach the same relay deployment.\n\n    End-to-end flow:\n\n    1. Install an official\/TestFlight iOS build that was compiled with the same relay base URL.\n    2. Configure `gateway.push.apns.relay.baseUrl` on the gateway.\n    3. Pair the iOS app to the gateway and let both node and operator sessions connect.\n    4. The iOS app fetches the gateway identity, registers with the relay using App Attest plus the app receipt, and then publishes the relay-backed `push.apns.register` payload to the paired gateway.\n    5. The gateway stores the relay handle and send grant, then uses them for `push.test`, wake nudges, and reconnect wakes.\n\n    Operational notes:\n\n    * If you switch the iOS app to a different gateway, reconnect the app so it can publish a new relay registration bound to that gateway.\n    * If you ship a new iOS build that points at a different relay deployment, the app refreshes its cached relay registration instead of reusing the old relay origin.\n\n    Compatibility note:\n\n    * `OPENCLAW_APNS_RELAY_BASE_URL` and `OPENCLAW_APNS_RELAY_TIMEOUT_MS` still work as temporary env overrides.\n    * `OPENCLAW_APNS_RELAY_ALLOW_HTTP=true` remains a loopback-only development escape hatch; do not persist HTTP relay URLs in config.\n\n    See [iOS App](\/platforms\/ios#relay-backed-push-for-official-builds) for the end-to-end flow and [Authentication and trust flow](\/platforms\/ios#authentication-and-trust-flow) for the relay security model.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Set up heartbeat (periodic check-ins)&quot;&gt;\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      agents: {\n        defaults: {\n          heartbeat: {\n            every: &quot;30m&quot;,\n            target: &quot;last&quot;,\n          },\n        },\n      },\n    }\n    ```\n\n    * `every`: duration string (`30m`, `2h`). Set `0m` to disable.\n    * `target`: `last` | `whatsapp` | `telegram` | `discord` | `none`\n    * `directPolicy`: `allow` (default) or `block` for DM-style heartbeat targets\n    * See [Heartbeat](\/gateway\/heartbeat) for the full guide.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Configure cron jobs&quot;&gt;\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      cron: {\n        enabled: true,\n        maxConcurrentRuns: 2,\n        sessionRetention: &quot;24h&quot;,\n        runLog: {\n          maxBytes: &quot;2mb&quot;,\n          keepLines: 2000,\n        },\n      },\n    }\n    ```\n\n    * `sessionRetention`: prune completed isolated run sessions from `sessions.json` (default `24h`; set `false` to disable).\n    * `runLog`: prune `cron\/runs\/&lt;jobId&gt;.jsonl` by size and retained lines.\n    * See [Cron jobs](\/automation\/cron-jobs) for feature overview and CLI examples.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Set up webhooks (hooks)&quot;&gt;\n    Enable HTTP webhook endpoints on the Gateway:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      hooks: {\n        enabled: true,\n        token: &quot;shared-secret&quot;,\n        path: &quot;\/hooks&quot;,\n        defaultSessionKey: &quot;hook:ingress&quot;,\n        allowRequestSessionKey: false,\n        allowedSessionKeyPrefixes: [&quot;hook:&quot;],\n        mappings: [\n          {\n            match: { path: &quot;gmail&quot; },\n            action: &quot;agent&quot;,\n            agentId: &quot;main&quot;,\n            deliver: true,\n          },\n        ],\n      },\n    }\n    ```\n\n    Security note:\n\n    * Treat all hook\/webhook payload content as untrusted input.\n    * Keep unsafe-content bypass flags disabled (`hooks.gmail.allowUnsafeExternalContent`, `hooks.mappings[].allowUnsafeExternalContent`) unless doing tightly scoped debugging.\n    * For hook-driven agents, prefer strong modern model tiers and strict tool policy (for example messaging-only plus sandboxing where possible).\n\n    See [full reference](\/gateway\/configuration-reference#hooks) for all mapping options and Gmail integration.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Configure multi-agent routing&quot;&gt;\n    Run multiple isolated agents with separate workspaces and sessions:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    {\n      agents: {\n        list: [\n          { id: &quot;home&quot;, default: true, workspace: &quot;~\/.openclaw\/workspace-home&quot; },\n          { id: &quot;work&quot;, workspace: &quot;~\/.openclaw\/workspace-work&quot; },\n        ],\n      },\n      bindings: [\n        { agentId: &quot;home&quot;, match: { channel: &quot;whatsapp&quot;, accountId: &quot;personal&quot; } },\n        { agentId: &quot;work&quot;, match: { channel: &quot;whatsapp&quot;, accountId: &quot;biz&quot; } },\n      ],\n    }\n    ```\n\n    See [Multi-Agent](\/concepts\/multi-agent) and [full reference](\/gateway\/configuration-reference#multi-agent-routing) for binding rules and per-agent access profiles.\n  &lt;\/Accordion&gt;\n\n  &lt;Accordion title=&quot;Split config into multiple files ($include)&quot;&gt;\n    Use `$include` to organize large configs:\n\n    ```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n    \/\/ ~\/.openclaw\/openclaw.json\n    {\n      gateway: { port: 18789 },\n      agents: { $include: &quot;.\/agents.json5&quot; },\n      broadcast: {\n        $include: [&quot;.\/clients\/a.json5&quot;, &quot;.\/clients\/b.json5&quot;],\n      },\n    }\n    ```\n\n    * **Single file**: replaces the containing object\n    * **Array of files**: deep-merged in order (later wins)\n    * **Sibling keys**: merged after includes (override included values)\n    * **Nested includes**: supported up to 10 levels deep\n    * **Relative paths**: resolved relative to the including file\n    * **Error handling**: clear errors for missing files, parse errors, and circular includes\n  &lt;\/Accordion&gt;\n&lt;\/AccordionGroup&gt;\n\n## Config hot reload\n\nThe Gateway watches `~\/.openclaw\/openclaw.json` and applies changes automatically \u2014 no manual restart needed for most settings.\n\n### Reload modes\n\n| Mode                   | Behavior                                                                                |\n| ---------------------- | --------------------------------------------------------------------------------------- |\n| **`hybrid`** (default) | Hot-applies safe changes instantly. Automatically restarts for critical ones.           |\n| **`hot`**              | Hot-applies safe changes only. Logs a warning when a restart is needed \u2014 you handle it. |\n| **`restart`**          | Restarts the Gateway on any config change, safe or not.                                 |\n| **`off`**              | Disables file watching. Changes take effect on the next manual restart.                 |\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  gateway: {\n    reload: { mode: &quot;hybrid&quot;, debounceMs: 300 },\n  },\n}\n<\/code><\/pre>\n<h3>What hot-applies vs what needs a restart<\/h3>\n<p>Most fields hot-apply without downtime. In <code>hybrid<\/code> mode, restart-required changes are handled automatically.<\/p>\n<table>\n<thead>\n<tr>\n<th>Category<\/th>\n<th>Fields<\/th>\n<th>Restart needed?<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Channels<\/td>\n<td><code>channels.*<\/code>, <code>web<\/code> (WhatsApp) \u2014 all built-in and extension channels<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Agent &amp; models<\/td>\n<td><code>agent<\/code>, <code>agents<\/code>, <code>models<\/code>, <code>routing<\/code><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Automation<\/td>\n<td><code>hooks<\/code>, <code>cron<\/code>, <code>agent.heartbeat<\/code><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Sessions &amp; messages<\/td>\n<td><code>session<\/code>, <code>messages<\/code><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Tools &amp; media<\/td>\n<td><code>tools<\/code>, <code>browser<\/code>, <code>skills<\/code>, <code>audio<\/code>, <code>talk<\/code><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>UI &amp; misc<\/td>\n<td><code>ui<\/code>, <code>logging<\/code>, <code>identity<\/code>, <code>bindings<\/code><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Gateway server<\/td>\n<td><code>gateway.*<\/code> (port, bind, auth, tailscale, TLS, HTTP)<\/td>\n<td><strong>Yes<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Infrastructure<\/td>\n<td><code>discovery<\/code>, <code>canvasHost<\/code>, <code>plugins<\/code><\/td>\n<td><strong>Yes<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n  <code>gateway.reload<\/code> and <code>gateway.remote<\/code> are exceptions \u2014 changing them does <strong>not<\/strong> trigger a restart.\n<\/p>\n<h2>Config RPC (programmatic updates)<\/h2>\n<p>\n  Control-plane write RPCs (<code>config.apply<\/code>, <code>config.patch<\/code>, <code>update.run<\/code>) are rate-limited to <strong>3 requests per 60 seconds<\/strong> per <code>deviceId+clientIp<\/code>. When limited, the RPC returns <code>UNAVAILABLE<\/code> with <code>retryAfterMs<\/code>.\n<\/p>\n<p>    Validates + writes the full config and restarts the Gateway in one step.<\/p>\n<pre><code>&lt;Warning&gt;\n  `config.apply` replaces the **entire config**. Use `config.patch` for partial updates, or `openclaw config set` for single keys.\n&lt;\/Warning&gt;\n\nParams:\n\n* `raw` (string) \u2014 JSON5 payload for the entire config\n* `baseHash` (optional) \u2014 config hash from `config.get` (required when config exists)\n* `sessionKey` (optional) \u2014 session key for the post-restart wake-up ping\n* `note` (optional) \u2014 note for the restart sentinel\n* `restartDelayMs` (optional) \u2014 delay before restart (default 2000)\n\nRestart requests are coalesced while one is already pending\/in-flight, and a 30-second cooldown applies between restart cycles.\n\n```bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}\nopenclaw gateway call config.get --params '{}'  # capture payload.hash\nopenclaw gateway call config.apply --params '{\n  \"raw\": \"{ agents: { defaults: { workspace: \"~\/.openclaw\/workspace\" } } }\",\n  \"baseHash\": \"&lt;hash&gt;\",\n  \"sessionKey\": \"agent:main:whatsapp:direct:+15555550123\"\n}'\n```\n<\/code><\/pre>\n<\/p>\n<p>\n    Merges a partial update into the existing config (JSON merge patch semantics):<\/p>\n<pre><code>* Objects merge recursively\n* `null` deletes a key\n* Arrays replace\n\nParams:\n\n* `raw` (string) \u2014 JSON5 with just the keys to change\n* `baseHash` (required) \u2014 config hash from `config.get`\n* `sessionKey`, `note`, `restartDelayMs` \u2014 same as `config.apply`\n\nRestart behavior matches `config.apply`: coalesced pending restarts plus a 30-second cooldown between restart cycles.\n\n```bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}\nopenclaw gateway call config.patch --params '{\n  \"raw\": \"{ channels: { telegram: { groups: { \"*\": { requireMention: false } } } } }\",\n  \"baseHash\": \"&lt;hash&gt;\"\n}'\n```\n<\/code><\/pre>\n<\/p>\n<h2>Environment variables<\/h2>\n<p>OpenClaw reads env vars from the parent process plus:<\/p>\n<ul>\n<li><code>.env<\/code> from the current working directory (if present)<\/li>\n<li><code>~\/.openclaw\/.env<\/code> (global fallback)<\/li>\n<\/ul>\n<p>Neither file overrides existing env vars. You can also set inline env vars in config:<\/p>\n<p><code>json5  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\n{<br \/>\n  env: {<br \/>\n    OPENROUTER_API_KEY: \"sk-or-...\",<br \/>\n    vars: { GROQ_API_KEY: \"gsk-...\" },<br \/>\n  },<br \/>\n}<\/code><\/p>\n<p>\n  If enabled and expected keys aren&#8217;t set, OpenClaw runs your login shell and imports only the missing keys:<\/p>\n<p><code>json5  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\n  {<br \/>\n    env: {<br \/>\n      shellEnv: { enabled: true, timeoutMs: 15000 },<br \/>\n    },<br \/>\n  }<\/code><\/p>\n<p>Env var equivalent: <code>OPENCLAW_LOAD_SHELL_ENV=1<\/code>\n<\/p>\n<p>\n  Reference env vars in any config string value with <code>${VAR_NAME}<\/code>:<\/p>\n<p><code>json5  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\n  {<br \/>\n    gateway: { auth: { token: \"${OPENCLAW_GATEWAY_TOKEN}\" } },<br \/>\n    models: { providers: { custom: { apiKey: \"${CUSTOM_API_KEY}\" } } },<br \/>\n  }<\/code><\/p>\n<p>Rules:<\/p>\n<ul>\n<li>Only uppercase names matched: <code>[A-Z_][A-Z0-9_]*<\/code><\/li>\n<li>Missing\/empty vars throw an error at load time<\/li>\n<li>Escape with <code>$${VAR}<\/code> for literal output<\/li>\n<li>Works inside <code>$include<\/code> files<\/li>\n<li>Inline substitution: <code>\"${BASE}\/v1\"<\/code> \u2192 <code>\"https:\/\/api.example.com\/v1\"<\/code>\n<\/li>\n<\/ul>\n<p>\n  For fields that support SecretRef objects, you can use:<\/p>\n<p><code>json5  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\n  {<br \/>\n    models: {<br \/>\n      providers: {<br \/>\n        openai: { apiKey: { source: \"env\", provider: \"default\", id: \"OPENAI_API_KEY\" } },<br \/>\n      },<br \/>\n    },<br \/>\n    skills: {<br \/>\n      entries: {<br \/>\n        \"image-lab\": {<br \/>\n          apiKey: {<br \/>\n            source: \"file\",<br \/>\n            provider: \"filemain\",<br \/>\n            id: \"\/skills\/entries\/image-lab\/apiKey\",<br \/>\n          },<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n    channels: {<br \/>\n      googlechat: {<br \/>\n        serviceAccountRef: {<br \/>\n          source: \"exec\",<br \/>\n          provider: \"vault\",<br \/>\n          id: \"channels\/googlechat\/serviceAccount\",<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n  }<\/code><\/p>\n<p>SecretRef details (including <code>secrets.providers<\/code> for <code>env<\/code>\/<code>file<\/code>\/<code>exec<\/code>) are in <a href=\"\/gateway\/secrets\">Secrets Management<\/a>.<br \/>\n  Supported credential paths are listed in <a href=\"\/reference\/secretref-credential-surface\">SecretRef Credential Surface<\/a>.\n<\/p>\n<p>See <a href=\"\/help\/environment\">Environment<\/a> for full precedence and sources.<\/p>\n<h2>Full reference<\/h2>\n<p>For the complete field-by-field reference, see <strong><a href=\"\/gateway\/configuration-reference\">Configuration Reference<\/a><\/strong>.<\/p>\n<hr \/>\n<p><em>Related: <a href=\"\/gateway\/configuration-examples\">Configuration Examples<\/a> \u00b7 <a href=\"\/gateway\/configuration-reference\">Configuration Reference<\/a> \u00b7 <a href=\"\/gateway\/doctor\">Doctor<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configuration OpenClaw reads an optional JSON5 config f [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-751","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=751"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/751\/revisions"}],"predecessor-version":[{"id":872,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/751\/revisions\/872"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}