> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://stelltec.com/rhebok/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://stelltec.com/rhebok/docs/_mcp/server.

# Disconnect an agent

POST http://127.0.0.1:7331/api/agents/disconnect
Content-Type: application/json

Removes rhebok's own entries from the agent's config files and returns
the agent's new state with the files it changed. `instructions` is
accepted and ignored.


Reference: https://stelltec.com/rhebok/docs/api/agents/disconnect-agent

## Request

### Body (application/json)

This endpoint expects an AgentRequest.

- `id` (string, required) — The agent id, for example `claude-code` or `codex`. A blank id is refused.
- `instructions` (boolean, optional, default: false) — On connect, also add the opt-in instructions block where the agent has one (Codex's `AGENTS.md`).

## Response

### 200

Disconnected.

- `agent` (Agent, required)
- `change` (AgentChange, required)

## Errors

### 400 Bad Request Error

The body is not valid JSON for this route, `id` is blank, or the agent refused an option. A body or blank-id error has only `error`; an agent refusal also has `unparseable: false`.

- `DisconnectAgentRequestBadRequestError`
  - AgentRefusalError: AgentRefusalError
  - Error: Error

### 404 Not Found Error

No supported agent has that id.

- `error` (string, required)
- `unparseable` (boolean, required) — True when a config file exists but could not be parsed, so rhebok left it unchanged.

### 409 Conflict Error

The agent cannot be changed now (`unparseable: false`), one of its config files exists but does not parse and was left unchanged (`unparseable: true`), or the request `Origin` is not this dashboard (only `error`).

- `DisconnectAgentRequestConflictError`
  - AgentRefusalError: AgentRefusalError
  - Error: Error

### 413 Content Too Large Error

The declared `Content-Length` is over 65,536 bytes.

- `error` (string, required) — What went wrong, in plain words.

### 421 Misdirected Request Error

The `Host` header does not name this dashboard (see the rules at the top of this page).

- `error` (string, required) — What went wrong, in plain words.

### 500 Internal Server Error

The connect or disconnect failed for another reason.

- `error` (string, required)
- `unparseable` (boolean, required) — True when a config file exists but could not be parsed, so rhebok left it unchanged.

## Types

### Agent

- `id` (enum, required)
  - Allowed values: `claude-code`, `codex`, `claude-desktop`, `cursor`, `gemini`
- `name` (string, required)
- `detected` (AgentDetected, required)
- `status` (AgentStatus, required)
- `capabilities` (AgentCapabilities, required)
- `snippet` (string, required, nullable)
- `instructions` (boolean, optional) — Present only for agents with an instructions block (Codex's `AGENTS.md`); true when it is in place.

### AgentChange

- `files` (list of string, required) — Files written.
- `backups` (list of string, required) — Backup copies kept of files that existed before.
- `notes` (list of string, required) — Steps left for you, such as trusting a hook or restarting an app.

### AgentRefusalError

- `error` (string, required)
- `unparseable` (boolean, required) — True when a config file exists but could not be parsed, so rhebok left it unchanged.

### Error

- `error` (string, required) — What went wrong, in plain words.

### AgentDetected

- `installed` (boolean, required)
- `version` (string, required, nullable)
- `config_path` (string, required, nullable)

### AgentStatus

- `state` (enum, required)
  - Allowed values: `connected`, `not_connected`, `stale`, `broken`
- `reason` (string, optional) — Present when `state` is `stale` or `broken`.

### AgentCapabilities

- `mcp` (boolean, required)
- `prompt_hook` (boolean, required)
- `session_hook` (boolean, required)
- `transcripts` (boolean, required)
- `instructions` (boolean, required)

## Examples

**Request**

```json
{
  "id": "cursor"
}
```

**Response**

```json
{
  "agent": {
    "id": "claude-code",
    "name": "string",
    "detected": {
      "installed": true,
      "version": "string",
      "config_path": "string"
    },
    "status": {
      "state": "connected",
      "reason": "string"
    },
    "capabilities": {
      "mcp": true,
      "prompt_hook": true,
      "session_hook": true,
      "transcripts": true,
      "instructions": true
    },
    "snippet": "string",
    "instructions": true
  },
  "change": {
    "files": [
      "string"
    ],
    "backups": [
      "string"
    ],
    "notes": [
      "string"
    ]
  }
}
```

**SDK Code**

```python Agents_disconnectAgent_example
import requests

url = "http://127.0.0.1:7331/api/agents/disconnect"

payload = { "id": "cursor" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Agents_disconnectAgent_example
const url = 'http://127.0.0.1:7331/api/agents/disconnect';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"id":"cursor"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Agents_disconnectAgent_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://127.0.0.1:7331/api/agents/disconnect"

	payload := strings.NewReader("{\n  \"id\": \"cursor\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Agents_disconnectAgent_example
require 'uri'
require 'net/http'

url = URI("http://127.0.0.1:7331/api/agents/disconnect")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"id\": \"cursor\"\n}"

response = http.request(request)
puts response.read_body
```

```java Agents_disconnectAgent_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://127.0.0.1:7331/api/agents/disconnect")
  .header("Content-Type", "application/json")
  .body("{\n  \"id\": \"cursor\"\n}")
  .asString();
```

```php Agents_disconnectAgent_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://127.0.0.1:7331/api/agents/disconnect', [
  'body' => '{
  "id": "cursor"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Agents_disconnectAgent_example
using RestSharp;

var client = new RestClient("http://127.0.0.1:7331/api/agents/disconnect");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"id\": \"cursor\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Agents_disconnectAgent_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["id": "cursor"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:7331/api/agents/disconnect")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```