docs/gateway/tools-invoke-http-api.md
OpenClaw’s Gateway exposes a simple HTTP endpoint for invoking a single tool directly. It is always enabled and uses Gateway auth plus tool policy. Like the OpenAI-compatible /v1/* surface, shared-secret bearer auth is treated as trusted operator access for the whole gateway.
POST /tools/invokehttp://<gateway-host>:<port>/tools/invokeDefault max payload size is 2 MB.
Uses the Gateway auth configuration.
Common HTTP auth paths:
gateway.auth.mode="token" or "password"):
Authorization: Bearer <token-or-password>gateway.auth.mode="trusted-proxy"):
route through the configured identity-aware proxy and let it inject the
required identity headersgateway.auth.mode="none"):
no auth header requiredNotes:
gateway.auth.mode="token", use gateway.auth.token (or OPENCLAW_GATEWAY_TOKEN).gateway.auth.mode="password", use gateway.auth.password (or OPENCLAW_GATEWAY_PASSWORD).gateway.auth.mode="trusted-proxy", the HTTP request must come from a
configured trusted proxy source; same-host loopback proxies require explicit
gateway.auth.trustedProxy.allowLoopback = true.gateway.auth.rateLimit is configured and too many auth failures occur, the endpoint returns 429 with Retry-After.Treat this endpoint as a full operator-access surface for the gateway instance.
token and password), the endpoint restores the normal full operator defaults even if the caller sends a narrower x-openclaw-scopes header.gateway.auth.mode="none" on a private ingress) honor x-openclaw-scopes when present and otherwise fall back to the normal operator default scope set.Auth matrix:
gateway.auth.mode="token" or "password" + Authorization: Bearer ...
x-openclaw-scopesoperator.admin, operator.approvals, operator.pairing,
operator.read, operator.talk.secrets, operator.writegateway.auth.mode="none" on private ingress)
x-openclaw-scopes when the header is presentoperator.admin{
"tool": "sessions_list",
"action": "json",
"args": {},
"sessionKey": "main",
"dryRun": false
}
Fields:
tool (string, required): tool name to invoke.action (string, optional): mapped into args if the tool schema supports action and the args payload omitted it.args (object, optional): tool-specific arguments.sessionKey (string, optional): target session key. If omitted or "main", the Gateway uses the configured main session key (honors session.mainKey and default agent, or global in global scope).dryRun (boolean, optional): reserved for future use; currently ignored.Tool availability is filtered through the same policy chain used by Gateway agents:
tools.profile / tools.byProvider.profiletools.allow / tools.byProvider.allowagents.<id>.tools.allow / agents.<id>.tools.byProvider.allowIf a tool is not allowed by policy, the endpoint returns 404.
Important boundary notes:
/tools/invoke does not add an extra per-call approval prompt.Gateway HTTP also applies a hard deny list by default (even if session policy allows the tool):
exec — direct command execution (RCE surface)spawn — arbitrary child process creation (RCE surface)shell — shell command execution (RCE surface)fs_write — arbitrary file mutation on the hostfs_delete — arbitrary file deletion on the hostfs_move — arbitrary file move/rename on the hostapply_patch — patch application can rewrite arbitrary filessessions_spawn — session orchestration; spawning agents remotely is RCEsessions_send — cross-session message injectioncron — persistent automation control planegateway — gateway control plane; prevents reconfiguration via HTTPnodes — node command relay can reach system.run on paired hostswhatsapp_login — interactive setup requiring terminal QR scan; hangs on HTTPYou can customize this deny list via gateway.tools:
{
gateway: {
tools: {
// Additional tools to block over HTTP /tools/invoke
deny: ["browser"],
// Remove tools from the default deny list
allow: ["gateway"],
},
},
}
To help group policies resolve context, you can optionally set:
x-openclaw-message-channel: <channel> (example: slack, telegram)x-openclaw-account-id: <accountId> (when multiple accounts exist)200 → { ok: true, result }400 → { ok: false, error: { type, message } } (invalid request or tool input error)401 → unauthorized429 → auth rate-limited (Retry-After set)404 → tool not available (not found or not allowlisted)405 → method not allowed500 → { ok: false, error: { type, message } } (unexpected tool execution error; sanitized message)curl -sS http://127.0.0.1:18789/tools/invoke \
-H 'Authorization: Bearer secret' \
-H 'Content-Type: application/json' \
-d '{
"tool": "sessions_list",
"action": "json",
"args": {}
}'