Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions api-reference/support.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: Support API
description: "Token auto-healing, diagnostics, and self-service support endpoints"
---
Comment on lines +1 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 New support page not added to docs.json navigation

The new api-reference/support.mdx page is created but not registered in the navigation.groups array in docs.json. The "API Reference" group (docs.json:95-183) lists all API reference pages, but "api-reference/support" is missing. This means the page will exist but be unreachable through the site's navigation menu — users can only access it via a direct URL.

Prompt for agents
The new file api-reference/support.mdx needs to be added to the navigation configuration in docs.json. In docs.json, find the "API Reference" group (around line 95) and add "api-reference/support" to the pages array. A logical placement would be near related endpoints like api-reference/health or api-reference/debug (around lines 122-138).
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


# Support API

Self-service endpoints for diagnosing issues and automatically repairing gateway tokens. These endpoints help restore connectivity when tokens expire or go missing without requiring manual intervention.

## Heal gateway token

```http
POST /api/support/heal-token
```

Requires session authentication. Automatically retrieves or generates a new gateway token for the authenticated user. The endpoint first checks for an existing user-specific token in the database and generates a new one if none is found.

Gateway health is checked before token operations. If the gateway is degraded, the response still returns a valid token but includes the degraded health status.

### Response (success)

```json
{
"healed": true,
"token": "a1b2c3d4e5f6...64-character-hex-string",
"isNew": true,
"health": {
"name": "OpenClaw Gateway",
"status": "ok",
"detail": null
},
"message": "New gateway token generated successfully"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `healed` | boolean | `true` when a valid token was returned |
| `token` | string | The gateway token (64-character hex string). This is either an existing valid token or a newly generated one. |
| `isNew` | boolean | `true` when a new token was generated, `false` when an existing token was returned |
| `health` | object | Gateway health check result |
| `health.name` | string | Service name (`OpenClaw Gateway`) |
| `health.status` | string | Gateway health status: `ok`, `degraded`, or `down` |
| `health.detail` | string \| null | Additional detail when the gateway is not healthy |
| `message` | string | Human-readable description of the outcome |

### Response (failure)

```json
{
"healed": false,
"message": "Failed to generate gateway token. Support has been alerted.",
"health": {
"name": "OpenClaw Gateway",
"status": "down",
"detail": "Connection refused"
}
}
```

### Errors

| Code | Description |
|------|-------------|
| 401 | Unauthorized — missing or invalid session |
| 500 | Token generation failed. An automatic support alert is sent when this occurs. |

<Note>The dashboard calls this endpoint automatically on load when a gateway token is missing. You typically do not need to call this endpoint manually.</Note>

---

## Get diagnostics

```http
GET /api/support/diagnostics
```

Requires session authentication (email must be present). Returns a snapshot of platform health, active trial counts, recent agent errors, and gateway token status.

### Response

```json
{
"serviceHealth": [
{
"name": "OpenClaw Gateway",
"status": "ok",
"detail": null
}
],
"trialCount": 12,
"tokenStatus": "present",
"recentErrors": [
{
"id": "agent_abc",
"name": "My Agent",
"updatedAt": "2026-04-04T10:00:00.000Z",
"status": "error"
}
],
"gatewayUrl": "https://openclaw-gw-ui-production.up.railway.app",
"timestamp": "2026-04-04T12:00:00.000Z"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `serviceHealth` | array | Health status of monitored backend services |
| `serviceHealth[].name` | string | Service name |
| `serviceHealth[].status` | string | Health status: `ok`, `degraded`, or `down` |
| `serviceHealth[].detail` | string \| null | Error detail when the service is not healthy |
| `trialCount` | number | Number of users currently on an active free trial |
| `tokenStatus` | string | Gateway token status: `present` or `missing`. When `missing`, a support alert is sent automatically. |
| `recentErrors` | array | Up to 5 most recently updated agents in `error` status |
| `recentErrors[].id` | string | Agent identifier |
| `recentErrors[].name` | string | Agent display name |
| `recentErrors[].updatedAt` | string | ISO 8601 timestamp of the last status update |
| `recentErrors[].status` | string | Agent status (always `error` in this list) |
| `gatewayUrl` | string | The OpenClaw gateway URL used for health checks |
| `timestamp` | string | ISO 8601 timestamp of the diagnostics snapshot |

### Errors

| Code | Description |
|------|-------------|
| 401 | Unauthorized — missing or invalid session, or email not present |
| 500 | Diagnostics query failed |