> 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.

# Save config changes

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

Applies a patch of dotted keys to `config.toml` and returns the new
config state. Comments and key order in the file survive. Send the
`etag` from the last `GET /api/config`; if the file changed since, the
save is refused with the current etag. The save is also refused if it
would add a problem the file did not already have. `pdf.ocr_command`
cannot be set, changed or removed from the dashboard.


Reference: https://stelltec.com/rhebok/docs/api/config/save-config

## Request

### Body (application/json)

This endpoint expects a ConfigSaveRequest.

- `etag` (string, required) — The `etag` from the last `GET /api/config`.
- `set` (map from string to ConfigPatchValue, optional) — Dotted keys (`hook.threshold`) to values. A null value removes the key, the same as listing it in `unset`.
- `unset` (list of string, optional) — Dotted keys to remove, so their defaults apply again.

## Response

### 200

Saved. The body is the new config state, as `GET /api/config` returns it.

- `path` (string, required) — The path of `config.toml`.
- `exists` (boolean, required)
- `etag` (string, required) — sha256 of the file's bytes as hex, or `""` when there is no file. Send it back on save.
- `effective` (map from string to any, required) — The whole config rhebok runs with, every default filled in. Keys that look like secrets are removed. Dotted paths into this object are the keys of a save's `set`.
- `surface_weights` (ConfigViewSurfaceWeights, required) — The ranking weights the hook and MCP each use after per-surface overrides.
- `file` (map from string to any, required, nullable) — Only what `config.toml` itself sets. `{}` when there is no file, null when it does not parse.
- `defaults` (map from string to any, required) — The config with nothing set, in the same shape as `effective`.
- `errors` (list of FieldError, required) — Every problem in the file as it is now.
- `secrets` (ConfigViewSecrets, required) — Whether each secret is set. The values are never returned.
- `env_overrides` (list of EnvOverride, required) — Endpoint settings that come from the process environment, which the dashboard cannot change.
- `embed_models` (list of EmbedModelChoice, required)
- `endpoint` (EmbedEndpointState, required)

## Errors

### 400 Bad Request Error

The body is not the JSON this route expects (it does not parse, or a required field is missing or has the wrong type).

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

### 409 Conflict Error

The file changed since `etag` was read (the body carries the current `etag`), or the request `Origin` is not this dashboard (the body has only `error`).

- `SaveConfigRequestConflictError`
  - ConfigConflictError: ConfigConflictError
  - 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.

### 422 Unprocessable Entity Error

The change was not saved because it would leave the config with a new problem. `errors` lists each problem.

- `error` (string, required) — "not saved: " followed by every problem, separated by "; ".
- `errors` (list of FieldError, required)

### 500 Internal Server Error

An unexpected server-side failure, such as failing to find the running binary, spawn a process, or read or write a file.

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

## Types

### ConfigPatchValue

A TOML value as JSON. An object becomes a table; null means remove the key.

- string
- double
- integer
- boolean
- list of any
- map from string to any

### ConfigViewSurfaceWeights

The ranking weights the hook and MCP each use after per-surface overrides.

- `hook` (map from string to any, required)
- `mcp` (map from string to any, required)

### FieldError

One problem with `config.toml` or with a requested change.

- `path` (string, required) — The dotted key (`hook.threshold`), or `""` for a syntax error.
- `message` (string, required)
- `line` (integer, required, nullable) — The 1-based line in `config.toml`, or null when the problem has no single line.

### ConfigViewSecrets

Whether each secret is set. The values are never returned.

- `embed.token` (enum, required)
  - Allowed values: `set`, `unset`
- `pdf.ocr_token` (enum, required)
  - Allowed values: `set`, `unset`
- `backup.key` (enum, required)
  - Allowed values: `set`, `unset`
- `backup.drive_token` (enum, required)
  - Allowed values: `set`, `unset`

### EnvOverride

- `variable` (enum, required)
  - Allowed values: `RHEBOK_EMBED_URL`, `RHEBOK_EMBED_MODEL`, `RHEBOK_EMBED_TOKEN`
- `setting` (enum, required)
  - Allowed values: `endpoint.url`, `endpoint.model`, `embed.token`

### EmbedModelChoice

- `id` (string, required)
- `label` (string, required)
- `model` (string, required)
- `dimensions` (integer, required)
- `hook_threshold` (double, required)
- `mcp_threshold` (double, required)
- `size` (string, required)
- `min_ollama` (string, required, nullable)
- `summary` (string, required)

### EmbedEndpointState

