# Replace engines

URL: https://docs.hanzo.ai/docs/openapi/websearch/set-search-engines

> Replaces the platform's web search engine setting and answers the result.

`PUT /v1/websearch/engines`

> [Websearch →](https://docs.hanzo.ai/docs/openapi/websearch) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                             |
| ------------- | ------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/websearch/engines` |
| **Method**    | `PUT`                                       |
| **Operation** | `set_search_engines`                        |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`      |

Replaces the platform's web search engine setting and answers the result.

`enabled` lists the engines searches run, in order — at least one, each a
registered engine named once, and at least one that is available (needs no key
here, or its key is held). `options` gives each engine's values by name; an
engine or a field left out takes its default, because the setting replaces the
stored one whole. A count must lie within the engine's bounds, a language is a
tag like `en` or `en-US`, a region a two-letter country code, and an option the
engine does not support is refused.

SuperAdmin only. 400 names every problem with the setting at once; 503 when
the settings store or KMS cannot answer. The answer is the engine list as it
now stands, so the caller sees the effect without a second read.

## Request

6 fields, body `application/json` (required).

| Field                | In   | Type                          | Required | Description                                                                                   |
| -------------------- | ---- | ----------------------------- | -------- | --------------------------------------------------------------------------------------------- |
| `enabled`            | body | string\[]                     | —        | Enabled are the engines searches run, in order.                                               |
| `options`            | body | object                        | —        | Options are each engine's values, by engine name — for any registered engine, enabled or not. |
| `options.*`          | body | websearch.searchEngineOptions | —        |                                                                                               |
| `options.*.count`    | body | integer (int64)               | —        | Count is how many hits the engine is asked for per search.                                    |
| `options.*.language` | body | string                        | —        | Language is the default language the engine is asked in, as a tag like `en` or `en-US`.       |
| `options.*.region`   | body | string                        | —        | Region is a two-letter country code the engine favours, like `GB`.                            |

## Response

| Status    | Body                    | Meaning |
| --------- | ----------------------- | ------- |
| `200`     | websearch.searchEngines | ok      |
| `default` | problem-details         | refused |

`200` body — 19 fields.

| Field                          | In   | Type                            | Always | Description                                                                                                                       |
| ------------------------------ | ---- | ------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `engines`                      | body | websearch.searchEngine\[]       | —      | Engines are the enabled engines in the order they run, then the rest by name.                                                     |
| `engines[].acceptsKey`         | body | boolean                         | —      | AcceptsKey is whether the engine takes an API key at all.                                                                         |
| `engines[].available`          | body | boolean                         | —      | Available is whether the engine answers from this cluster as things stand: it needs no key there (bing, ddg), or its key is held. |
| `engines[].enabled`            | body | boolean                         | —      | Enabled is whether searches run it.                                                                                               |
| `engines[].keyed`              | body | boolean                         | —      | Keyed is whether the platform holds a key for it in KMS.                                                                          |
| `engines[].name`               | body | string                          | —      | Name is the engine: `mojeek`, `bing`, `brave` or `ddg`.                                                                           |
| `engines[].needsKey`           | body | boolean                         | —      | NeedsKey is whether the engine answers only with a key.                                                                           |
| `engines[].options`            | body | websearch.searchEngineOptions   | —      |                                                                                                                                   |
| `engines[].options.count`      | body | integer (int64)                 | —      | Count is how many hits the engine is asked for per search.                                                                        |
| `engines[].options.language`   | body | string                          | —      | Language is the default language the engine is asked in, as a tag like `en` or `en-US`.                                           |
| `engines[].options.region`     | body | string                          | —      | Region is a two-letter country code the engine favours, like `GB`.                                                                |
| `engines[].order`              | body | integer (int64)                 | —      | Order is its place among the enabled engines, from 1; 0 when disabled.                                                            |
| `engines[].supports`           | body | websearch.searchEngineOption\[] | —      | Supports lists the options the engine reads, with each one's bounds.                                                              |
| `engines[].supports[].default` | body | integer (int64)                 | —      | Default is the count used when none is set.                                                                                       |
| `engines[].supports[].max`     | body | integer (int64)                 | —      | Max is the most count the engine accepts.                                                                                         |
| `engines[].supports[].min`     | body | integer (int64)                 | —      | Min is the least count the engine accepts.                                                                                        |
| `engines[].supports[].name`    | body | string                          | —      | Name is the option: `count`, `language` or `region`.                                                                              |
| `engines[].supports[].param`   | body | string                          | —      | Param is the engine's own query parameter the option sets, such as `t` or `rb` for Mojeek.                                        |
| `saved`                        | body | boolean                         | —      | Saved is whether a setting is stored.                                                                                             |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo websearch engines replace
```

**SDK**

**.ts**

```ts
import { Configuration, WebsearchApi } from 'hanzoai';

const api = new WebsearchApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.setSearchEngines({ enabled: ["<enabled>"], options: {} });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import WebsearchApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = WebsearchApi(client).set_search_engines(enabled=["<enabled>"], options={})
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.WebsearchAPI.SetSearchEngines(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, websearch_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = websearch_api::set_search_engines(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.WebsearchApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new WebsearchApi(client).setSearchEngines();
```

**HTTP**

```bash
curl -X PUT https://api.hanzo.ai/v1/websearch/engines \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "enabled": [
         "<enabled>"
       ],
       "options": {}
     }'
```

**MCP**

Tool `websearch`, op `set_search_engines` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "websearch",
         "arguments": {
           "op": "set_search_engines",
           "input": {
             "enabled": [
               "<enabled>"
             ],
             "options": {}
           }
         }
       }
     }'
```

---

[Websearch API](https://docs.hanzo.ai/docs/openapi/websearch) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
