Replace key

Seals an engine's API key in KMS, replacing any key held.

PUT /v1/websearch/engines/{name}/key

Addresshttps://api.hanzo.ai/v1/websearch/engines/{name}/key
MethodPUT
Operationset_search_engine_key
AuthAuthorization: Bearer $HANZO_API_KEY

Seals an engine's API key in KMS, replacing any key held.

The key is the platform's: it lives in KMS under the platform org admin at /websearch/<ENGINE>_KEY (env prod), every search reads it from there at the moment it runs, and no operation returns, logs or echoes it — the answer says only that a key is now held. Only an engine that takes a key accepts one (mojeek, brave).

SuperAdmin only. 404 for an engine that does not exist, 400 for one that takes no key or a key that is empty, longer than 4096 bytes or holds whitespace or control characters, 503 when KMS cannot take it.

Request

3 fields, body application/json (required).

FieldInTypeRequiredDescription
namepathstringyesName is the engine, from the path.
keybodystring—Key is the API key.
namebodystring—Name is the engine, from the path.

Response

StatusBodyMeaning
200websearch.searchEngineKeyedok
defaultproblem-detailsrefused

200 body — 2 fields.

FieldInTypeAlwaysDescription
keyedbodyboolean—Keyed is whether a key is now held.
namebodystring—Name is the engine.

Failure carries the platform error shape — see Errors.

Examples

hanzo websearch engines key replace <name>
import { Configuration, WebsearchApi } from 'hanzoai';

const api = new WebsearchApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.setSearchEngineKey({ name: 'name', key: "<key>", name: "<name>" });
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_engine_key(name='name', key="<key>", name="<name>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.WebsearchAPI.SetSearchEngineKey(context.Background()).Execute()
if err != nil {
	return err
}
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_engine_key(&cfg, Default::default()).await?;
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).setSearchEngineKey();
curl -X PUT https://api.hanzo.ai/v1/websearch/engines/<name>/key \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "key": "<key>",
       "name": "<name>"
     }'

MCP reaches websearch through the websearch tool, which names its 3 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_search_engines"
         }
       }
     }'

Websearch API · All Hanzo APIs · Interactive reference

Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.