Skip to main content

Maintenance API

Check agent health, query runtime state, and trigger maintenance restarts. These endpoints operate on the authenticated user’s deployed agent instance. All lifecycle endpoints (start, stop, restart, repair, reset-memory, update, and POST /api/openclaw/maintenance) resolve the target Railway service using a two-tier strategy:
  1. Persisted service ID (preferred) — when the agent’s configuration includes a runtimeServiceId, the platform uses it directly without making any Railway API calls. This is the default for agents provisioned with the current platform version.
  2. Project-level discovery (fallback) — when no persisted service ID is available (for example, agents provisioned before this feature was introduced), the platform falls back to listing all services in the Railway project and matching by name.

Get instance runtime state

Requires session authentication. Returns runtime state for a specific agent instance using the shared runtime probe, which checks /healthz, /readyz, and /api/status on the agent. This endpoint resolves status without a backend hop — it reads the persisted OpenClaw URL from the database and probes the agent in-process.

Path parameters

Response

Status values

The shared runtime probe uses /api/status as the authoritative health signal. The legacy /healthz and /readyz endpoints may legitimately return 404 on some deployments. When /api/status returns 200, the agent is considered reachable regardless of legacy probe results.

Errors


Get instance stats

Requires session authentication and instance ownership. Returns runtime stats for a specific agent instance using the shared runtime probe, which checks /healthz, /readyz, and /api/status. Resource-level metrics (CPU, memory) are not yet exposed by the gateway and return placeholder values.

Path parameters

Response

The telemetry object is included to signal which metric categories the API supports. All three categories are currently false because the managed runtime does not yet expose restart counts, last-exit details, or per-message telemetry. These fields will transition to true as the underlying runtime adds support.

Errors


Start instance

Requires session authentication and instance ownership. Triggers a deploy of the user’s agent service on Railway. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503.

Path parameters

Response

Errors


Stop instance

Requires session authentication and instance ownership. Stops (suspends) the user’s agent service on Railway. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503.

Path parameters

Response

Errors


Restart instance

Requires session authentication and instance ownership. Restarts the user’s agent gateway on Railway. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503.

Path parameters

Response

Errors


Repair instance

Requires session authentication and instance ownership. Performs a full reconfigure of the agent service: rewrites all environment variables on Railway and restarts the container. Use this to fix broken gateway tokens, corrupted configuration, or stuck containers. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503. The repair uses the user’s per-user gateway token from the database. If no token exists, a new one is generated automatically.

Path parameters

Response

Errors


Reset instance memory

Requires session authentication and instance ownership. Wipes all stored agent memories from the database and restarts the container. The agent starts fresh as if newly provisioned. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503.
This action permanently deletes all agent memory entries for the user. The workspace on Railway is ephemeral and resets on restart.

Path parameters

Response

Errors


Update instance image

Requires session authentication and instance ownership. Updates the agent container to the platform’s current default OpenClaw image and triggers a redeploy. The target service is resolved using the persisted runtimeServiceId when available. When managed runtime controls are disabled, this endpoint returns 503.

Path parameters

Response

Errors


Get instance gateway token

Requires session authentication and instance ownership. Returns the gateway token for the user’s agent instance.

Path parameters

Response

Errors


503 error details

All lifecycle endpoints (start, stop, restart, repair, reset-memory, and update) return 503 in two scenarios:

Controls disabled

When managed runtime controls are disabled via the ENABLE_OPENCLAW_CONTROLS or NEXT_PUBLIC_ENABLE_OPENCLAW_CONTROLS environment variables, all lifecycle endpoints return:

Service or configuration resolution failure

When the platform cannot resolve the Railway service for the agent, lifecycle endpoints return 503 with a descriptive error message. This happens before the lifecycle action is attempted and indicates a configuration problem on the platform side, not an issue with the agent itself. The platform resolves the Railway service using a two-tier strategy:
  1. Persisted service ID — when the agent’s configuration includes a runtimeServiceId (set during provisioning), the platform uses it directly. No Railway API call is made and no project-level listing is needed. This is the default for recently provisioned agents.
  2. Project-level discovery — when no persisted service ID exists, the platform falls back to listing all services in the Railway project and matching by name candidates derived from the agent’s URL and identifier. This fallback requires a Railway token with project-listing permissions.
When the persisted service ID is available, the only possible resolution errors are missing environment configuration (RAILWAY_API_KEY, RAILWAY_ENVIRONMENT_ID, or RAILWAY_PROJECT_ID). Ensure RAILWAY_TOKEN_TYPE is also set correctly — when using a project-scoped token, set it to project so the platform sends the key via the Project-Access-Token header instead of the default Authorization: Bearer header. The project-listing errors (No managed service reference found and Managed Railway service not found) only occur in the fallback path.
Possible error messages include:
Service resolution errors are distinct from operation errors. A 503 means the platform could not locate the agent’s service to act on. A 500 means the service was found but the requested action (deploy, suspend, restart, or env var update) failed. Agents provisioned with the current platform version include a persisted service ID that bypasses project-level discovery entirely, making the last two error messages unlikely for new deployments.

Get agent health

