Skip to main content

Maintenance API

Check agent health and trigger maintenance restarts. These endpoints operate on the authenticated user’s deployed agent instance.

Get agent health

GET /api/openclaw/maintenance
Requires session authentication. Returns liveness and readiness status for the user’s agent container by probing the agent’s /healthz and /readyz endpoints.

Response

{
  "instanceId": "abc123",
  "railwayUrl": "https://agentbot-agent-abc123-production.up.railway.app",
  "healthy": true,
  "ready": true,
  "version": "2026.3.28",
  "uptime": "2d 5h",
  "status": "healthy"
}
FieldTypeDescription
instanceIdstringThe agent’s instance identifier
railwayUrlstringThe agent’s public Railway URL
healthybooleantrue when the agent’s /healthz endpoint responds successfully
readybooleantrue when the agent’s /readyz endpoint responds successfully
versionstring | nullAgent runtime version reported by /healthz, or null if unavailable
uptimestring | nullAgent uptime reported by /healthz, or null if unavailable
statusstringComputed status: healthy, starting, or unreachable

Status values

StatusCondition
healthyBoth /healthz and /readyz respond successfully
starting/healthz responds but /readyz does not
unreachable/healthz does not respond

Response when no agent is deployed

When the authenticated user has no deployed agent:
{
  "status": "no_agent",
  "healthy": false,
  "ready": false
}
The health check uses a 5-second timeout for the /healthz probe and a 4-second timeout for the /readyz probe. Agents that are slow to start may report as unreachable or starting until fully initialized.

Errors

CodeDescription
200Health status returned (check status field for actual health)
401Unauthorized — missing or invalid session

Restart agent

POST /api/openclaw/maintenance
Requires session authentication. Triggers a restart of the user’s agent container. The agent automatically runs openclaw doctor --fix on startup, which performs health checks and applies any pending migrations.

Response

{
  "success": true,
  "message": "Agent restarting — doctor & migrations run on startup"
}
FieldTypeDescription
successbooleantrue when the restart was initiated
messagestringConfirmation message

Error responses

When the user has no deployed agent:
{
  "error": "No agent deployed"
}
When the backend restart call fails:
{
  "error": "Restart failed",
  "details": 502
}
CodeDescription
200Restart initiated
401Unauthorized — missing or invalid session
404No agent deployed for the authenticated user
500Internal error during the restart request
502Backend restart call failed
Restarting an agent causes 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.