Gateway
The v1 gateway routes incoming requests to registered plugins. It supports three payment methods — session-based billing (off-chain vouchers), MPP (Machine Payments Protocol on the Tempo blockchain), and Stripe.Base URL
Request
Headers
Body
Additional body fields are forwarded to the target plugin.
Plugins
The gateway routes to the following plugins:agent is the default plugin when no plugin ID is specified.Authentication
Protected plugins require either a valid session (cookie-based via NextAuth), a verified MPP payment credential, or a valid payment session with receipt. If you pay with MPP or session-based billing, NextAuth session authentication is not required.Payment flow
The gateway supports three payment methods per request:- Session — Off-chain billing via payment sessions. Each agent call auto-debits a voucher from the session balance with sub-100ms latency. See MPP sessions.
- MPP — Crypto-native per-request payments on the Tempo blockchain. See MPP payments.
- Stripe — Credit card payments. Requires an active subscription or credits. See Stripe integration.
X-Payment-Methodheader (session,mpp, orstripe)- Presence of an
Authorization: Paymentheader (impliesmpp) - Presence of an
X-Session-Idheader (impliessession) - Default:
stripe
Session billing
When the payment method issession, the gateway auto-debits the session balance via an off-chain voucher. You must provide both X-Session-Id and X-Wallet-Address headers.
The gateway checks the session balance against the plugin’s price before forwarding the request. If the balance is insufficient, the gateway returns 402 with the current balance and required cost.
Payment-Receipt header with the session receipt and an X-Session-Remaining header with the updated balance.
Session 402 errors
When a session payment fails, the response includes a specific error code:
Example insufficient balance response:
MPP 402 challenge
When an MPP request has no valid credential, the gateway returns402 Payment Required with pricing information for both payment methods:
WWW-Authenticate header is also set:
Response
Success (200)
Payment-Receipt header and the payment.receipt field contains the transaction hash. When paid via session, the Payment-Receipt header contains the session receipt and the X-Session-Remaining header contains the updated balance.
Response headers
Error responses
Per-agent gateway authentication
Each agent container receives a unique gateway auth token at provisioning time. The internal gateway authenticates requests using token-based auth on port18789.
The container entrypoint writes its own minimal configuration to
$HOME/.openclaw/openclaw.json using a slightly different schema (auth.method at the top level instead of gateway.auth.mode). The provisioning config written by the backend uses the gateway.auth.mode path. When the entrypoint runs, it overwrites the provisioning config with its own minimal skeleton. To preserve the full provisioning config, pass the gateway token via the OPENCLAW_GATEWAY_TOKEN environment variable so the entrypoint uses the same token.Agent container configuration
When an agent is provisioned, the backend generates an OpenClaw configuration with the following parameters. These values are set automatically and cannot be overridden by the caller.Container environment variables
The following environment variables are set on every agent container at launch:Gateway settings
Tool settings
Session settings
Agent defaults
Health monitoring
The gateway monitors channel health for each agent container. When a channel becomes unresponsive, the gateway can automatically restart it.CORS
The gateway supports CORS preflight viaOPTIONS /api/v1/gateway. Allowed methods are GET, POST, PUT, DELETE, and OPTIONS. The Content-Type, Authorization, X-Plugin-Id, and Payment headers are permitted.