- `backend` (enum, required)
  - Allowed values: `ollama`, `remote`
- `url` (string, required, nullable)
- `model` (string, required, nullable)
- `error` (string, required, nullable) — Why the remote endpoint settings could not be used, or null.

### ConfigConflictError

- `error` (string, required)
- `etag` (string, required) — The etag of the file as it is now. Reload with `GET /api/config` before you try again.

### Error

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

## Examples

**Request**

```json
{
  "etag": "9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c",
  "set": {
    "hook.threshold": 0.68,
    "sources": [
      "/Users/me/vault",
      "/Users/me/papers"
    ]
  },
  "unset": [
    "mcp.max_tokens"
  ]
}
```

**Response**

```json
{
  "path": "string",
  "exists": true,
  "etag": "string",
  "effective": {},
  "surface_weights": {
    "hook": {},
    "mcp": {}
  },
  "file": {},
  "defaults": {},
  "errors": [
    {
      "path": "string",
      "message": "string",
      "line": 1
    }
  ],
  "secrets": {
    "embed.token": "set",
    "pdf.ocr_token": "set",
    "backup.key": "set",
    "backup.drive_token": "set"
  },
  "env_overrides": [
    {
      "variable": "RHEBOK_EMBED_URL",
      "setting": "endpoint.url"
    }
  ],
  "embed_models": [
    {
      "id": "string",
      "label": "string",
      "model": "string",
      "dimensions": 1,
      "hook_threshold": 1.1,
      "mcp_threshold": 1.1,
      "size": "string",
      "min_ollama": "string",
      "summary": "string"
    }
  ],
  "endpoint": {
    "backend": "ollama",
    "url": "string",
    "model": "string",
    "error": "string"
  }
}
```

**SDK Code**

```python Config_saveConfig_example
import requests

url = "http://127.0.0.1:7331/api/config"

payload = {
    "etag": "9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c",
    "set": {
        "hook.threshold": 0.68,
        "sources": ["/Users/me/vault", "/Users/me/papers"]
    },
    "unset": ["mcp.max_tokens"]
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Config_saveConfig_example
const url = 'http://127.0.0.1:7331/api/config';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"etag":"9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c","set":{"hook.threshold":0.68,"sources":["/Users/me/vault","/Users/me/papers"]},"unset":["mcp.max_tokens"]}'
};

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

```go Config_saveConfig_example
package main

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

func main() {

	url := "http://127.0.0.1:7331/api/config"

	payload := strings.NewReader("{\n  \"etag\": \"9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c\",\n  \"set\": {\n    \"hook.threshold\": 0.68,\n    \"sources\": [\n      \"/Users/me/vault\",\n      \"/Users/me/papers\"\n    ]\n  },\n  \"unset\": [\n    \"mcp.max_tokens\"\n  ]\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 Config_saveConfig_example
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"etag\": \"9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c\",\n  \"set\": {\n    \"hook.threshold\": 0.68,\n    \"sources\": [\n      \"/Users/me/vault\",\n      \"/Users/me/papers\"\n    ]\n  },\n  \"unset\": [\n    \"mcp.max_tokens\"\n  ]\n}"

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

```java Config_saveConfig_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/config")
  .header("Content-Type", "application/json")
  .body("{\n  \"etag\": \"9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c\",\n  \"set\": {\n    \"hook.threshold\": 0.68,\n    \"sources\": [\n      \"/Users/me/vault\",\n      \"/Users/me/papers\"\n    ]\n  },\n  \"unset\": [\n    \"mcp.max_tokens\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://127.0.0.1:7331/api/config', [
  'body' => '{
  "etag": "9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c",
  "set": {
    "hook.threshold": 0.68,
    "sources": [
      "/Users/me/vault",
      "/Users/me/papers"
    ]
  },
  "unset": [
    "mcp.max_tokens"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Config_saveConfig_example
using RestSharp;

var client = new RestClient("http://127.0.0.1:7331/api/config");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"etag\": \"9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c\",\n  \"set\": {\n    \"hook.threshold\": 0.68,\n    \"sources\": [\n      \"/Users/me/vault\",\n      \"/Users/me/papers\"\n    ]\n  },\n  \"unset\": [\n    \"mcp.max_tokens\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Config_saveConfig_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "etag": "9b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c",
  "set": [
    "hook.threshold": 0.68,
    "sources": ["/Users/me/vault", "/Users/me/papers"]
  ],
  "unset": ["mcp.max_tokens"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:7331/api/config")! 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()
```