# Replace config

URL: https://docs.hanzo.ai/docs/openapi/gateway/put-gateway-config

> Updates one policy scope and returns the policy in force after the write.

`PUT /v1/gateway/config`

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

|               |                                          |
| ------------- | ---------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/gateway/config` |
| **Method**    | `PUT`                                    |
| **Operation** | `put_gateway_config`                     |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`   |

Updates one policy scope and returns the policy in force after the write.
A body carrying any PLATFORM field (cors\_origins, per\_ip\_rpm, window\_sec) is a
platform write and requires SuperAdmin; otherwise it is a per-org write (org\_rpm,
cache\_ttl\_sec, cache\_paths, methods) scoped to the caller's own org — or, for a
SuperAdmin, the tenant named by ?org=\<slug>. A body that sets nothing is a 400.
The abuse gate's mode is an OPERATOR field: setting it requires SuperAdmin,
whichever organization it lands on. updated\_at and updated\_by are
server-stamped; a client-supplied value is ignored.

## Request

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

| Field           | In   | Type            | Required | Description                                                                                                                                |
| --------------- | ---- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `cache_paths`   | body | object          | —        | CachePaths overrides CacheTTLSec per path PREFIX (key "/v1/models" → seconds).                                                             |
| `cache_paths.*` | body | integer (int64) | —        |                                                                                                                                            |
| `cache_ttl_sec` | body | integer (int64) | —        | CacheTTLSec is the org's default edge-cache TTL for its responses, in seconds; 0 means no caching.                                         |
| `cors_origins`  | body | string\[]       | —        | CORSOrigins is the PLATFORM-scope CORS allowlist EdgeCORS admits: an exact origin, a bare host, or a "\*.host" wildcard.                   |
| `methods`       | body | string\[]       | —        | Methods is the allowlist of HTTP methods the edge accepts for this org.                                                                    |
| `mode`          | body | string          | —        | Mode is the abuse gate's posture for THIS scope: "shadow" scores traffic and records the verdict without acting on it, "live" enforces it. |
| `org_rpm`       | body | integer (int64) | —        | OrgRPM is the org's OWN authenticated rate ceiling, requests per minute, as ScopeRateLimit enforces it.                                    |
| `per_ip_rpm`    | body | integer (int64) | —        | PerIPRPM is the PLATFORM-scope pre-auth flood cap: requests EdgeRateLimit admits per WindowSec from one client IP.                         |
| `updated_at`    | body | integer (int64) | —        | UpdatedAt is the unix second this policy row was last written.                                                                             |
| `updated_by`    | body | string          | —        | UpdatedBy is the validated user id that wrote this policy row.                                                                             |
| `window_sec`    | body | integer (int64) | —        | WindowSec is the window PerIPRPM is counted over, in seconds.                                                                              |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | gateway.Policy  | ok      |
| `default` | problem-details | refused |

`200` body — 11 fields.

| Field           | In   | Type            | Always | Description                                                                                                                                |
| --------------- | ---- | --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `cache_paths`   | body | object          | —      | CachePaths overrides CacheTTLSec per path PREFIX (key "/v1/models" → seconds).                                                             |
| `cache_paths.*` | body | integer (int64) | —      |                                                                                                                                            |
| `cache_ttl_sec` | body | integer (int64) | —      | CacheTTLSec is the org's default edge-cache TTL for its responses, in seconds; 0 means no caching.                                         |
| `cors_origins`  | body | string\[]       | —      | CORSOrigins is the PLATFORM-scope CORS allowlist EdgeCORS admits: an exact origin, a bare host, or a "\*.host" wildcard.                   |
| `methods`       | body | string\[]       | —      | Methods is the allowlist of HTTP methods the edge accepts for this org.                                                                    |
| `mode`          | body | string          | —      | Mode is the abuse gate's posture for THIS scope: "shadow" scores traffic and records the verdict without acting on it, "live" enforces it. |
| `org_rpm`       | body | integer (int64) | —      | OrgRPM is the org's OWN authenticated rate ceiling, requests per minute, as ScopeRateLimit enforces it.                                    |
| `per_ip_rpm`    | body | integer (int64) | —      | PerIPRPM is the PLATFORM-scope pre-auth flood cap: requests EdgeRateLimit admits per WindowSec from one client IP.                         |
| `updated_at`    | body | integer (int64) | —      | UpdatedAt is the unix second this policy row was last written.                                                                             |
| `updated_by`    | body | string          | —      | UpdatedBy is the validated user id that wrote this policy row.                                                                             |
| `window_sec`    | body | integer (int64) | —      | WindowSec is the window PerIPRPM is counted over, in seconds.                                                                              |

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

## Examples

**CLI**

```bash
hanzo gateway config replace
```

**SDK**

**.ts**

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

const api = new GatewayApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.putGatewayConfig({ cache_paths: {}, cache_ttl_sec: 0 });
```

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = GatewayApi(client).put_gateway_config(cache_paths={}, cache_ttl_sec=0)
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new GatewayApi(client).putGatewayConfig();
```

**HTTP**

```bash
curl -X PUT https://api.hanzo.ai/v1/gateway/config \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "cache_paths": {},
       "cache_ttl_sec": 0
     }'
```

**MCP**

MCP reaches **gateway** through the `gateway` 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:

```bash
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": "get_gateway_config"
         }
       }
     }'
```

---

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