Requires session authentication. Returns liveness and readiness status for the user’s agent container by probing the agent’s /healthz, /readyz, and /api/status endpoints using the shared runtime probe.
This endpoint uses GET /api/status on the agent as the authoritative health signal. The legacy /healthz and /readyz probes are still checked for backward compatibility but may legitimately return 404 on some deployments. When /api/status returns 200, the agent is considered reachable even if the legacy probes fail.

Response

Status values

Response when no agent is deployed

When the authenticated user has no deployed agent:
The health check uses a 5-second timeout for /healthz and /api/status, and a 4-second timeout for /readyz. When /api/status is reachable but legacy probes fail, the statusReason field explains why the status was derived from /api/status alone.

Errors

Restart or reset agent

Requires session authentication. Triggers a restart or factory reset of the user’s agent container. The action field in the request body determines the behavior. This endpoint resolves the target Railway service using the persisted runtimeServiceId from the agent’s configuration when available, falling back to project-level service discovery for older agents. See service resolution for details. When managed runtime controls are disabled (via the ENABLE_OPENCLAW_CONTROLS or NEXT_PUBLIC_ENABLE_OPENCLAW_CONTROLS environment variables set to false), this endpoint returns 503 with the message: Managed runtime controls are temporarily disabled until the Railway control path is fully verified.

Request body

Actions

restart (default)

Restarts the agent container. The agent automatically runs openclaw doctor --fix on startup, which performs health checks and applies any pending migrations. Request:
Response:

factory-reset

Pins the agent to the known-good OpenClaw image (v2026.4.11), reconfigures environment variables, and restarts the container with doctor --fix. Use this when an agent is broken after updating to an incompatible version. Request:
Response:

Error responses

When the user has no deployed agent:
When a restart or factory reset fails:
Both restart and factory-reset cause a brief period of downtime while the container reinitializes. The openclaw doctor --fix process runs automatically during startup and may take additional time depending on the number of pending fixes or migrations.
Factory reset pins the agent to the platform’s configured default image. After a factory reset, you can update to a newer version later through the normal update flow.

Ensure OpenClaw compatibility

Requires session authentication. Checks and migrates the authenticated user’s agent setup for compatibility with OpenClaw 2026.4.11. This endpoint applies any necessary fixes automatically, including plugin config migration, agent pairing scope corrections, and token generation.

Response

Response when no fixes are needed

Error response

When the compatibility check itself fails:
This endpoint is idempotent. Calling it multiple times applies only the fixes that have not already been applied. After all fixes are applied, subsequent calls return an empty fixes array.

OpenClaw runtime version

Returns the current OpenClaw runtime version and container image. Requires bearer token authentication (the /api/openclaw router applies the authenticate middleware to all non-proxy routes). The backend normalizes the version before returning it. If the configured image uses a floating tag such as latest, the backend replaces it with the current managed baseline version (2026.4.11) so the response always contains a concrete release number.

Response

OpenClaw runtime version (web proxy)

No authentication required. Proxies to the backend GET /api/openclaw/version endpoint using the internal API key. Returns the OpenClaw runtime version, container image, and deployment timestamp. When the backend is unreachable or returns an error, the endpoint returns a fallback version derived from the configured image tag (for example, 2026.4.11) and includes the default image.

Version normalization

All version endpoints — the backend GET /api/openclaw/version, the web proxy GET /api/openclaw-version, and the web-layer GET /api/openclaw/version — normalize the openclawVersion value before returning it. If the configured image uses a floating tag like latest, the version is replaced with the current managed baseline version (currently 2026.4.11). This ensures every layer of the API returns a concrete release number rather than an opaque tag, so you can reliably compare the running version against known releases.

Response

This endpoint uses an 8-second request timeout when calling the backend. If the backend does not respond within that window, the fallback version is returned. Version normalization now applies at every layer: the backend GET /api/openclaw/version, the web proxy GET /api/openclaw-version, and the web-layer GET /api/openclaw/version all normalize floating tags to the managed baseline.

Heal gateway token

Requires session authentication. Auto-heals (regenerates) the gateway token for the authenticated user’s OpenClaw agent. When the user has no existing token, the endpoint generates a new one automatically instead of only checking for an existing token. The endpoint also checks gateway health and sends support alerts when token generation fails or the gateway is degraded.

Response

Response when token generation fails

Error response

This endpoint replaces the previous behavior where users had to manually refresh their pairing token. Tokens are now auto-generated when missing. The generated token is a 64-character hex string stored per-user in the database. Lifecycle operations such as repair use the per-user token from the database when reconfiguring the agent runtime.

List OpenClaw instances

Returns all running OpenClaw agent containers with their image, status, and metadata. Requires bearer token authentication.

Response

Errors

Get instance container stats

Returns live resource usage for a specific OpenClaw container. Requires bearer token authentication.

Path parameters

Response

Errors

OpenClaw proxy

Transparent HTTP proxy to a running OpenClaw container. Forwards all HTTP methods to the container’s internal address on port 18789. HTTP requests do not require authentication on the proxy itself — the OpenClaw instance’s own token authentication handles access control.
WebSocket upgrades through the proxy require bearer token authentication. The server validates the Authorization: Bearer <token> header before establishing the WebSocket connection. This is handled at the server level, separate from the HTTP proxy middleware.
The proxy rewrites the request path by stripping the /api/openclaw/proxy/:agentId prefix before forwarding.

Path parameters

Errors