Claude apps gateway configuration
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1020,7 +1020,7 @@
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
`managedMcpServers`| CLI| Remote MCP servers [provided to every matching developer](</docs/en/managed-mcp#provide-servers-through-managed-settings>) alongside the servers they add themselves, `http` and `sse` only. See MCP servers in a policy. Requires Claude Code v2.1.259 or later on the gateway server and on clients. Earlier clients ignore the key.
-Because these settings arrive over the network, the CLI shows each developer a security approval dialog before applying the settings listed below:
+Because these settings arrive over the network, the CLI shows each developer a security approval dialog before applying settings such as the following:
* `hooks`
* `env` variables that require the developer’s approval, such as proxy and base-URL variables
@@ -1036,7 +1036,12 @@
#### Context window in terminal sessions
-Terminal sessions signed in through `/login` use the 1M context window for Opus 4.7 and later, Sonnet 5 and later, and the Fable models. The model ID needs no `[1m]` suffix, and sessions compact at about 967K tokens. Before Claude Code v2.1.287 on the developer’s machine, Claude Code treated the Opus and Fable models as having a 200K window unless the model ID ended in `[1m]`. To have terminal sessions compact at the 200K boundary instead, set the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) in the policy’s `env`:
+Terminal sessions signed in through `/login` use the 1M context window for Opus 4.7 and later, Sonnet 5 and later, and the Fable models. By default, sessions compact near the [auto-compact window tuned for the model](</docs/en/model-config#compaction-near-400k-on-a-1m-model>), which is 400K tokens on current models. To get these defaults on a machine with an older Claude Code version, have the developer update:
+
+ * **Before v2.1.334** : sessions with the 1M window compacted at about 967K tokens
+ * **Before v2.1.287** : Claude Code treated the Opus and Fable models as having a 200K window unless the model ID ended in `[1m]`
+
+To keep the full window in these sessions, put the [`modelSettings` entries for your organization](</docs/en/model-config#compaction-near-400k-on-a-1m-model>) in the policy’s `cli` block. To have terminal sessions compact at the 200K boundary instead, set the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) in the policy’s `env`:
managed:
policies:
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -451,10 +451,10 @@
`region`| Yes| AWS region. The gateway derives the endpoint from it as `https://bedrock-mantle.<region>.api.aws/anthropic`.
`models`| Yes| The models your AWS account has been granted on Mantle, named as clients send them, such as `claude-haiku-4-5`. Only these go to this upstream, and every other model skips to the next one.
`auth`| No| Takes the same keys as the Amazon Bedrock upstream’s `auth` block, under the same rules.
-`assume_role`| No| The role that this upstream’s requests go through, with the same keys as on a `bedrock` upstream, including `session_name` for per-developer attribution. Give the role Mantle’s IAM actions. Requires a gateway running Claude Code v2.1.318 or later. An earlier gateway exits at startup with `Unrecognized key(s) in object: 'assume_role'`.
+`assume_role`| No| The role that this upstream’s requests go through, with the same keys as on a `bedrock` upstream, including `session_name` for per-developer attribution. Requires a gateway running Claude Code v2.1.318 or later. An earlier gateway exits at startup with `Unrecognized key(s) in object: 'assume_role'`.
`base_url`| No| Override the derived endpoint. Keep the `/anthropic` path at the end.
-Grant the upstream’s AWS identity Mantle’s own IAM actions for inference and token counting, which [Use the Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) lists. For a Mantle model ID that the gateway doesn’t know, add an entry to the top-level `models:` block whose `upstream_model` maps this upstream’s name to that ID. Then put that entry’s `id` in this upstream’s `models` field too. A `bedrock` upstream’s `guardrail` and `assume_role` settings don’t extend to the requests Mantle serves:
+Grant [Mantle’s IAM actions](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) to the `assume_role` role if you set one, otherwise to the upstream’s AWS identity. For a Mantle model ID that the gateway doesn’t know, add an entry to the top-level `models:` block whose `upstream_model` maps this upstream’s name to that ID. Then put that entry’s `id` in this upstream’s `models` field too. A `bedrock` upstream’s `guardrail` and `assume_role` settings don’t extend to the requests Mantle serves:
* **`guardrail`** : the gateway applies no Bedrock guardrail to requests it sends to Mantle, so it refuses to start when a `mantle` upstream is listed while any `bedrock` upstream sets `guardrail`.
* **`assume_role`** : set it on the `mantle` upstream itself. Without it, requests that Mantle serves are sent with the `mantle` upstream’s own `auth` credentials.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1176,10 +1176,10 @@
To change what the picker offers, use one of these:
- * **Start users on the 1M option** : set `modelPrefer1mContext: true` in the policy’s `desktop` block. Users who haven’t yet chosen a model start on the 1M option when the first listed model has one. Users who already chose a model keep their choice.
+ * **Show only the 1M option** : set [`modelPrefer1mContext`](<https://claude.com/docs/third-party/claude-desktop/configuration#modelprefer1mcontext>) to `true` in the policy’s `desktop` block. You need Claude Desktop 2.31226.0 or later on members’ machines.
* **Offer the option by hand** : do this if your gateway server runs a version older than v2.1.284, or an entry names no Claude model. List the model twice in `models`, once with its plain ID and once with `[1m]` appended, both with the same `upstream_model` map. Claude Desktop shows the pair as one model with a 1M option. The gateway serves a `[1m]` entry without checking it, so add one only for a model your upstreams serve at 1M.
-This example offers the option by hand for a custom alias routed to an application inference profile, and starts new users on it:
+This example lists a custom alias and its `[1m]` variant, both routed to an application inference profile, and sets `modelPrefer1mContext`:
models:
- id: corp-sonnet
@@ -1325,10 +1325,16 @@
`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how to size it. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`. It is what stops someone from guessing another developer’s code. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how far to raise it.
-If you leave both `access_control` lists empty, which is the default, the gateway serves any client address, so only your network restricts who can reach it. That matters because a gateway can push managed settings that run commands on developer machines. While `allow_cidrs` is empty, the gateway warns in two places, without changing how it answers any request:
-
- * **At boot** : a warning in the operational log recommends allowing only the private ranges `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `100.64.0.0/10`, `127.0.0.0/8`, `::1/128`, and `fc00::/7`, plus any other internal ranges your developers connect from. If you bind the gateway to a loopback address and set neither `trusted_proxies` nor `public_url`, as in local development, the warning doesn’t appear.
- * **At runtime** : the first time a request arrives from an address outside those private ranges, the gateway logs a warning and emits an [`access.public_client` audit event](</docs/en/claude-apps-gateway-deploy#logs>) carrying the client IP. Both fire once per process. Link-local addresses, `169.254.0.0/16` and `fe80::/10`, don’t count as public. The gateway answers `/healthz` and `/readyz` before this check runs, so health probes from public ranges don’t trigger it.
+If you leave both `access_control` lists empty, which is the default, the gateway serves any client address, so only your network restricts who can reach it. That matters because a gateway can push managed settings that run commands on developer machines. To refuse clients from outside your network, set `allow_cidrs` to these private ranges, plus any other internal ranges your developers connect from:
+
+ * **IPv4** : `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `100.64.0.0/10`, and `127.0.0.0/8`
+ * **IPv6** : `::1/128` and `fc00::/7`
+
+While `allow_cidrs` is empty, the gateway watches for requests from outside the private ranges above, without changing how it answers them:
+
+ * **Once per process** : when it serves such a request, the gateway logs a warning and emits an [`access.public_client` audit event](</docs/en/claude-apps-gateway-deploy#logs>) carrying the client IP.
+ * **Not counted as public** : link-local addresses, `169.254.0.0/16` and `fe80::/10`.
+ * **Not checked** : health probes to `/healthz` and `/readyz`, which the gateway answers before this check runs.
Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. If the relay belongs in `listen.trusted_proxies`, list it there. Keep the gateway and everything in front of it unreachable from the public internet regardless.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -8,7 +8,7 @@
* `oidc`: your identity provider (IdP), including issuer, client, claim mapping, and who may sign in
* `session`: the bearer tokens the gateway mints, with secret and lifetime
* `store`: PostgreSQL, for device grants and rate-limit counters
- * `upstreams`: where inference goes, whether Anthropic, Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, or Microsoft Foundry
+ * `upstreams`: where inference goes, whether Anthropic, Amazon Bedrock, Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed), Google Cloud’s Agent Platform, or Microsoft Foundry
**Optional sections:**
@@ -149,7 +149,7 @@
---|---|---
`provider: anthropic` upstreams, Workload Identity Federation token exchange, `telemetry.forward_to` exports| Resolved and checked locally, then `CONNECT` to the checked IP address through the proxy. A telemetry collector listed in `NO_PROXY` is reached directly instead| Hostname handed to the proxy
IdP discovery, JWKS, token, and userinfo| Direct unless `oidc.use_proxy: true`, then `CONNECT` to the checked IP address| Hostname handed to the proxy, unless `oidc.use_proxy: false` keeps an internal IdP direct
-Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry upstreams; Google group lookups| Hostname handed to the proxy| Unchanged
+Amazon Bedrock, Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed), Google Cloud’s Agent Platform, and Microsoft Foundry upstreams; Google group lookups| Hostname handed to the proxy| Unchanged
Proxy-only egress stays off unless the gateway’s environment meets all three of these conditions:
@@ -491,6 +491,20 @@
`base_url`| No| Override the derived endpoint
Because the platform resolves first-party model IDs, the built-in catalog routes to it with no `models:` block. When you curate a `models:` list, key the entry `anthropicAws:` with the first-party ID.
+
+#### Claude Models on Google Cloud (Anthropic managed)
+
+Claude Models on Google Cloud (Anthropic managed) is the Anthropic-operated Claude API, reached through your Google Cloud project. To send model requests to it, add an upstream with the `anthropicGoogleCloud` provider. Before you add the upstream, upgrade your gateway replicas to Claude Code v2.1.307 or later and [set up the service in a Google Cloud project](<https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#set-up-your-account>). Grant `roles/claude.user` on that project to the identity that the gateway’s Google credentials resolve to.
+
+ upstreams:
+ - provider: anthropicGoogleCloud
+ project_id: example-prod
+ workspace_id: wrkspc_01ABCDEFGHIJKLMN
+ auth: {} # Google credentials, not an API key; {} uses Application Default Credentials
+ # OR the path to a service account key file:
+ # auth: { service_account_json: /secrets/sa.json }
+
+Both `project_id` and `workspace_id` are required: `project_id` is the ID of the project where you set up the service, and you can [find the `wrkspc_` ID](<https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#find-your-workspace-id>) in the Claude Console.
#### Google Cloud Agent Platform
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -2,7 +2,7 @@
## File structure
-Five sections are required. Every other section is optional, and an omitted section takes its defaults. Unknown keys fail boot, so a typo surfaces as a named error rather than a silently ignored setting. **Required sections:**
+Five sections are required. Every other section is optional, and an omitted section takes its defaults. **Required sections:**
* `listen`: bind address, public URL, TLS termination
* `oidc`: your identity provider (IdP), including issuer, client, claim mapping, and who may sign in
@@ -419,6 +419,8 @@
By default the gateway signs every Bedrock request with one credential, so AWS sees all developers’ requests under a single IAM principal. Add `session_name: email` to `assume_role` and the gateway calls `sts:AssumeRole` once per developer per hour, with the session name set to that developer’s email, and signs their requests with the returned credentials, so each developer’s requests reach AWS under their own assumed-role session. The role can be in the gateway’s own account. Requires a gateway running Claude Code v2.1.281 or later. [Cost attribution on AWS](</docs/en/claude-apps-gateway-on-aws#cost-attribution>) covers the IAM role and where AWS billing shows the sessions.
+For per-developer attribution, set `assume_role` with `session_name` on every `bedrock` and `mantle` upstream except those that use `aws_bearer_token`. Those can’t take `assume_role`, so their requests stay under one principal.
+
upstreams:
- provider: bedrock
region: us-east-1
@@ -427,7 +429,7 @@
role_arn: arn:aws:iam::123456789012:role/claude-gateway-bedrock-user
session_name: email # or sub
-`session_name` selects which verified claim becomes the AWS `RoleSessionName`: `email` or `sub`. The gateway writes any character other than ASCII letters, digits, and `_+,.@-` as `=XX` hex per UTF-8 byte, and shortens a result longer than 64 characters to a prefix plus a hash, so each developer’s session name stays valid and unique. A request from a developer whose token lacks the claim isn’t sent through this upstream, and the operator log says to switch to `sub` or set `oidc.email_claim`. An active developer costs one STS call per hour per gateway replica, and concurrent first requests share one call. The gateway also makes one call of its own on this role: the token count for a request the client abandoned, so that [spend limits](</docs/en/claude-apps-gateway-spend-limits>) stay accurate. That count and its one-token fallback request are signed by the shared `claude-apps-gateway` session, so AWS attributes the fallback to `claude-apps-gateway` rather than to the developer. For strict per-developer attribution, set `assume_role` with `session_name` on every Bedrock upstream you list. An upstream without it signs the requests it serves with its own credentials.
+`session_name` selects which verified claim becomes the AWS `RoleSessionName`: `email` or `sub`. The gateway writes any character other than ASCII letters, digits, and `_+,.@-` as `=XX` hex per UTF-8 byte, and shortens a result longer than 64 characters to a prefix plus a hash, so each developer’s session name stays valid and unique. A request from a developer whose token lacks the claim isn’t sent through this upstream, and the operator log says to switch to `sub` or set `oidc.email_claim`. An active developer costs one STS call per hour per gateway replica, and concurrent first requests share one call. The gateway also makes one call of its own on this role: the token count for a request the client abandoned, so that [spend limits](</docs/en/claude-apps-gateway-spend-limits>) stay accurate. That count and its one-token fallback request are signed by the shared `claude-apps-gateway` session, so AWS attributes the fallback to `claude-apps-gateway` rather than to the developer.
#### Amazon Bedrock Mantle endpoint
@@ -1031,6 +1033,8 @@
Claude Code applies this variable without showing the developer the approval dialog. The variable applies to every model, including model IDs that end in `[1m]`. To turn off 1M context instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"`](</docs/en/model-config#extended-context>) in the same `env` block. Claude Code then treats every model as having a 200K window. In interactive sessions, each developer approves this variable in the approval dialog before it takes effect.
+Claude Code doesn’t read an alias’s `upstream_model` to size its context window. To give its model’s window to an alias in `models` that Claude Code doesn’t recognize, see [Correct the window for a gateway or custom model ID](</docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id>).
+
#### One-hour prompt cache
To request the one-hour [prompt cache TTL](</docs/en/prompt-caching#cache-lifetime>) instead of the default five minutes, add these keys to a policy’s existing `code`, `cli`, or `settings` block and restart the gateway. The keys need Claude Code v2.1.242 or later on the gateway server and on clients. `promptCacheTtl` covers the main conversation. `subagentPromptCacheTtl` is optional and covers subagents, workflows, and background requests. This example adds both to a `match: {}` policy keyed `cli`:
@@ -1071,7 +1075,7 @@
##### Apply `code` settings in the Code tab
-The Claude Code settings a policy holds under its `code` key apply in Claude Desktop’s Code tab when all of these hold:
+Apart from [some provider and model variables](</docs/en/desktop#managed-settings>), the Claude Code settings a policy holds under its `code` key apply in Claude Desktop’s Code tab when all of these hold:
* The policy also has a `desktop` key, and an empty `desktop: {}` counts
* Claude Desktop is version 2.9939.2 or later
@@ -1105,18 +1109,27 @@
##### What the gateway rejects at boot
-The gateway validates each `desktop` block at boot against the configuration schema Claude Desktop itself uses, so a mistake surfaces at gateway start as an error naming the key rather than reaching every connected desktop. The gateway fails at boot when a block contains:
-
- * An unknown key
- * A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value or a misspelled sub-key inside a nested entry. Before v2.1.260, the gateway silently dropped a misspelled field inside a nested object of a `managedMcpServers` or `orgPluginSettings` entry instead of failing at boot.
+The gateway fails at boot when a `desktop` block contains:
+
+ * A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value.
* A key the gateway computes itself: the inference connection, the model list, and the OTLP relay. Configure those through `upstreams`, `models`, and the `telemetry` section’s `forward_to`.
* A legacy alias of a current key. In the boot error, the gateway names the canonical key to write.
+ * From v2.1.300, any key whose name starts with `selfHosted`, such as the keys for a self-hosted session host. Remove these keys before you upgrade the gateway to v2.1.300 or later.
If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
+##### Keys the gateway doesn’t know
+
+On a gateway running Claude Code v2.1.295 or later, most keys from a newer Claude Desktop release need no gateway upgrade. On v2.1.321 or later, neither do most new sub-keys inside a known key. Some keys and values still fail at boot, such as these:
+
+ * A new choice in a known key’s fixed list of values.
+ * A likely typo of a key you can set in a `desktop` block, such as `disable_auto_updates` for `disableAutoUpdates`. The error suggests a name.
+
+In each case, if the name or value is real in a newer Claude Desktop release, [upgrade the gateway](</docs/en/claude-apps-gateway-deploy#upgrades>) to the latest release. Otherwise correct or remove it. To find out before you deploy, test the policy.
+
##### Keys that need a later gateway or Claude Desktop version
-The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key.
+`userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key.
[`sshTransport`](<https://claude.com/docs/third-party/claude-desktop/configuration#sshtransport>) needs Claude Code v2.1.293 or later on the gateway server.
Show diff (706 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1,10 +1,6 @@
A Claude apps gateway deployment is configured by one YAML file, conventionally `gateway.yaml`. The file defines everything the gateway does: where it listens, how developers sign in, where inference goes, and which policies and telemetry apply. This page is the reference for every option in that file. To write your first one, start from the [quickstart](</docs/en/claude-apps-gateway#quickstart>), which builds a minimal working config and runs it. Once you have a config you’re happy with, the [deployment guide](</docs/en/claude-apps-gateway-deploy>) covers containerizing and hosting it on Kubernetes, Cloud Run, or your own platform. The gateway reads the file once, at startup, with `claude gateway --config /path/to/gateway.yaml`. Every option is validated against a schema at boot, so a malformed config fails at start with a field-level error rather than at first use. The complete example at the end of this page exercises every section.
-##
-
-
-
-File structure
+## File structure
Five sections are required. Every other section is optional, and an omitted section takes its defaults. Unknown keys fail boot, so a typo surfaces as a named error rather than a silently ignored setting. **Required sections:**
@@ -26,11 +22,7 @@
* `access_control`, `limits`, `timeouts`, `rate_limits`: IP allow/deny, request size caps, upstream time-to-first-byte, and per-IP sign-in limits
* `load_test_mode`: load testing the gateway without calling a model provider
-##
-
-
-
-Secret expansion
+## Secret expansion
Don’t write secrets such as `client_secret`, `jwt_secret`, or `postgres_url` directly in `gateway.yaml`. Reference them with one of the forms below, and the gateway resolves the value at boot from an environment variable or a file:
@@ -39,17 +31,9 @@
`${VAR}`| The environment variable `VAR`. Boot fails if undefined.| Container environment variables, AWS Secrets Manager via env injection
`${file:/path}`| Contents of the file at that absolute path, trimmed. The reference must be the field’s entire value: unlike `${VAR}`, it isn’t expanded inside a longer string, so for a database password set `store.password` rather than embedding it in `postgres_url`.| Kubernetes Secret volume mounts, Vault Agent, SOPS
-##
-
-
-
-Required sections
-
-###
-
-
-
-`listen`
+## Required sections
+
+### `listen`
The `listen` block controls where the gateway serves: the bind address and port, the externally visible origin, and optional TLS termination.
@@ -63,11 +47,7 @@
List a frontend in `trusted_proxies` only if the last `X-Forwarded-For` entry that it passes on is one that no developer wrote. List no address or range that developers connect from. A frontend that appends the address of each connection it receives qualifies. One that passes the header on as developers send it doesn’t. `X-Forwarded-For` entries written as `ipv4:port` or `[ipv6]:port`, as some load balancers do, are read with the port dropped. An IPv6 address with a port appended and no brackets may be read as a different address or not read at all. Turn off the port option on any proxy that writes that form.
-###
-
-
-
-`oidc`
+### `oidc`
The `oidc` block connects the gateway to your identity provider and decides who can sign in. It names the issuer and OAuth client, maps the claims that carry email and groups, and restricts sign-in by email domain or group. OpenID Connect (OIDC) is the SSO protocol the gateway uses with your identity provider; see [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for what to register on the IdP side.
@@ -96,11 +76,7 @@
`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
`ca_cert_pem`| No| The PEM-encoded CA certificate itself, not a path to a file. It replaces the system trust store for IdP requests only. To load a mounted file, write `${file:/etc/gateway/idp-ca.pem}`. Use for Keycloak or Dex behind corporate PKI.
-####
-
-
-
-Certificate client authentication
+#### Certificate client authentication
If your identity provider authenticates OAuth clients with a certificate instead of a client secret, as Microsoft Entra does with certificate credentials, set `token_endpoint_auth_method: private_key_jwt`. Requires Claude Code v2.1.284 or later on the gateway server. With this configuration the gateway sends no secret. It authenticates to the IdP’s token endpoint with a short-lived JWT signed with the certificate’s private key when a developer signs in and each time the gateway refreshes their session. The JWT is signed with RS256 and identifies the certificate by `x5t` and `x5t#S256` thumbprint headers rather than a `kid`. Your IdP must be able to find the registered certificate by thumbprint.
@@ -146,11 +122,7 @@
Compare the SHA-1 thumbprint with the one the IdP shows for the certificate you uploaded. If the certificate has expired or isn’t valid yet, the gateway still starts but logs a warning that sign-ins and refreshes will fail until you replace it. To confirm that the IdP accepts the certificate, have one developer sign in through the gateway.
-####
-
-
-
-Rotate the client certificate
+#### Rotate the client certificate
The gateway reads the key and certificate once at boot, so a changed file takes effect only after a restart. Rotate in this order so that no token request presents a certificate the IdP doesn’t have:
@@ -158,19 +130,11 @@
2. Replace the key and certificate files that `gateway.yaml` loads, then restart the gateway. If you run several replicas, a [rolling restart](</docs/en/claude-apps-gateway-deploy#upgrades>) works, because the IdP has both certificates until you remove the old one.
3. After every replica has restarted, remove the old certificate from the IdP.
-####
-
-
-
-IdP requests through a forward proxy
+#### IdP requests through a forward proxy
The inference upstreams honor `HTTPS_PROXY` and `HTTP_PROXY` on every version. The gateway’s own requests to the IdP, discovery, JWKS, token, and userinfo, go direct unless you set `oidc.use_proxy: true`, which requires v2.1.227 or later. When a proxy variable is set, `use_proxy` is unset, and the issuer isn’t covered by `NO_PROXY`, the gateway keeps those requests direct and logs a notice at boot asking you to choose; `use_proxy: false` keeps them direct and silences the notice. With `use_proxy: true`, the pod resolves each IdP endpoint’s hostname itself and asks the proxy to `CONNECT` to the resolved IP address, so the proxy must accept `CONNECT` to the IP address of every host the discovery document names, not only the issuer. Use an `http://` proxy URL. `ca_cert_pem` and the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) apply on the proxied path as well. Proxy-only egress changes both of these: while it’s active, IdP requests follow the proxy unless you set `use_proxy: false`, and the gateway hands the proxy each IdP hostname without resolving it first.
-####
-
-
-
-Proxy-only egress
+#### Proxy-only egress
Set `CLAUDE_GATEWAY_PROXY_IS_EGRESS_BOUNDARY=1` in the gateway’s environment, next to `HTTPS_PROXY`, when the pod reaches other hosts only through that forward proxy and can’t resolve public DNS names itself, or when the proxy refuses `CONNECT` to an IP address. Requires v2.1.277 or later. It’s an environment variable rather than a `gateway.yaml` key so that nothing in the config file can relax the gateway’s address check.
@@ -197,11 +161,7 @@
Turn this on only when the proxy’s allowlist is at least as strict as the gateway’s own check. The proxy must refuse cloud metadata endpoints such as `169.254.169.254` and `metadata.google.internal`, link-local addresses, and the proxy host’s own loopback, and it must refuse them by the address a name resolves to, not only by name, because the gateway no longer catches a hostname that resolves to one of them. A proxy that connects anywhere it’s asked removes the gateway’s [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) for these requests.
-###
-
-
-
-`session`
+### `session`
The `session` block shapes the bearer tokens the gateway mints after sign-in: the secret that signs them and how long they live.
@@ -210,11 +170,7 @@
`jwt_secret`| Yes| At least 32 bytes of entropy, for example from `openssl rand -base64 32`. Signs the gateway’s HS256 bearer tokens. Accepts a single string or an array for rotation: index 0 signs and all entries verify. To rotate, prepend a new secret, wait `ttl_hours`, then drop the old one.
`ttl_hours`| No| Gateway bearer token lifetime. Default `1`. The CLI silently refreshes before expiry when the IdP issues refresh tokens. A shorter lifetime deprovisions faster; a longer one makes fewer IdP round-trips. If your IdP can’t issue refresh tokens because `offline_access` is unavailable, there is no silent refresh, so raise this to `8` or `12` to avoid sending developers back to the browser login every hour.
-###
-
-
-
-`store`
+### `store`
The `store` block points the gateway at its PostgreSQL database, which holds device grants and rate-limit counters.
@@ -229,19 +185,11 @@
For local development, point `postgres_url` at a throwaway Postgres container, for example `docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres`.
-###
-
-
-
-`upstreams`
+### `upstreams`
`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model, passing over any upstream whose `groups` list leaves the developer out. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the upstream rejected the credential the gateway used, or denied it access, for example to the requested model. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
-####
-
-
-
-Upstream error messages
+#### Upstream error messages
The gateway returns one upstream’s error response, or its own `502`, depending on how the upstreams answered:
@@ -256,11 +204,7 @@
For example, the gateway replaces Amazon Bedrock’s `Input is too long for requested model.` with `capability_rejected: prompt_too_long`. Claude Code [compacts automatically](</docs/en/errors#prompt-is-too-long>) on that token, as it does on `prompt is too long`. Keeping a cloud upstream’s `400` or `413` message, or replacing it with a `capability_rejected:` token, requires gateway v2.1.233 or later.
-####
-
-
-
-Anthropic API
+#### Anthropic API
The minimal Anthropic upstream is an API key from the [Claude Console](<https://platform.claude.com>):
@@ -311,11 +255,7 @@
If you set `forward_user_identity` on an Amazon Bedrock upstream, the gateway exits at startup with `Unrecognized key(s) in object: 'forward_user_identity'`. If your proxy sits in front of Bedrock, list it as a `provider: anthropic` upstream instead. The gateway sends that upstream the Anthropic Messages format, so your proxy has to [translate requests for Bedrock](</docs/en/llm-gateway-protocol#format-mismatch-with-the-upstream>). To name each developer to AWS instead, see Per-developer AWS cost attribution.
-####
-
-
-
-Amazon Bedrock
+#### Amazon Bedrock
For the client-side Amazon Bedrock deployment that the gateway replaces or fronts, see [Claude Code on Amazon Bedrock](</docs/en/amazon-bedrock>). The gateway-side upstream:
@@ -489,11 +429,7 @@
`session_name` selects which verified claim becomes the AWS `RoleSessionName`: `email` or `sub`. The gateway writes any character other than ASCII letters, digits, and `_+,.@-` as `=XX` hex per UTF-8 byte, and shortens a result longer than 64 characters to a prefix plus a hash, so each developer’s session name stays valid and unique. A request from a developer whose token lacks the claim isn’t sent through this upstream, and the operator log says to switch to `sub` or set `oidc.email_claim`. An active developer costs one STS call per hour per gateway replica, and concurrent first requests share one call. The gateway also makes one call of its own on this role: the token count for a request the client abandoned, so that [spend limits](</docs/en/claude-apps-gateway-spend-limits>) stay accurate. That count and its one-token fallback request are signed by the shared `claude-apps-gateway` session, so AWS attributes the fallback to `claude-apps-gateway` rather than to the developer. For strict per-developer attribution, set `assume_role` with `session_name` on every Bedrock upstream you list. An upstream without it signs the requests it serves with its own credentials.
-####
-
-
-
-Amazon Bedrock Mantle endpoint
+#### Amazon Bedrock Mantle endpoint
The `mantle` provider sends inference to Amazon Bedrock’s [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>). It requires Claude Code v2.1.283 or later on the gateway server. Earlier gateway releases reject it at boot, so upgrade every replica before adding it. The example below puts Mantle first, with an Amazon Bedrock upstream behind it to serve every model the `models` field leaves out:
@@ -523,11 +459,7 @@
For what Mantle’s own error responses mean, see [Mantle endpoint errors](</docs/en/amazon-bedrock#mantle-endpoint-errors>).
-####
-
-
-
-Claude Platform on AWS
+#### Claude Platform on AWS
Claude Platform on AWS serves the first-party Anthropic API on AWS infrastructure at `aws-external-anthropic.<region>.api.aws`. It uses first-party model IDs, honors `anthropic-beta` headers as sent, and serves `count_tokens`, so none of the Bedrock-specific translation applies. The `anthropicAws` provider requires Claude Code v2.1.198 or later; earlier gateway releases reject it at boot. For the client-side deployment of the same platform, see [Claude Code on Claude Platform on AWS](</docs/en/claude-platform-on-aws>). The gateway-side upstream:
@@ -558,11 +490,7 @@
Because the platform resolves first-party model IDs, the built-in catalog routes to it with no `models:` block. When you curate a `models:` list, key the entry `anthropicAws:` with the first-party ID.
-####
-
-
-
-Google Cloud Agent Platform
+#### Google Cloud Agent Platform
For the equivalent client-side setup, see [Claude Code on Google Cloud](</docs/en/google-vertex-ai>). The gateway-side upstream:
@@ -586,11 +514,7 @@
Cloud Run / GCE| Set the service’s service account to one with `roles/aiplatform.user`. `auth: {}` picks it up.
Anywhere else| `auth: { service_account_json: /secrets/sa.json }`, the path to a JSON key file mounted as a secret. The field takes a file path, not the key contents, so no `${file:…}` expansion is involved.
-####
-
-
-
-Microsoft Foundry
+#### Microsoft Foundry
For the client-side Microsoft Foundry deployment, see [Claude Code on Microsoft Foundry](</docs/en/microsoft-foundry>). The gateway-side upstream:
@@ -606,17 +530,13 @@
Setup| How
---|---
-RBAC| Grant the gateway’s identity `Azure AI User` or `Cognitive Services User` on the Microsoft Foundry resource
+RBAC| Grant the gateway’s identity the `Foundry User` or `Cognitive Services User` role on the Microsoft Foundry resource
Deployments| Microsoft Foundry uses admin-chosen deployment names, not canonical model IDs. Add a `models:` block mapping each canonical ID to your deployment name.
AKS (workload identity)| Federate a User-Assigned Managed Identity with the cluster’s OIDC issuer and bind it to the gateway’s service account. `use_azure_ad: true` picks it up via `WorkloadIdentityCredential`.
ACI / App Service| Enable system-assigned or user-assigned managed identity on the resource. `use_azure_ad: true` picks it up.
Anywhere else| `auth: { api_key: "${FOUNDRY_API_KEY}" }`. Quote `${…}` inside `{ }`.
-####
-
-
-
-Static headers on upstream requests
+#### Static headers on upstream requests
To add fixed headers to the requests the gateway sends to one upstream, set `headers:` on that upstream. Use it when a proxy you run in front of the provider routes or attributes traffic by a header. `headers:` requires Claude Code v2.1.277 or later on the gateway server. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. The headers go to the server that `base_url` names, or to the provider’s own endpoint when `base_url` is unset. The provider receives them too unless your proxy removes them. This example reaches a `provider: vertex` upstream through a proxy at `upstream-proxy.internal.example.com`. It sets the `x-source` header the proxy reads, and sends a token from the `PROXY_TOKEN` environment variable as `x-proxy-token`:
@@ -645,11 +565,7 @@
* `host`, `content-type`, and `user-agent`
* Any name starting with `anthropic-`, `x-goog-`, `x-amz-`, or `x-amzn-`
-####
-
-
-
-Multiple upstreams
+#### Multiple upstreams
The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. A request moves past an upstream only in these cases:
@@ -710,11 +626,7 @@
Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so by default failover doesn’t send a body field an upstream would reject. If you set the one-hour cache TTL in a policy, it goes to every upstream in the list, so set it only if all of them accept it.
-####
-
-
-
-Send each team to its own upstream
+#### Send each team to its own upstream
To send each team’s requests to its own AWS account or Google Cloud project, list one upstream per team and give each one a `groups` list. Only developers in a listed IdP group reach that upstream, on the first try and on failover. Every provider takes `groups`. Requires Claude Code v2.1.314 or later on the gateway server. This example gives the `payments-eng` and `search-eng` groups an AWS account each, and adds an upstream with no `groups` list that every developer can use:
@@ -768,17 +680,9 @@
If your IdP’s userinfo endpoint returns the groups claim and `oidc.google_groups` isn’t set, set `oidc.userinfo_fallback` to `true` to fill in the groups from there.
-##
-
-
-
-Optional sections
-
-###
-
-
-
-`login_notice`
+## Optional sections
+
+### `login_notice`
To show developers a notice when they sign in, set the top-level `login_notice` key to the notice text, up to 500 characters. This example says who the gateway is for and where to ask for access:
@@ -786,11 +690,7 @@
Developers see the text under `Notice from <gateway hostname>` on the gateway’s verification page in the browser and on the interactive sign-in screen in the terminal. Line breaks in the text become spaces. The notice appears before sign-in, so anyone who can reach the gateway can read it. Requires Claude Code v2.1.319 or later on the gateway server, and also on the developer’s machine for the terminal screen. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back.
-###
-
-
-
-`admin`
+### `admin`
Optional. Enables `/v1/organizations/spend_limits`, which mirrors Anthropic’s public Admin API, and per-developer spend enforcement on `/v1/messages`. See [Spend limits](</docs/en/claude-apps-gateway-spend-limits>) for how caps are set and enforced; this section covers the `gateway.yaml` keys that turn the feature on and tune it.
@@ -824,11 +724,7 @@
`pooled_conflict_rule`| No| `default_order` (default) or `priority_list`. The order the gateway tries a developer’s pooled budgets in. See Pooled budget order. Requires v2.1.319 or later.
`pooled_priority_order`| With `priority_list`| Up to 50 group names, each listed once and spelled as your IdP sends it. The groups whose pooled budgets the gateway tries first. See Pooled budget order. Requires v2.1.319 or later.
-####
-
-
-
-Pooled budget order
+#### Pooled budget order
A pooled budget is one monthly limit that a whole group spends against. To set one, add `pooled_budget` to the [request that sets the group’s monthly cap](</docs/en/claude-apps-gateway-spend-limits#set-a-cap>), as in `"pooled_budget": {"amount": "500000"}` for $5,000. The request also takes the group’s `scope`, `"period": "monthly"`, and `amount`, which stays each member’s own cap. For a developer in several such groups, each request counts against the first budget whose spend is below its limit, and is refused when every budget is used up. `pooled_conflict_rule` sets the order the gateway tries the budgets in:
@@ -837,11 +733,7 @@
If you list groups without `pooled_conflict_rule: priority_list`, the gateway ignores the list and logs a warning at boot. A gateway server earlier than v2.1.319 refuses to start when it finds `pooled_conflict_rule` or `pooled_priority_order`. Upgrade every replica before you add either key, and remove both keys before you roll back.
-###
-
-
-
-`enforcement`
+### `enforcement`
The `enforcement` block controls how spend-limit checks behave when the store is unavailable.
@@ -849,11 +741,7 @@
---|---|---
`fail_closed_on_error`| No| Default `false`. Spend enforcement fails open on a Postgres outage, so inference stays up. Set `true` to fail closed: over-cap developers are blocked, but so is everyone else if the store is unreachable. Requires an `admin:` block: spend enforcement only runs when `admin` is configured, and the gateway refuses to start if you set this `true` without one.
-###
-
-
-
-`pricing`
+### `pricing`
The `pricing` block tells the spend meter what to charge instead of USD list price, so caps and [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) reflect your contracted rates. Amounts stay in USD and remain an estimate, not an invoice. Two prerequisites:
@@ -885,11 +773,7 @@
For per-region rates, give each region its own named upstream and one row per upstream.
-####
-
-
-
-Mark prices up
+#### Mark prices up
With v2.1.271 or later on the gateway server, you can set `multiplier` above 1, up to 10, to meter more than the provider charges, for example an internal chargeback rate. This example meters every request at 120% of the price:
@@ -898,11 +782,7 @@
With an `admin:` block, the markup also applies to spend limits. The meter counts 120% of the price, so developers reach their caps sooner. The gateway logs a warning at boot that says so. The multiplier doesn’t change what the upstream provider charges for the requests. If the gateway also sends the rates to signed-in clients, developers need Claude Code v2.1.271 or later to see the markup. Earlier clients ignore a `multiplier` above 1 and show costs without it. A gateway server earlier than v2.1.271 refuses to start if you set a `multiplier` above 1.
-####
-
-
-
-Send the rates to signed-in clients
+#### Send the rates to signed-in clients
With v2.1.268 or later on the gateway server, the gateway also puts the rates from `pricing` into the `managed` policies it serves, as the [`modelPricing`](</docs/en/settings-reference#modelpricing>) managed setting. Developers matched by a policy then see the `pricing` rates in `/usage`, the status line, and OpenTelemetry. A developer who matches no policy receives no managed settings, so their figures stay at list price. Clients apply the setting in Claude Code v2.1.242 or later.
@@ -911,11 +791,7 @@
* Opt one policy out: set `modelPricing` to `{}` in that policy’s `cli` block, and its developers stay at list price.
* Keep a policy’s own rates: a policy whose `cli` block sets `modelPricing` with its own `multiplier` or `overrides` keeps that `modelPricing` whole, and the gateway adds no rates of its own to it.
-###
-
-
-
-`models`
+### `models`
The `models` block is an optional admin-curated model list, served at `/v1/models` and used to translate model IDs per upstream. It is required for non-US Amazon Bedrock regions, Amazon Bedrock provisioned-throughput ARNs, and Microsoft Foundry deployment names.
@@ -929,13 +805,9 @@
bedrock: us.anthropic.claude-opus-4-8 # or an inference-profile ARN
foundry: your-opus-deployment-name
-Each key under `upstream_model` must match the `name` of a configured upstream, which defaults to the provider name. A key that matches no upstream fails boot, so omit the lines for providers you don’t use.
-
-###
-
-
-
-`managed`
+Each key under `upstream_model` must match the `name` of a configured upstream, which defaults to the provider name. A key that matches no upstream fails boot, so omit the lines for providers you don’t use. To let developers use the `fable` alias with `auto_include_builtin_models: false`, add a `claude-fable-5` entry to `models`. That’s the ID the [`fable` alias](</docs/en/model-config#fable-alias-resolution>) resolves to for developers signed in to the gateway. Without it, their messages fail with an error that starts with `API Error: 400 model claude-fable-5 is not in the operator's model allowlist`.
+
+### `managed`
The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; by default the first match is selected, then merged onto the `match: {}` catch-all base. A user who matches two role policies gets only the first, so the second policy’s deny rules don’t apply unless you apply every matching policy. Policies are served per-user at `GET /managed/settings` with ETag/304 caching.
@@ -957,7 +829,11 @@
A `match: {}` catch-all, conventionally listed last, is treated as a base layer. Every other policy inherits any key it doesn’t set from the catch-all, so per-role entries only need to list what differs from the org default. The merge rules depend on the key type:
* **Allow-lists** : `availableModels` and `permissions.allow`. A specific policy’s list fully replaces the base’s.
- * **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, `deniedModels`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
+ * **Deny-lists and hook arrays** : these take the union of base and policy:
+ * `permissions.deny` and `permissions.ask`
+ * `disabledMcpjsonServers` and `deniedMcpServers`
+ * `blockedMarketplaces` and `deniedModels`
+ * The `hooks` event-type arrays
* **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. An empty list denies every model. The check also covers the model a session starts on before the developer picks one, so start sessions on a model the policy allows. The gateway validates the `model` value itself before it relays a request, so a malformed value never reaches an upstream. It rejects the request with a `400` in two cases:
@@ -981,11 +857,7 @@
Claude Desktop follows its own schedule.
-####
-
-
-
-Apply every matching policy
+#### Apply every matching policy
A user who matches several role policies gets only the first unless you set `policy_mode: layered` beside `policies`. With `layered`, every policy that matches the user applies, down to the first `match: {}` policy. `policy_mode` requires Claude Code v2.1.316 or later on the gateway server. A gateway on a version that lacks it refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. This example has one group that loses `WebFetch` and one that gains Opus:
@@ -1025,11 +897,7 @@
* **A`!` pattern**: a [`!` negation](</docs/en/permissions#special-characters-and-negation>) in a `Read` or `Edit` rule in any policy’s `permissions.deny` or `permissions.ask` list, the `match: {}` policy’s included
* **A limit on hooks outside the catch-all** : `disableAllHooks`, `allowedHttpHookUrls`, or `httpHookAllowedEnvVars` in any policy other than `match: {}`
-####
-
-
-
-Start sessions on a model the policy allows
+#### Start sessions on a model the policy allows
If `availableModels` leaves out Claude Code’s default model, sessions get `400` responses until the developer picks a listed model, for example with `/model`. In gateway sessions the default is the Opus model the `opus` alias resolves to, and `availableModels` on its own doesn’t change it. To fix this, set [`enforceAvailableModels: true`](</docs/en/model-config#enforce-the-allowlist-for-the-default-model>) in the same `cli` block, then check which kind of entry the list has:
@@ -1048,11 +916,7 @@
env:
ANTHROPIC_DEFAULT_OPUS_MODEL: restricted-claude-opus-4-8 # opus and Default resolve to the ID too
-####
-
-
-
-Matcher values that stop the gateway at boot
+#### Matcher values that stop the gateway at boot
At boot, the gateway checks the `match` block of every policy and the `admin_groups` list. Any of these values stops the gateway with an error that names the field:
@@ -1068,11 +932,7 @@
* An `email_domain` containing `@`, whitespace, or a comma: the policy matched no one
* An empty entry in `groups` or in `admin_groups`: the entry matched a user only when that user’s IdP `groups` claim also contained an empty entry. In `admin_groups`, that match granted admin access. If your `admin_groups` list never contained an empty entry, no one gained admin access this way.
-####
-
-
-
-Choose `cli` or `code`
+#### Choose `cli` or `code`
When a policy uses the `code` key, each of these stops the gateway from starting:
@@ -1098,11 +958,7 @@
* **To cover the Code tab** : switch to `code`, once users’ machines meet the conditions in Apply `code` settings in the Code tab
* **To stay on`cli`**: set `serve_to_desktop: false` beside `cli` in a policy to silence the warning
-####
-
-
-
-What goes in `cli`
+#### What goes in `cli`
Each `code` or `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys include `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
@@ -1158,19 +1014,11 @@
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
-####
-
-
-
-Test a policy before deployment
+#### Test a policy before deployment
To test a policy change, start the gateway against a throwaway Postgres database. The gateway connects to Postgres and applies its schema migrations before it checks the contents of `cli`, `code`, and `desktop` blocks. When it can’t reach the database, the start stops at `could not connect to Postgres` and reports nothing about their contents.
-####
-
-
-
-Context window in terminal sessions
+#### Context window in terminal sessions
Terminal sessions signed in through `/login` use the 1M context window for Opus 4.7 and later, Sonnet 5 and later, and the Fable models. The model ID needs no `[1m]` suffix, and sessions compact at about 967K tokens. Before Claude Code v2.1.287 on the developer’s machine, Claude Code treated the Opus and Fable models as having a 200K window unless the model ID ended in `[1m]`. To have terminal sessions compact at the 200K boundary instead, set the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) in the policy’s `env`:
@@ -1183,11 +1031,7 @@
Claude Code applies this variable without showing the developer the approval dialog. The variable applies to every model, including model IDs that end in `[1m]`. To turn off 1M context instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"`](</docs/en/model-config#extended-context>) in the same `env` block. Claude Code then treats every model as having a 200K window. In interactive sessions, each developer approves this variable in the approval dialog before it takes effect.
-####
-
-
-
-One-hour prompt cache
+#### One-hour prompt cache
To request the one-hour [prompt cache TTL](</docs/en/prompt-caching#cache-lifetime>) instead of the default five minutes, add these keys to a policy’s existing `code`, `cli`, or `settings` block and restart the gateway. The keys need Claude Code v2.1.242 or later on the gateway server and on clients. `promptCacheTtl` covers the main conversation. `subagentPromptCacheTtl` is optional and covers subagents, workflows, and background requests. This example adds both to a `match: {}` policy keyed `cli`:
@@ -1202,19 +1046,11 @@
To confirm `promptCacheTtl`, sign in to the gateway as a user the policy matches and [check which TTL your cache writes used](</docs/en/prompt-caching#choose-the-ttl-yourself>). Pass `--model` to repeat the check for each model the gateway serves. One-hour cache writes [cost more](</docs/en/prompt-caching#cache-lifetime>) than five-minute writes. For [spend limits](</docs/en/claude-apps-gateway-spend-limits#how-requests-are-priced>) to count that higher rate, you need v2.1.286 or later on the gateway server.
-####
-
-
-
-MCP servers in a policy
+#### MCP servers in a policy
To provide MCP servers to the Claude Code clients a policy matches, set [`managedMcpServers`](</docs/en/managed-mcp#provide-servers-through-managed-settings>) in that policy’s `cli` block. You need Claude Code v2.1.259 or later on the gateway server and on clients. The gateway checks each entry at boot with [the same rules Claude Code applies on the client](</docs/en/managed-mcp#what-an-entry-can-contain>), and if an entry fails a check, the gateway refuses to start and names the entry. If you write a `${VAR}` reference in `gateway.yaml`, the gateway resolves it from its environment at boot through secret expansion before it runs the entry checks, so every matching client receives the literal value and can read it. The [header guidance for provided servers](</docs/en/managed-mcp#provide-servers-through-managed-settings>) applies to the expanded value. The gateway rejects the `.mcp.json` spelling `mcpServers` in a `cli` block, and its boot error names `managedMcpServers` as the key to use. Before v2.1.259, the gateway rejected any MCP server definition in a `cli` block.
-####
-
-
-
-Claude Desktop overlay
+#### Claude Desktop overlay
If your organization also deploys [Claude Desktop](</docs/en/desktop>), the same gateway serves both clients. Point `bootstrapUrl`, in Claude Desktop’s [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>), at `<listen.public_url>/user/bootstrap`. Claude Desktop derives the OAuth issuer from that URL, runs the same device-code sign-in against this gateway, and fetches its configuration from the response.
@@ -1304,11 +1140,7 @@
To shorten the 24 hours, set [`relaunchEnforcementHours`](<https://claude.com/docs/third-party/claude-desktop/configuration#relaunchenforcementhours>) in the policy’s `desktop` block. You need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.40609.0 or later on members’ machines. With `0`, the dialog appears as soon as Claude Desktop finds the change.
-####
-
-
-
-Extended context in Claude Desktop
+#### Extended context in Claude Desktop
If you serve Claude Desktop from the gateway, its model picker offers a 1M context option for each listed model that can run with a 1M context window. These include Claude Opus 4.6 and later, Claude Sonnet 4.6 and later, and the Fable models. The option is the model’s `[1m]` variant, which [Extended context](</docs/en/model-config#extended-context>) describes. You need Claude Code v2.1.284 or later on the gateway server. A `models` entry gets no 1M option when:
@@ -1340,19 +1172,11 @@
To remove the option from the picker, set `CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"` in the `env` block under the policy’s `cli` key. If you also listed an entry whose `id` ends in `[1m]`, the gateway still serves it, so delete that entry too. The variable also reaches the terminal sessions of developers the policy matches. For what it changes there, see [Extended context](</docs/en/model-config#extended-context>).
-####
-
-
-
-Precedence with other managed sources
+#### Precedence with other managed sources
If a device also has an MDM-delivered policy or a local `managed-settings.json`, gateway-delivered settings rank first. [Precedence within the managed tier](</docs/en/managed-settings#precedence-within-the-managed-tier>) on the managed settings page says when the local sources apply, and has the [keys Claude Code reads from every admin source](</docs/en/managed-settings#keys-read-from-every-admin-source>) regardless of which source it selected, such as the sandbox lock keys, `forceRemoteSettingsRefresh`, and the per-variable `env` merge. A [`policyHelper`](</docs/en/settings-reference#policyhelper>) configured in an MDM profile or the managed settings file runs only when the gateway delivers no settings; the entry says what its output replaces. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. [Parent settings from embedding hosts](</docs/en/managed-settings#parent-settings-from-embedding-hosts>) says when Claude Code applies it, and [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
-###
-
-
-
-`telemetry`
+### `telemetry`
The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Events that Claude Code logs before the developer signs in [don’t carry this identity](</docs/en/monitoring-usage#standard-attributes>). To see which attribute follows a change in a developer’s groups, see Group changes during an open session. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
@@ -1395,11 +1219,7 @@
Without a `forward_to` destination for a signal, the gateway accepts and discards it. If developers already export Claude Code telemetry to one of your collectors, add it as a `forward_to` destination, with logs or traces enabled if they export those, so it keeps receiving their data after they sign in. To skip the relay instead, name the collector in a policy. [Traces](</docs/en/monitoring-usage#traces-beta>) also require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. Set it in a managed policy’s `env` block, since the gateway doesn’t push it. Developers approve it in the same security approval dialog that the pushed endpoint already triggers. Set it to `1` only in the policies whose groups you want traced. A policy that doesn’t set it inherits the value from your `match: {}` catch-all policy if that policy sets one, per the merge rules. To keep a group’s clients from sending traces even when a developer sets the variable locally, set it to `0` in that group’s policy. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
-####
-
-
-
-Send cumulative metrics
+#### Send cumulative metrics
If your collector accepts only cumulative metrics, set [`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`](</docs/en/monitoring-usage#common-configuration-variables>) to `cumulative`. Claude Code sends delta metrics by default, and the gateway relays them without converting them. Set the variable where each kind of session reads it:
@@ -1410,11 +1230,7 @@
If you add the variable to a machine’s managed settings, also set [`parentSettingsBehavior: "merge"`](</docs/en/claude-apps-gateway#set-the-opt-in>) in the highest-priority source on that machine. Without it, Cowork sessions and Code tab sessions under a `cli` policy run without the egress allowlist and other policy that Claude Desktop passes them as parent settings.
-####
-
-
-
-Add your own labels
+#### Add your own labels
To put fixed labels such as `service.namespace` or `deployment.environment.name` on the telemetry of sessions signed in through the gateway, set `telemetry.resource_attributes`. Each label is an OpenTelemetry resource attribute, and every destination receives the same labels. Sessions get the labels only when you also set `telemetry.forward_to` and `listen.public_url`. This example adds two labels:
@@ -1435,11 +1251,7 @@
You need Claude Code v2.1.281 or later on the gateway server to set `telemetry.resource_attributes`. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. Terminal sessions signed in through `/login` receive the labels as `OTEL_RESOURCE_ATTRIBUTES`, pushed with the other telemetry variables. If you set `OTEL_RESOURCE_ATTRIBUTES` in a policy’s `env` block, terminal sessions that policy matches get that value instead of the labels. Claude Desktop receives the labels from the gateway alongside `user.email` and the other identity attributes. Claude Code also copies each label onto every metric data point, so you can filter metrics by it in a backend that doesn’t index resource attributes. To turn that copy off, see [Metrics cardinality control](</docs/en/monitoring-usage#metrics-cardinality-control>).
-####
-
-
-
-Group changes during an open session
+#### Group changes during an open session
Terminal sessions put `user.groups` on the OTLP resource and again on each metric data point and event. If a developer’s groups change while a session is open, data points and events for usage after the next silent refresh carry the new groups. The resource keeps the old groups until the developer restarts Claude Code, so group by the attribute on the data point or event. If you turn on `resource_to_telemetry_conversion` in the OpenTelemetry Collector’s Prometheus remote write exporter, the exporter replaces each data point’s `user.groups` with the resource’s, so every data point shows the old groups. To keep the data point’s value, delete `user.groups` from the resource ahead of that exporter. This OpenTelemetry Collector `resource` processor deletes the attribute in the pipelines that list it:
@@ -1451,11 +1263,7 @@
After you add `resource/drop-user-groups` to the metrics pipeline’s `processors`, each series carries the `user_groups` label from its own data point.
-####
-
-
-
-Export directly to your collector
+#### Export directly to your collector
To have sessions signed in through `/login` send telemetry straight to your collector instead of through the relay, set `OTEL_EXPORTER_OTLP_ENDPOINT` to the collector’s `https://` base URL in the `env` block of a managed policy. Claude Code appends `/v1/metrics`, `/v1/logs`, or `/v1/traces` to the URL you set, such as `https://otel-collector.example.com:4318`, and exports each signal there over OTLP/HTTP. Requires Claude Code v2.1.265 or later on each developer’s machine. Earlier clients export through the relay. To authenticate to the collector, set `OTEL_EXPORTER_OTLP_HEADERS` in the same `env` block. Sessions never send the developer’s gateway session token to a collector named this way. When you add or change this endpoint in a policy, Claude Code asks each developer to approve it in the security approval dialog before applying it in an interactive session. Claude Code checks the endpoint before it exports a signal directly, and keeps that signal on the relay when a check fails. The checks include:
@@ -1472,19 +1280,11 @@
When the developer signs out, or signs in to a different gateway, exports to the collector stop and Claude Code drops each remaining batch rather than sending it.
-####
-
-
-
-When a destination fails
+#### When a destination fails
The gateway doesn’t buffer, retry, or store telemetry, so it drops an export that doesn’t reach a destination rather than delivering it late. Each destination succeeds or fails on its own, and the exporting client receives a success response either way, so a failed delivery appears only in the gateway’s log. After five consecutive failed deliveries to a destination, the gateway pauses forwarding to it in 30-second stretches, logging each pause, until a delivery succeeds. Any error response, timeout, or connection error counts as a failed delivery, except `400`, `413`, `415`, `422`, and `431`, which mean the collector refused that export’s payload as malformed or too large. A refused payload neither advances nor resets the failure count: the gateway keeps forwarding to the destination and logs a warning naming it and the status, on the destination’s first refusal and every hundredth after.
-###
-
-
-
-HTTP tuning
+### HTTP tuning
Four optional top-level blocks, `access_control`, `limits`, `timeouts`, and `rate_limits`, tune the HTTP surface. The defaults suit most deployments.
@@ -1505,11 +1305,7 @@
Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. If the relay belongs in `listen.trusted_proxies`, list it there. Keep the gateway and everything in front of it unreachable from the public internet regardless.
-###
-
-
-
-`load_test_mode`
+### `load_test_mode`
The `load_test_mode` block lets you load test a gateway without calling a model provider. While it’s on, the gateway builds and signs each provider request as usual, discards it instead of sending it, and streams a canned reply back through its normal response path. The reply is filler text that begins with a sentence saying it is canned. Requires Claude Code v2.1.282 or later on the gateway server. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the block, and remove the block before you roll back. The example below turns the mode on with the defaults, a reply of roughly 750 tokens of text streamed over about 10 seconds:
@@ -1528,11 +1324,7 @@
Never turn this on for a gateway that developers use. Every request gets the canned reply and no model is called. The gateway logs a `load_test_mode is on` warning at boot and marks each `inference` [audit event](</docs/en/claude-apps-gateway-deploy#logs>) with `load_test: true` while the mode is on.
-##
-
-
-
-Complete example
+## Complete example
This full reference config exercises every core section; the HTTP tuning blocks keep their defaults. Copy it, delete what you don’t need, and fill in your values. The config in the [Quickstart](</docs/en/claude-apps-gateway#quickstart>) is a minimal version of this.
@@ -1700,11 +1492,7 @@
headers:
Authorization: Bearer ${OTEL_TOKEN}
-##
-
-
-
-Client-side managed settings
+## Client-side managed settings
Everything above configures the gateway server. You point developer machines at the gateway separately, on each device, through Claude Code’s [managed settings](</docs/en/managed-settings>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
@@ -1716,11 +1504,7 @@
`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. To stop developers from bypassing the gateway with a cloud provider variable or an `ANTHROPIC_BASE_URL` of their own, add `"allowedProviders": ["gateway"]` to the same file. Claude Code then refuses every session on the machine that isn’t set up for a Cloud gateway, and admits a gateway only when it is the one `forceLoginGatewayUrl` names or one whose URL the file’s `env` block sets as `ANTHROPIC_BASE_URL`. `claude gateway` refuses to run on a machine that sets the list, so keep the key off the gateway host. See the [`allowedProviders`](</docs/en/settings-reference#allowedproviders>) entry in the settings reference. Requires Claude Code v2.1.285 or later. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in the gateway payload doesn’t configure the gateway sign-in. For a developer’s own `~/.claude/settings.json`, see [Set the gateway URL in user settings](</docs/en/claude-apps-gateway#set-the-gateway-url-in-user-settings>). Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
-##
-
-
-
-Related
+## Related
* [Claude apps gateway overview](</docs/en/claude-apps-gateway>): quickstart and developer connection
* [Deployment guide](</docs/en/claude-apps-gateway-deploy>): IdP setup, container image, Kubernetes and Cloud Run, and operations
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -59,7 +59,9 @@
`port`| No| Bind port. Default `8080`.
`public_url`| Unless `host` is loopback| The externally visible `https://` origin, used to build the IdP `redirect_uri` and discovery metadata. Required whenever `host` isn’t a loopback address, whether TLS terminates at a proxy such as an ALB, Ingress, or Cloud Run or at the gateway itself through `tls`, because the gateway never derives its own origin from `X-Forwarded-*` headers; they are client-spoofable. Boot fails without it. `trusted_proxies` below governs client-IP resolution only. Also required to enable telemetry, because the gateway builds the OTLP endpoint it pushes to clients from this URL.
`tls.cert` / `tls.key`| No| PEM paths if the gateway terminates TLS itself
-`trusted_proxies`| No| CIDRs or IPs of load balancers in front of the gateway. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit. Equivalent to nginx `set_real_ip_from`. `X-Forwarded-For` entries written as `ipv4:port` or `[ipv6]:port`, as some load balancers do, are read with the port dropped. An IPv6 address with a port appended and no brackets may be read as a different address or not read at all, so turn off the port option on any proxy that writes that form.
+`trusted_proxies`| No| CIDRs or IPs of the frontends to trust. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit.
+
+List a frontend in `trusted_proxies` only if the last `X-Forwarded-For` entry that it passes on is one that no developer wrote. List no address or range that developers connect from. A frontend that appends the address of each connection it receives qualifies. One that passes the header on as developers send it doesn’t. `X-Forwarded-For` entries written as `ipv4:port` or `[ipv6]:port`, as some load balancers do, are read with the port dropped. An IPv6 address with a port appended and no brackets may be read as a different address or not read at all. Turn off the port option on any proxy that writes that form.
###
@@ -1501,7 +1503,7 @@
* **At boot** : a warning in the operational log recommends allowing only the private ranges `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `100.64.0.0/10`, `127.0.0.0/8`, `::1/128`, and `fc00::/7`, plus any other internal ranges your developers connect from. If you bind the gateway to a loopback address and set neither `trusted_proxies` nor `public_url`, as in local development, the warning doesn’t appear.
* **At runtime** : the first time a request arrives from an address outside those private ranges, the gateway logs a warning and emits an [`access.public_client` audit event](</docs/en/claude-apps-gateway-deploy#logs>) carrying the client IP. Both fire once per process. Link-local addresses, `169.254.0.0/16` and `fe80::/10`, don’t count as public. The gateway answers `/healthz` and `/readyz` before this check runs, so health probes from public ranges don’t trigger it.
-Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. Behind such a front end, set `listen.trusted_proxies` first so the gateway sees real client addresses, and keep the gateway and everything in front of it unreachable from the public internet regardless.
+Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. If the relay belongs in `listen.trusted_proxies`, list it there. Keep the gateway and everything in front of it unreachable from the public internet regardless.
###
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -16,6 +16,7 @@
**Optional sections:**
+ * `login_notice`: a notice developers see when they sign in
* `admin`: Admin API auth and retention for spend limits
* `enforcement`: spend-limit fail-open or fail-closed behavior
* `pricing`: contracted rates and a multiplier for the spend meter and for the cost figures developers see
@@ -775,6 +776,18 @@
+`login_notice`
+
+To show developers a notice when they sign in, set the top-level `login_notice` key to the notice text, up to 500 characters. This example says who the gateway is for and where to ask for access:
+
+ login_notice: This gateway is for Example Corp staff. For access questions, email it-help@example.com.
+
+Developers see the text under `Notice from <gateway hostname>` on the gateway’s verification page in the browser and on the interactive sign-in screen in the terminal. Line breaks in the text become spaces. The notice appears before sign-in, so anyone who can reach the gateway can read it. Requires Claude Code v2.1.319 or later on the gateway server, and also on the developer’s machine for the terminal screen. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back.
+
+###
+
+
+
`admin`
Optional. Enables `/v1/organizations/spend_limits`, which mirrors Anthropic’s public Admin API, and per-developer spend enforcement on `/v1/messages`. See [Spend limits](</docs/en/claude-apps-gateway-spend-limits>) for how caps are set and enforced; this section covers the `gateway.yaml` keys that turn the feature on and tune it.
@@ -792,6 +805,9 @@
# IdP groups granted full admin via the normal gateway JWT (no API key).
admin_groups: [platform-finops]
blocked_message: request an increase at https://go.example.com/claude-limits
+ # Try eng-platform's pooled budget first, then eng-all's, then any other group's.
+ pooled_conflict_rule: priority_list
+ pooled_priority_order: [eng-platform, eng-all]
Field| Required| Description
---|---|---
@@ -803,6 +819,21 @@
`spend_retention_months`| No| Default `13`. `spend` counter rows older than this are swept. The default keeps a full year plus the current partial month for year-over-year reporting.
`identity_retention_days`| No| Default `90`. Last-seen TTL for `principal_emails` rows, which hold each developer’s email, display name, and groups (PII). Deliberately shorter than spend retention so a deprovisioned identity ages out while its anonymous spend counters remain.
`group_limit_mode`| No| `min` (default) or `max`. When a developer is in several groups with caps, `min` enforces the most restrictive and `max` the least. Used by both enforcement and `/effective`.
+`pooled_conflict_rule`| No| `default_order` (default) or `priority_list`. The order the gateway tries a developer’s pooled budgets in. See Pooled budget order. Requires v2.1.319 or later.
+`pooled_priority_order`| With `priority_list`| Up to 50 group names, each listed once and spelled as your IdP sends it. The groups whose pooled budgets the gateway tries first. See Pooled budget order. Requires v2.1.319 or later.
+
+####
+
+
+
+Pooled budget order
+
+A pooled budget is one monthly limit that a whole group spends against. To set one, add `pooled_budget` to the [request that sets the group’s monthly cap](</docs/en/claude-apps-gateway-spend-limits#set-a-cap>), as in `"pooled_budget": {"amount": "500000"}` for $5,000. The request also takes the group’s `scope`, `"period": "monthly"`, and `amount`, which stays each member’s own cap. For a developer in several such groups, each request counts against the first budget whose spend is below its limit, and is refused when every budget is used up. `pooled_conflict_rule` sets the order the gateway tries the budgets in:
+
+ * **`default_order`** : the largest limit first, and equal limits in ascending group-name order
+ * **`priority_list`** : the budgets of the groups in `pooled_priority_order`, in list order, then the other groups’ budgets by group name
+
+If you list groups without `pooled_conflict_rule: priority_list`, the gateway ignores the list and logs a warning at boot. A gateway server earlier than v2.1.319 refuses to start when it finds `pooled_conflict_rule` or `pooled_priority_order`. Upgrade every replica before you add either key, and remove both keys before you roll back.
###
@@ -1512,6 +1543,8 @@
# environment variable (debug | info | warn | error; default info). debug
# also logs the claim names in each id_token, for groups_claim diagnosis.
# It does not affect audit events, which are always emitted.
+ # Set CLAUDE_GATEWAY_LOG_FORMAT=json to write operational log lines as JSON
+ # objects with severity, time, and message.
listen:
host: 0.0.0.0
@@ -1552,6 +1585,9 @@
# connect_timeout_seconds: 5
# readiness_grace_seconds: 300 # keep passing the readiness check through a database failover
+ # Notice shown at sign-in. Anyone who can reach the gateway can read it.
+ # login_notice: This gateway is for Example Corp staff. For access questions, email it-help@example.com.
+
# Enables /v1/organizations/spend_limits (mirrors the Anthropic Admin API)
# and per-developer spend enforcement on /v1/messages. Omit to disable.
# Caps themselves are set via the admin API, not here.
@@ -1566,6 +1602,8 @@
# # spend_retention_months: 13
# # identity_retention_days: 90
# # group_limit_mode: min
+ # # pooled_conflict_rule: priority_list
+ # # pooled_priority_order: [eng-platform, eng-all]
# enforcement:
# fail_closed_on_error: false
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1491,7 +1491,7 @@
`reply_tokens`| No| Default `750`. Roughly how many tokens of text each canned reply carries, a whole number from 1 to 100000.
`reply_seconds`| No| Default `9.5`. How long a streamed reply takes, from 0 to 600. `0` sends the whole reply at once. A reply to a non-streaming request always comes back at once.
-A load test in this mode covers the gateway, your Postgres, and everything in front of the gateway. It doesn’t cover the provider’s limits, speed, or network path. No model request is sent to the provider, so a replica’s CPU per request is an estimate and reads lower than production, which also encrypts its traffic to the provider. Confirm a replica count with a small pilot against the real provider. Before v2.1.283, the estimate reads much lower. While the mode is on, a request can carry an `x-load-test-user` header holding a whole number of up to seven digits. The gateway counts each number as a separate developer, with the email and groups of the developer whose token came with the request. Give the load-test deployment its own empty database, because the gateway refuses to start with the mode on against a database in which any developer has already spent anything.
+A load test in this mode covers the gateway, your Postgres, and everything in front of the gateway. It doesn’t cover the provider’s limits, speed, and network path, or the wait at each replica’s [limit on concurrent upstream requests](</docs/en/claude-apps-gateway-deploy#concurrent-upstream-requests>). A replica still logs the `client requests are open` warning when more requests are open than that limit, the point where production requests start to wait. No model request is sent to the provider, so a replica’s CPU per request is an estimate and reads lower than production, which also encrypts its traffic to the provider. Confirm a replica count with a small pilot against the real provider. Before v2.1.283, the estimate reads much lower. While the mode is on, a request can carry an `x-load-test-user` header holding a whole number of up to seven digits. The gateway counts each number as a separate developer, with the email and groups of the developer whose token came with the request. Give the load-test deployment its own empty database, because the gateway refuses to start with the mode on against a database in which any developer has already spent anything.
Never turn this on for a gateway that developers use. Every request gets the canned reply and no model is called. The gateway logs a `load_test_mode is on` warning at boot and marks each `inference` [audit event](</docs/en/claude-apps-gateway-deploy#logs>) with `load_test: true` while the mode is on.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -460,7 +460,7 @@
* If STS refuses or is unreachable, the gateway doesn’t send the request with the upstream’s own credentials. It logs the STS error with what to check, then tries the next upstream you listed. Upstream error messages covers what the client receives when no upstream succeeds. A later upstream without `assume_role` would serve the request with its own credentials, so list one only if that is what you want.
* The gateway calls the regional STS endpoint `sts.<region>.amazonaws.com`, which its network must reach. For the FIPS endpoint, set `AWS_USE_FIPS_ENDPOINT=true` in the gateway’s environment rather than `use_fips_endpoint` in an AWS config file.
- * `assume_role` applies to `provider: bedrock` only and needs SigV4 source credentials: the gateway refuses to start when it’s set beside `aws_bearer_token`.
+ * `assume_role` needs SigV4 source credentials: the gateway refuses to start when it’s set beside `aws_bearer_token`.
* Without a `groups` list, every developer the gateway admits can use this upstream. To limit which models a developer can use, set `availableModels` in a `managed` policy.
* To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account.
* A request for a built-in model name can still reach this upstream, and the gateway signs it with the same role. List this upstream last unless its account should also serve those models.
@@ -510,12 +510,13 @@
`region`| Yes| AWS region. The gateway derives the endpoint from it as `https://bedrock-mantle.<region>.api.aws/anthropic`.
`models`| Yes| The models your AWS account has been granted on Mantle, named as clients send them, such as `claude-haiku-4-5`. Only these go to this upstream, and every other model skips to the next one.
`auth`| No| Takes the same keys as the Amazon Bedrock upstream’s `auth` block, under the same rules.
+`assume_role`| No| The role that this upstream’s requests go through, with the same keys as on a `bedrock` upstream, including `session_name` for per-developer attribution. Give the role Mantle’s IAM actions. Requires a gateway running Claude Code v2.1.318 or later. An earlier gateway exits at startup with `Unrecognized key(s) in object: 'assume_role'`.
`base_url`| No| Override the derived endpoint. Keep the `/anthropic` path at the end.
Grant the upstream’s AWS identity Mantle’s own IAM actions for inference and token counting, which [Use the Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) lists. For a Mantle model ID that the gateway doesn’t know, add an entry to the top-level `models:` block whose `upstream_model` maps this upstream’s name to that ID. Then put that entry’s `id` in this upstream’s `models` field too. A `bedrock` upstream’s `guardrail` and `assume_role` settings don’t extend to the requests Mantle serves:
* **`guardrail`** : the gateway applies no Bedrock guardrail to requests it sends to Mantle, so it refuses to start when a `mantle` upstream is listed while any `bedrock` upstream sets `guardrail`.
- * **`assume_role`** : a `mantle` upstream takes no `assume_role`. Requests that Mantle serves are sent with the `mantle` upstream’s own `auth` credentials, and aren’t attributed per developer.
+ * **`assume_role`** : set it on the `mantle` upstream itself. Without it, requests that Mantle serves are sent with the `mantle` upstream’s own `auth` credentials.
For what Mantle’s own error responses mean, see [Mantle endpoint errors](</docs/en/amazon-bedrock#mantle-endpoint-errors>).
Show diff (167 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -232,7 +232,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the upstream rejected the credential the gateway used, or denied it access, for example to the requested model. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model, passing over any upstream whose `groups` list leaves the developer out. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the upstream rejected the credential the gateway used, or denied it access, for example to the requested model. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
@@ -243,7 +243,7 @@
The gateway returns one upstream’s error response, or its own `502`, depending on how the upstreams answered:
* **An upstream returned a status the gateway doesn’tfail over on**: that upstream’s response. The gateway tries no further upstreams.
- * **Every upstream the gateway tried failed in a way itfails over on**: the last `429`. When none returned a `429`, the gateway prefers, in order, the last `401` or `403`, the last `404`, and the last `501`. When none returned any of those, the gateway’s own `502`, `all upstreams failed (N attempted)`, where N counts every entry in `upstreams`, including entries the gateway skipped because they don’t serve the requested model.
+ * **Every upstream the gateway tried failed in a way itfails over on**: the last `429`. When none returned a `429`, the gateway prefers, in order, the last `401` or `403`, the last `404`, and the last `501`. When none returned any of those, the gateway’s own `502`, `all upstreams failed (N attempted)`. N counts your `upstreams` entries, including skipped ones, minus any whose `groups` list leaves the developer out.
When the gateway returns an upstream’s response, it keeps the upstream’s status code. Whether it keeps the upstream’s message depends on the provider. An Anthropic API upstream’s error body reaches the developer unchanged. The Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry upstreams can name your account IDs, role ARNs, and project IDs in their error text. The gateway records that full text in the [operational log](</docs/en/claude-apps-gateway-deploy#logs>). What the developer sees from those upstreams depends on the rejection:
@@ -396,6 +396,35 @@
If your AWS account or organization enforces a guardrail, see [Amazon Bedrock’s documentation](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-enforcements.html>) for how that guardrail treats input tags.
+##### Log which guardrail filter fired
+
+To find out which Amazon Bedrock guardrail filter blocked a developer’s request, set `guardrail_trace: true` on the Bedrock upstream, restart the gateway, and have the developer send the request again. Then find the request’s `guardrail.trace` event in the [audit log](</docs/en/claude-apps-gateway-deploy#logs>). Requires Claude Code v2.1.314 or later on the gateway server. An earlier gateway refuses to start when it finds `guardrail_trace`.
+
+ upstreams:
+ - provider: bedrock
+ region: us-east-1
+ auth: {}
+ guardrail:
+ id: gr-abc123
+ version: "1"
+ guardrail_trace: true # default false; beside guardrail, not inside it
+
+The gateway writes a `guardrail.trace` event, without the matched text, when a filter fired or the guardrail’s action is `INTERVENED`. Find the developer’s events by `email` or `sub`. One streamed request can produce several events, and one of them can have an empty `filters` list, so read every event that has the same `request_id`:
+
+Field| What it holds
+---|---
+`request_id`| The request’s ID
+`sub`, `email`| The developer’s user ID and email
+`upstream`| The upstream the reply came from
+`action`| The guardrail’s action, such as `INTERVENED`
+`filters`| The filters that fired. The list is empty when AWS sends no filter detail
+`filters[].side`| `input` or `output`
+`filters[].guardrail`| The guardrail’s ID
+`filters[].policy`| The Bedrock policy and list, such as `contentPolicy.filters` or `sensitiveInformationPolicy.piiEntities`
+Other `filters[]` fields| An entry can also carry fields such as `action`, `name`, `type`, `confidence`, `filterStrength`, `score`, and `threshold`
+
+The event leaves out the text a filter matched, including the `match` field of Bedrock’s trace. Developers don’t receive Bedrock’s trace data, because the gateway removes it from each reply, streamed or not. If a client sends an `amazon-bedrock-*` field in a `/v1/messages` request body, the gateway answers 400 on an upstream that sets `guardrail_trace`.
+
##### Bedrock in another AWS account
Set `assume_role` on a Bedrock upstream and the gateway uses its own AWS identity only to call `sts:AssumeRole` on a role you name, which can be in a different AWS account from the gateway. Every Bedrock request from that upstream is signed with the one-hour credentials STS returns, so no long-lived access key crosses accounts. Requires a gateway running Claude Code v2.1.281 or later. An earlier gateway refuses to start when it finds the key.
@@ -432,7 +461,9 @@
* If STS refuses or is unreachable, the gateway doesn’t send the request with the upstream’s own credentials. It logs the STS error with what to check, then tries the next upstream you listed. Upstream error messages covers what the client receives when no upstream succeeds. A later upstream without `assume_role` would serve the request with its own credentials, so list one only if that is what you want.
* The gateway calls the regional STS endpoint `sts.<region>.amazonaws.com`, which its network must reach. For the FIPS endpoint, set `AWS_USE_FIPS_ENDPOINT=true` in the gateway’s environment rather than `use_fips_endpoint` in an AWS config file.
* `assume_role` applies to `provider: bedrock` only and needs SigV4 source credentials: the gateway refuses to start when it’s set beside `aws_bearer_token`.
- * Every developer the gateway admits can use this upstream; `managed` governs which developers may use which models. To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account. A request for a built-in model name can still reach this upstream, and the gateway signs it with the same role. List this upstream last unless its account should also serve those models.
+ * Without a `groups` list, every developer the gateway admits can use this upstream. To limit which models a developer can use, set `availableModels` in a `managed` policy.
+ * To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account.
+ * A request for a built-in model name can still reach this upstream, and the gateway signs it with the same role. List this upstream last unless its account should also serve those models.
This example gives one model a custom id that only the isolated upstream serves:
@@ -616,7 +647,13 @@
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. Every request starts at the first upstream. A request reaches a later upstream only when every upstream ahead of it has failed or doesn’t serve the requested model. The gateway keeps no record of failed upstreams, so while an upstream is down, every request that reaches it still tries it and waits for it to fail before moving on. The gateway waits this long for a response to start:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. A request moves past an upstream only in these cases:
+
+ * The upstream has failed
+ * The upstream doesn’t serve the requested model
+ * The upstream has a `groups` list that leaves the developer out
+
+The gateway keeps no record of failed upstreams, so while an upstream is down, every request that reaches it still tries it and waits for it to fail before moving on. The gateway waits this long for a response to start:
* **`provider: anthropic` upstreams**: `timeouts.upstream_ttfb_ms`, 120 seconds by default
* **Other providers** : up to one hour. To shorten that wait for streaming requests, set `timeouts.upstream_ttfb_ms` on gateway v2.1.295 or later. Non-streaming model requests wait up to one hour either way
@@ -661,11 +698,71 @@
---|---
Different regions| One Amazon Bedrock upstream per region, each with its own `region:`. With `auto_include_builtin_models: true` the cross-region inference profiles route automatically; for region-pinned deployments use a `models:` block.
Different accounts| One Amazon Bedrock upstream per account. The default chain (`auth: {}`) uses the pod’s identity; for a second account, add `assume_role` to reach it with short-lived credentials, or set explicit credentials or a bearer token in `auth:`.
+Different teams| Give each team’s upstream a `groups` list, so that only developers in those IdP groups reach it. See Send each team to its own upstream.
Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
-Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. A `mantle` upstream is tried only for the models listed in its `models` field. On every other upstream the gateway tries built-in models in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
+Model-scoped routing| A custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. An upstream with a `models` list, which a `mantle` upstream must have, is tried only for those models.
+Built-in model routing| On an upstream with no `models` or `groups` list, the gateway tries built-in models in order and uses the provider’s default ID where the `upstream_model:` map has no entry. For a built-in model the provider has a default ID for, the map changes which ID an upstream receives rather than whether it is tried. An upstream that rejects the ID follows the same failover rules as any other upstream error.
Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so by default failover doesn’t send a body field an upstream would reject. If you set the one-hour cache TTL in a policy, it goes to every upstream in the list, so set it only if all of them accept it.
+
+####
+
+
+
+Send each team to its own upstream
+
+To send each team’s requests to its own AWS account or Google Cloud project, list one upstream per team and give each one a `groups` list. Only developers in a listed IdP group reach that upstream, on the first try and on failover. Every provider takes `groups`. Requires Claude Code v2.1.314 or later on the gateway server. This example gives the `payments-eng` and `search-eng` groups an AWS account each, and adds an upstream with no `groups` list that every developer can use:
+
+ upstreams:
+ - name: bedrock-payments
+ provider: bedrock
+ region: us-east-1
+ auth: {}
+ assume_role:
+ role_arn: arn:aws:iam::111111111111:role/claude-gateway-bedrock
+ groups: [payments-eng]
+ - name: bedrock-search
+ provider: bedrock
+ region: us-east-1
+ auth: {}
+ assume_role:
+ role_arn: arn:aws:iam::222222222222:role/claude-gateway-bedrock
+ groups: [search-eng]
+ - name: bedrock-shared # no groups: open to everyone, so listed last
+ provider: bedrock
+ region: us-east-1
+ auth: {}
+
+With the example config, each developer’s requests start at the first upstream in their row and move to the next on failover:
+
+Developer’s groups| Upstreams, in order
+---|---
+`payments-eng`| `bedrock-payments`, then `bedrock-shared`
+`search-eng`| `bedrock-search`, then `bedrock-shared`
+`payments-eng` and `search-eng`| `bedrock-payments`, then `bedrock-search`, then `bedrock-shared`
+Neither| `bedrock-shared`
+
+When a team’s upstream denies the requested model with a `403`, the gateway tries the next upstream in that team’s row that serves the model. To keep the team on one upstream, give every upstream a `groups` list, and make sure no other upstream lists a group the team’s developers are in. That team then has no failover, and requests from developers in no listed group fail with a `400`. To get each developer to the upstream you intend, write entries that match exactly and put open upstreams last:
+
+ * **Entries** : write each group exactly as your IdP sends it in the groups claim, which `match.groups` also reads. The gateway refuses to start when it finds an empty list or an empty entry. It doesn’t check an entry against your IdP, so an entry that matches no one raises no warning.
+ * **Order** : put an upstream that has no `groups` list last. It serves everyone, so listed earlier it takes a team’s requests ahead of that team’s own upstream.
+
+A gateway earlier than v2.1.314 refuses to start when it finds `groups`, so upgrade every replica before you add it.Before you roll back, remove each upstream that has a `groups` list and every `upstream_model` key or pricing override that names it, and keep at least one upstream. With only the `groups` key gone, that upstream is open to every developer. A key or override that still names a removed upstream stops the gateway from starting, with `references unknown upstream`.
+
+##### What happens when a developer is in no listed group
+
+If every upstream has a `groups` list, a developer in none of those groups sees this error, and the gateway contacts no provider:
+
+ API Error: 400 you aren't in a group that can use this gateway. Ask your administrator to add you to one
+
+Add the developer to a listed group in your IdP, or add an upstream with no `groups` list. The gateway reads a developer’s groups again at each token refresh. If your IdP leaves groups out of a refresh, the developer then has none:
+
+ * **`oidc.allowed_groups` is set**: the gateway refuses the refresh, and the session ends
+ * **Otherwise, an upstream has no`groups` list**: the developer’s requests move to it
+ * **Otherwise, every upstream has a`groups` list**: the developer’s requests fail with that error
+
+If your IdP’s userinfo endpoint returns the groups claim and `oidc.google_groups` isn’t set, set `oidc.userinfo_fallback` to `true` to fill in the groups from there.
##
@@ -773,9 +870,10 @@
Send the rates to signed-in clients
-With v2.1.268 or later on the gateway server, the gateway also puts the rates from `pricing` into the `managed` policies it serves, as the [`modelPricing`](</docs/en/settings-reference#modelpricing>) managed setting. Developers matched by a policy then see the `pricing` rates for the first upstream that serves each model ID in `/usage`, the status line, and OpenTelemetry. A developer who matches no policy receives no managed settings, so their figures stay at list price. Clients apply the setting in Claude Code v2.1.242 or later.
+With v2.1.268 or later on the gateway server, the gateway also puts the rates from `pricing` into the `managed` policies it serves, as the [`modelPricing`](</docs/en/settings-reference#modelpricing>) managed setting. Developers matched by a policy then see the `pricing` rates in `/usage`, the status line, and OpenTelemetry. A developer who matches no policy receives no managed settings, so their figures stay at list price. Clients apply the setting in Claude Code v2.1.242 or later.
* What the gateway adds: unless a policy’s `cli` block already sets `modelPricing`, the gateway adds the `multiplier` and, for every model ID a client can request, the override row of the first upstream that serves that ID. A rate that only a failover upstream charges stays on the gateway.
+ * Upstreams with a `groups` list: when one is the first upstream that serves a model ID, the gateway adds no row for that ID. Developers then see Claude Code’s own rate for that ID, which is the model’s standard rate when Claude Code recognizes the ID, times the `multiplier`.
* Opt one policy out: set `modelPricing` to `{}` in that policy’s `cli` block, and its developers stay at list price.
* Keep a policy’s own rates: a policy whose `cli` block sets `modelPricing` with its own `multiplier` or `overrides` keeps that `modelPricing` whole, and the gateway adds no rates of its own to it.
Show diff (120 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -355,9 +355,46 @@
version: "1" # a published version number, or DRAFT
# keep the quotes: a bare 1 fails at boot
-The gateway doesn’t support guardrail input tags. It adds no guard content tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation.
-
Also grant `bedrock:ApplyGuardrail` on the guardrail to the principal that signs this upstream’s requests: the gateway’s AWS principal, or with `assume_role` the role named in `role_arn`. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail, or refuses to start if that provider is `mantle`. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
+
+By default the gateway adds no input tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. To add the tags, set `input_tagging`. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation.
+
+##### Add guardrail input tags
+
+To have the gateway add the input tags that an Amazon Bedrock guardrail’s [prompt attacks filter](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-prompt-attack.html>) needs, set `input_tagging` in the `guardrail` block and restart the gateway. Set the same value on every `bedrock` upstream, or the gateway refuses to start. Requires Claude Code v2.1.316 or later on the gateway server. A gateway on a version that lacks the key exits at startup with `Unrecognized key(s) in object: 'input_tagging'`.
+
+According to [Amazon Bedrock’s documentation](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>), every filter in the guardrail stops evaluating untagged content once a request carries input tags. Try `input_tagging` on a test gateway before you set it on one that developers use.
+
+`input_tagging` takes one of these values:
+
+`input_tagging`| Where the gateway tags text| After the guardrail blocks a prompt
+---|---|---
+`last_message`| The `user` messages since Claude’s last reply| In Claude Code, the next prompt can pass, and Claude then receives the blocked prompt as part of the conversation
+`user_messages`| `user` messages| Later prompts in the session can be blocked as well, until the developer removes the blocked prompt
+`all_messages`| `user` and `assistant` messages| Same as `user_messages`
+`all_messages_and_system`| The system prompt and every message, including [mid-conversation system messages](</docs/en/llm-gateway-protocol#feature-pass-through>)| Same as `user_messages`
+
+With `last_message`, if the `user` messages since Claude’s last reply hold no text to tag, the gateway tags the mid-conversation system messages since that reply instead. A tool call counts as a reply. Amazon Bedrock’s guidance for the prompt attacks filter is to [tag user input so that the system prompt is excluded](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-prompt-attack.html>). If you set `all_messages_and_system`, a filter that flags Claude Code’s own system prompt can block requests. The example below tags text in every `user` message:
+
+ upstreams:
+ - provider: bedrock
+ region: us-east-1
+ auth: {}
+ guardrail:
+ id: gr-abc123
+ version: "1"
+ input_tagging: user_messages
+
+`user` messages can also hold text that Claude Code adds, such as [system reminders](</docs/en/glossary#system-reminder>), so check on the test gateway that ordinary requests aren’t blocked. In Anthropic’s testing, a tagged session kept its [prompt cache](</docs/en/prompt-caching>) reads from one prompt to the next, and the tags added no input tokens.
+
+##### What input tags don’t cover
+
+No `input_tagging` value stops a developer who deliberately puts text where no tag goes. Don’t count on the guardrail to evaluate these parts of a request:
+
+ * **Content the gateway doesn’t tag** : messages that your `input_tagging` value leaves out, tool definitions, tool call inputs, images, and PDFs, among others. Unless you set `all_messages_and_system`, the system prompt is untagged too.
+ * **Tool results** : these hold what Claude’s tools return, such as file contents and web pages. In Anthropic’s testing, a word filter didn’t evaluate them, with or without tags.
+
+If your AWS account or organization enforces a guardrail, see [Amazon Bedrock’s documentation](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-enforcements.html>) for how that guardrail treats input tags.
##### Bedrock in another AWS account
@@ -768,7 +805,7 @@
`managed`
-The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; the first match is selected, then merged onto the `match: {}` catch-all base. They are served per-user at `GET /managed/settings` with ETag/304 caching.
+The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; by default the first match is selected, then merged onto the `match: {}` catch-all base. A user who matches two role policies gets only the first, so the second policy’s deny rules don’t apply unless you apply every matching policy. Policies are served per-user at `GET /managed/settings` with ETag/304 caching.
managed:
policies:
@@ -803,7 +840,7 @@
`match: { email_domain: example.com }`| Matches the part after the last `@` in the JWT’s `email` claim, case-insensitive. Accepts one domain per policy.
`match: { groups: [a], email_domain: example.com }`| Both conditions must match
-An authenticated user who matches no policy gets the gateway’s defaults, which means every model in the catalog and no managed settings. Add a `match: {}` catch-all last if you want a guaranteed default policy.
+An authenticated user who matches no policy gets the gateway’s defaults, which means every model in the catalog and no managed settings. Add a `match: {}` catch-all last if you want a guaranteed default policy. Put organization-wide deny rules in the `match: {}` policy, because a group policy’s rules apply only while the user’s token carries that group.
The gateway keeps no user directory of its own. It authorizes each request from the user’s IdP token, reading group membership from the token’s `groups` claim and evaluating policies against it. There is no roster to enumerate and no accounts to pre-create, and therefore no SCIM endpoint, because there is nothing for SCIM to sync into.Run user and group lifecycle management at the source of truth, which is your IdP’s native SCIM provisioning or a dedicated identity-governance platform. Membership and deprovisioning governed there flow into the gateway automatically through the token. If you want SCIM provisioning of Claude accounts themselves, that is a [Claude for Enterprise](</docs/en/admin-setup>) capability.Two propagation clocks apply:
@@ -811,6 +848,50 @@
* **Group membership** : changing a user’s group membership changes which policy matches them. This takes effect on the next session re-mint, meaning the next silent refresh, bounded by `session.ttl_hours`.
Claude Desktop follows its own schedule.
+
+####
+
+
+
+Apply every matching policy
+
+A user who matches several role policies gets only the first unless you set `policy_mode: layered` beside `policies`. With `layered`, every policy that matches the user applies, down to the first `match: {}` policy. `policy_mode` requires Claude Code v2.1.316 or later on the gateway server. A gateway on a version that lacks it refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. This example has one group that loses `WebFetch` and one that gains Opus:
+
+ managed:
+ policy_mode: layered
+ policies:
+ - match: { groups: [no-web] }
+ cli:
+ permissions: { deny: ["WebFetch"] }
+ - match: { groups: [opus-users] }
+ cli:
+ availableModels: [opus, sonnet]
+ - match: {}
+ cli:
+ availableModels: [sonnet]
+ enforceAvailableModels: true
+
+The table shows what a user in both `no-web` and `opus-users` receives under the default, `first_match`, and under `layered`.
+
+Setting| `first_match`| `layered`
+---|---|---
+`availableModels`| `sonnet`| `opus`, `sonnet`
+`enforceAvailableModels`| `true`| `true`
+`permissions.deny`| `WebFetch`| `WebFetch`
+
+The gateway merges each matching policy onto the ones listed below it, by the same merge rules as the base layer:
+
+ * **Allow-lists, single values, and blocks such as`sandbox`**: each comes whole from the first-listed matching policy that sets it, so two groups’ `availableModels` lists don’t add up.
+ * **Deny-lists and hook arrays** : these add up across every matching policy, so a user in two groups gets both groups’ deny rules.
+ * **`env`, `modelOverrides`, and `skillOverrides`**: entries merge by name, and the first-listed matching policy that sets a name supplies its value.
+ * **`desktop` keys**: these merge by the rules for the base `desktop` block.
+
+Policies can add up to looser rules than any one of them gives alone. For example, the `match: {}` policy sets `sandbox.enabled: true`, one group’s policy sets `permissions.allow: ["Bash"]`, and another group’s sets `sandbox.enabled: false`. A user in both groups receives `Bash` allowed with the sandbox off. In this case, list the policy that allows `Bash` first, and copy the `match: {}` policy’s whole `sandbox` block into it.
+
+With `layered`, the gateway refuses to start on some settings, including these:
+
+ * **A`!` pattern**: a [`!` negation](</docs/en/permissions#special-characters-and-negation>) in a `Read` or `Edit` rule in any policy’s `permissions.deny` or `permissions.ask` list, the `match: {}` policy’s included
+ * **A limit on hooks outside the catch-all** : `disableAllHooks`, `allowedHttpHookUrls`, or `httpHookAllowedEnvVars` in any policy other than `match: {}`
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -400,7 +400,7 @@
This example gives one model a custom id that only the isolated upstream serves:
models:
- - id: claude-opus-restricted # a custom id, not a built-in model name
+ - id: restricted-claude-opus-4-8 # a custom id, not a built-in model name
upstream_model:
bedrock-isolated: us.anthropic.claude-opus-4-8 # the only upstream that serves it
@@ -579,7 +579,12 @@
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. Every request starts at the first upstream. A request reaches a later upstream only when every upstream ahead of it has failed or doesn’t serve the requested model. The gateway keeps no record of failed upstreams, so while an upstream is down, every request that reaches it still tries it and waits for it to fail before moving on. For an Anthropic API upstream, `timeouts.upstream_ttfb_ms` bounds the wait on a down upstream. That setting doesn’t apply to the other providers, where the gateway waits up to one hour for an upstream to start responding. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. Every request starts at the first upstream. A request reaches a later upstream only when every upstream ahead of it has failed or doesn’t serve the requested model. The gateway keeps no record of failed upstreams, so while an upstream is down, every request that reaches it still tries it and waits for it to fail before moving on. The gateway waits this long for a response to start:
+
+ * **`provider: anthropic` upstreams**: `timeouts.upstream_ttfb_ms`, 120 seconds by default
+ * **Other providers** : up to one hour. To shorten that wait for streaming requests, set `timeouts.upstream_ttfb_ms` on gateway v2.1.295 or later. Non-streaming model requests wait up to one hour either way
+
+`404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
upstreams:
# Primary: provisioned throughput in your home region.
@@ -824,9 +829,11 @@
policies:
- match: { groups: [restricted-projects] }
cli:
- availableModels: [claude-opus-restricted]
+ availableModels: [restricted-claude-opus-4-8]
enforceAvailableModels: true
- model: claude-opus-restricted
+ model: restricted-claude-opus-4-8
+ env:
+ ANTHROPIC_DEFAULT_OPUS_MODEL: restricted-claude-opus-4-8 # opus and Default resolve to the ID too
####
@@ -1060,7 +1067,11 @@
##### Keys that need a later gateway or Claude Desktop version
-The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it.
+The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key.
+
+[`sshTransport`](<https://claude.com/docs/third-party/claude-desktop/configuration#sshtransport>) needs Claude Code v2.1.293 or later on the gateway server.
+
+If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it.
##### How a role policy inherits the base `desktop` block
@@ -1270,7 +1281,7 @@
`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
`limits`| `max_request_header_bytes`| unset| Lowers the gateway’s 256 KiB limit on a request’s total headers. A request over the limit returns `431`, and a value above 256 KiB has no effect. If developers get `431` after signing in, see [Request headers too large after sign-in](</docs/en/claude-apps-gateway-deploy#request-headers-too-large-after-sign-in>).
`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
-`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; on every other provider the gateway waits up to one hour for the response to start.
+`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. If the key is unset, the default applies to `provider: anthropic` upstreams, and on every other provider the gateway waits up to one hour for the response to start. To shorten that wait, see Multiple upstreams.
`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how to size it. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`. It is what stops someone from guessing another developer’s code. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how far to raise it.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -936,7 +936,7 @@
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
-[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -873,7 +873,10 @@
permissions: { deny: ["Read(./.env)"] }
desktop: {}
-When you switch, delete any `serve_to_desktop` line in the same edit that renames the blocks. Where an instruction names the `cli` block, use your `code` block.
+When you switch, delete any `serve_to_desktop` line in the same edit that renames the blocks. Where an instruction names the `cli` block, use your `code` block. `serve_to_desktop: true` is a legacy way to offer a policy’s `cli` settings to the Code tab. It has no effect when Claude Desktop connects through `bootstrapUrl`. While your policies use `cli`, a boot warning that names this key means those settings aren’t reaching the Code tab:
+
+ * **To cover the Code tab** : switch to `code`, once users’ machines meet the conditions in Apply `code` settings in the Code tab
+ * **To stay on`cli`**: set `serve_to_desktop: false` beside `cli` in a policy to silence the warning
####
@@ -918,7 +921,7 @@
---|---|---
`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
[`deniedModels`](</docs/en/settings-reference#deniedmodels>), [`availableModelsMatch`](</docs/en/settings-reference#availablemodelsmatch>)| Gateway + CLI| [Block specific models or versions](</docs/en/model-config#block-specific-models-or-versions>) that `availableModels` would otherwise permit. A blocked model is rejected with a `400` at `/v1/messages` and is left out of `/v1/models`. The gateway’s own check requires Claude Code v2.1.299 or later on the gateway server. The CLI’s check requires v2.1.283 or later on clients, and earlier clients ignore both keys.
-`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
+`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>) and [what a Bash rule doesn’t match](</docs/en/permissions#bash-rule-limits>).
`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that skips permission prompts, and the `--dangerously-skip-permissions` flag
`allowManagedPermissionRulesOnly`| CLI| When `true`, managed settings become the only settings source of permission rules. The [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) entry lists every source Claude Code then ignores.
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
@@ -934,6 +937,14 @@
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
+
+####
+
+
+
+Test a policy before deployment
+
+To test a policy change, start the gateway against a throwaway Postgres database. The gateway connects to Postgres and applies its schema migrations before it checks the contents of `cli`, `code`, and `desktop` blocks. When it can’t reach the database, the start stops at `could not connect to Postgres` and reports nothing about their contents.
####
@@ -1448,7 +1459,7 @@
# The contractors policy inherits this key.
enforceAvailableModels: true
permissions:
- allow: [Read, Grep, Bash, Edit]
+ allow: [Read, Grep, Edit]
deny: ["WebFetch"]
env: { HTTP_PROXY: http://proxy.example.com:8080 }
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -220,7 +220,7 @@
`postgres_url`| Yes| `postgres://` or `postgresql://` URL with one host, not a comma-separated list. The gateway runs its own schema migrations at boot and on upgrade, so the role needs rights to create and alter tables on the target schema. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
`username`| No| Overrides the user in `postgres_url`
`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
-`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
+`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the gateway makes a few database operations per inference request, so raise it for a dedicated database under load, within what [Size the connection pool](</docs/en/claude-apps-gateway-deploy#size-the-connection-pool>) allows.
`connect_timeout_seconds`| No| Seconds the gateway waits when it opens a Postgres connection. A whole number from `1` to `60`, default `5`. Raise it if connection attempts time out when a new gateway instance starts. Requires Claude Code v2.1.274 or later on the gateway server. Earlier versions refuse to start when the key is set.
`readiness_grace_seconds`| No| How many seconds `/readyz` keeps reporting ready after Postgres stops answering. A whole number from `0` to `3600`, default `0`. See [Outage behavior](</docs/en/claude-apps-gateway-deploy#outage-behavior>) for how to pick a value. Requires Claude Code v2.1.282 or later on the gateway server. Earlier versions refuse to start when the key is set.
@@ -623,7 +623,7 @@
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. A `mantle` upstream is tried only for the models listed in its `models` field. On every other upstream the gateway tries built-in models in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
-Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so failover doesn’t send a body field an upstream would reject.
+Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so by default failover doesn’t send a body field an upstream would reject. If you set the one-hour cache TTL in a policy, it goes to every upstream in the list, so set it only if all of them accept it.
##
@@ -951,6 +951,25 @@
CLAUDE_CODE_AUTO_COMPACT_WINDOW: "200000"
Claude Code applies this variable without showing the developer the approval dialog. The variable applies to every model, including model IDs that end in `[1m]`. To turn off 1M context instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"`](</docs/en/model-config#extended-context>) in the same `env` block. Claude Code then treats every model as having a 200K window. In interactive sessions, each developer approves this variable in the approval dialog before it takes effect.
+
+####
+
+
+
+One-hour prompt cache
+
+To request the one-hour [prompt cache TTL](</docs/en/prompt-caching#cache-lifetime>) instead of the default five minutes, add these keys to a policy’s existing `code`, `cli`, or `settings` block and restart the gateway. The keys need Claude Code v2.1.242 or later on the gateway server and on clients. `promptCacheTtl` covers the main conversation. `subagentPromptCacheTtl` is optional and covers subagents, workflows, and background requests. This example adds both to a `match: {}` policy keyed `cli`:
+
+ managed:
+ policies:
+ - match: {}
+ cli:
+ promptCacheTtl: 1h
+ subagentPromptCacheTtl: 1h
+
+Set the keys only if your upstreams offer the one-hour TTL for every model the gateway serves. If an upstream rejects the TTL, the request fails, and neither the gateway nor Claude Code retries it with the five-minute TTL. For Amazon Bedrock, check [supported models, regions, and limits](<https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html#prompt-caching-models>).
+
+To confirm `promptCacheTtl`, sign in to the gateway as a user the policy matches and [check which TTL your cache writes used](</docs/en/prompt-caching#choose-the-ttl-yourself>). Pass `--model` to repeat the check for each model the gateway serves. One-hour cache writes [cost more](</docs/en/prompt-caching#cache-lifetime>) than five-minute writes. For [spend limits](</docs/en/claude-apps-gateway-spend-limits#how-requests-are-priced>) to count that higher rate, you need v2.1.286 or later on the gateway server.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -783,7 +783,7 @@
A `match: {}` catch-all, conventionally listed last, is treated as a base layer. Every other policy inherits any key it doesn’t set from the catch-all, so per-role entries only need to list what differs from the org default. The merge rules depend on the key type:
* **Allow-lists** : `availableModels` and `permissions.allow`. A specific policy’s list fully replaces the base’s.
- * **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
+ * **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, `deniedModels`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
* **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. An empty list denies every model. The check also covers the model a session starts on before the developer picks one, so start sessions on a model the policy allows. The gateway validates the `model` value itself before it relays a request, so a malformed value never reaches an upstream. It rejects the request with a `400` in two cases:
@@ -917,6 +917,7 @@
Key| Enforced by| Effect
---|---|---
`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
+[`deniedModels`](</docs/en/settings-reference#deniedmodels>), [`availableModelsMatch`](</docs/en/settings-reference#availablemodelsmatch>)| Gateway + CLI| [Block specific models or versions](</docs/en/model-config#block-specific-models-or-versions>) that `availableModels` would otherwise permit. A blocked model is rejected with a `400` at `/v1/messages` and is left out of `/v1/models`. The gateway’s own check requires Claude Code v2.1.299 or later on the gateway server. The CLI’s check requires v2.1.283 or later on clients, and earlier clients ignore both keys.
`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that skips permission prompts, and the `--dangerously-skip-permissions` flag
`allowManagedPermissionRulesOnly`| CLI| When `true`, managed settings become the only settings source of permission rules. The [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) entry lists every source Claude Code then ignores.
@@ -975,7 +976,7 @@
The gateway derives much of the bootstrap response from the matched policy’s `cli` or `code` block and from top-level gateway config:
- * The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
+ * The model list, from `availableModels`. The list leaves out models that the policy blocks with `deniedModels` or `availableModelsMatch: exact`. This filter requires Claude Code v2.1.299 or later on the gateway server. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list. If the allowlist the gateway serves includes `*` and the gateway doesn’t also serve Claude Desktop’s [`allowedWorkspaceFolders`](<https://claude.com/docs/third-party/claude-desktop/code#applied-as-managed-policy>), Claude Desktop doesn’t turn on the [Bash sandbox](</docs/en/sandboxing>) in the Code tab
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -304,7 +304,9 @@
`x-claude-gateway-user-id`| The developer’s IdP subject, from the token’s `sub` claim.
`x-claude-gateway-user-email`| The developer’s email, when the IdP supplied one.
-When the IdP token carries no email, the gateway sends only `x-claude-gateway-user-id` and omits the two email headers. If your IdP puts the email in a different claim, set `oidc.email_claim` to that claim. When your proxy answers `429` to a request that carried the developer’s email, the gateway returns that response to the developer as-is instead of failing over to the next upstream, so your proxy’s per-user budget or rate limit holds. The proxy’s other responses follow the ordinary failover rules. If a developer’s IdP token carries no email, the gateway forwards their requests without the email headers, so a `429` to one of those requests counts as upstream capacity and fails over. Before v2.1.267 on the gateway server, every `429` failed over. Set `forward_user_identity` only on an upstream whose `base_url` is a proxy you operate. The gateway sends developer emails to whatever server that `base_url` names. If the `base_url` is the Anthropic API, which is the default, the gateway refuses to start.
+When the IdP token carries no email, the gateway sends only `x-claude-gateway-user-id` and omits the two email headers. If your IdP puts the email in a different claim, set `oidc.email_claim` to that claim. Your proxy doesn’t receive the [`x-claude-code-*` headers](</docs/en/llm-gateway-protocol#request-headers>) that Claude Code sends, such as `x-claude-code-session-id`. The gateway doesn’t pass them to any upstream, so group requests by developer with the headers in the table above. When your proxy answers `429` to a request that carried the developer’s email, the gateway returns that response to the developer as-is instead of failing over to the next upstream, so your proxy’s per-user budget or rate limit holds. The proxy’s other responses follow the ordinary failover rules. If a developer’s IdP token carries no email, the gateway forwards their requests without the email headers, so a `429` to one of those requests counts as upstream capacity and fails over. Before v2.1.267 on the gateway server, every `429` failed over. Set `forward_user_identity` only on an upstream whose `base_url` is a proxy you operate. The gateway sends developer emails to whatever server that `base_url` names. If the `base_url` is the Anthropic API, which is the default, the gateway refuses to start.
+
+If you set `forward_user_identity` on an Amazon Bedrock upstream, the gateway exits at startup with `Unrecognized key(s) in object: 'forward_user_identity'`. If your proxy sits in front of Bedrock, list it as a `provider: anthropic` upstream instead. The gateway sends that upstream the Anthropic Messages format, so your proxy has to [translate requests for Bedrock](</docs/en/llm-gateway-protocol#format-mismatch-with-the-upstream>). To name each developer to AWS instead, see Per-developer AWS cost attribution.
####
@@ -975,7 +977,7 @@
* The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
- * The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
+ * The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list. If the allowlist the gateway serves includes `*` and the gateway doesn’t also serve Claude Desktop’s [`allowedWorkspaceFolders`](<https://claude.com/docs/third-party/claude-desktop/code#applied-as-managed-policy>), Claude Desktop doesn’t turn on the [Bash sandbox](</docs/en/sandboxing>) in the Code tab
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response.
@@ -1137,6 +1139,21 @@
* **Locally configured endpoints** : with OTLP/HTTP export enabled, the CLI ignores any locally configured endpoint, whether or not the gateway pushed the telemetry variables. Its exports go to the gateway unless a policy names your collector as the endpoint.
Without a `forward_to` destination for a signal, the gateway accepts and discards it. If developers already export Claude Code telemetry to one of your collectors, add it as a `forward_to` destination, with logs or traces enabled if they export those, so it keeps receiving their data after they sign in. To skip the relay instead, name the collector in a policy. [Traces](</docs/en/monitoring-usage#traces-beta>) also require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. Set it in a managed policy’s `env` block, since the gateway doesn’t push it. Developers approve it in the same security approval dialog that the pushed endpoint already triggers. Set it to `1` only in the policies whose groups you want traced. A policy that doesn’t set it inherits the value from your `match: {}` catch-all policy if that policy sets one, per the merge rules. To keep a group’s clients from sending traces even when a developer sets the variable locally, set it to `0` in that group’s policy. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+
+####
+
+
+
+Send cumulative metrics
+
+If your collector accepts only cumulative metrics, set [`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`](</docs/en/monitoring-usage#common-configuration-variables>) to `cumulative`. Claude Code sends delta metrics by default, and the gateway relays them without converting them. Set the variable where each kind of session reads it:
+
+ * **Terminal sessions** : in the `env` block under a policy’s `cli` or `code` key
+ * **Cowork sessions that[run on the user’s machine](</docs/en/managed-settings#where-and-when-a-policy-applies>)**: in the `env` block of the client-side managed settings on that machine
+ * **Code tab sessions under a`code` policy**: in the policy’s `env` block, once you meet the conditions for `code` settings to apply
+ * **Code tab sessions under a`cli` policy**: in the `env` block of the client-side managed settings on the machine that runs the session. Over SSH, that’s the remote host.
+
+If you add the variable to a machine’s managed settings, also set [`parentSettingsBehavior: "merge"`](</docs/en/claude-apps-gateway#set-the-opt-in>) in the highest-priority source on that machine. Without it, Cowork sessions and Code tab sessions under a `cli` policy run without the egress allowlist and other policy that Claude Desktop passes them as parent settings.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -930,7 +930,7 @@
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
-[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1435,7 +1435,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. To stop developers from bypassing the gateway with a cloud provider variable or an `ANTHROPIC_BASE_URL` of their own, add `"allowedProviders": ["gateway"]` to the same file. Claude Code then refuses every session on the machine that isn’t set up for a Cloud gateway, and admits a gateway only when it is the one `forceLoginGatewayUrl` names or one whose URL the file’s `env` block sets as `ANTHROPIC_BASE_URL`. `claude gateway` refuses to run on a machine that sets the list, so keep the key off the gateway host. See the [`allowedProviders`](</docs/en/settings-reference#allowedproviders>) entry in the settings reference. Requires Claude Code v2.1.285 or later. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in a developer’s own `~/.claude/settings.json` or in the gateway payload doesn’t configure the gateway sign-in. Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. To stop developers from bypassing the gateway with a cloud provider variable or an `ANTHROPIC_BASE_URL` of their own, add `"allowedProviders": ["gateway"]` to the same file. Claude Code then refuses every session on the machine that isn’t set up for a Cloud gateway, and admits a gateway only when it is the one `forceLoginGatewayUrl` names or one whose URL the file’s `env` block sets as `ANTHROPIC_BASE_URL`. `claude gateway` refuses to run on a machine that sets the list, so keep the key off the gateway host. See the [`allowedProviders`](</docs/en/settings-reference#allowedproviders>) entry in the settings reference. Requires Claude Code v2.1.285 or later. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in the gateway payload doesn’t configure the gateway sign-in. For a developer’s own `~/.claude/settings.json`, see [Set the gateway URL in user settings](</docs/en/claude-apps-gateway#set-the-gateway-url-in-user-settings>). Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
##
Show diff (114 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -850,9 +850,36 @@
+Choose `cli` or `code`
+
+When a policy uses the `code` key, each of these stops the gateway from starting:
+
+ * **Gateway version** : `code` requires Claude Code v2.1.296 or later on the gateway server. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and change `code` back to `cli` before you roll back to an earlier version.
+ * **Mixed keys** : a file that has both `code` and `cli`, or its earlier spelling `settings`, stops the gateway at boot. Put every block under one key, in one edit.
+
+A policy’s Claude Code settings, such as a rule that denies reading `.env` files, go in a block under the `cli` or `code` key. `code` is the recommended key, and `cli` is the legacy key. Both keys take the same contents. The key decides where the settings are enforced:
+
+ * **`cli`** : the terminal, the VS Code and JetBrains extensions, and the Agent SDK. Under `cli`, Claude Desktop’s Code tab gets the derived settings, so a scoped rule such as `Read(./.env)` doesn’t stop a user there.
+ * **`code`** : the same places, and Claude Desktop’s Code tab can be covered too.
+
+A file that uses `cli` works as it did, and a gateway that finds `cli` in a policy with a `desktop` key warns at boot and starts anyway. Switch to `code` so that the settings can also cover the Code tab. Before you switch, read Apply `code` settings in the Code tab. The policy needs a `desktop` key and users’ machines need setup before the settings apply there, and web search turns off in Claude Desktop. This policy puts the deny rule under `code`, with an empty `desktop` key:
+
+ managed:
+ policies:
+ - match: {}
+ code:
+ permissions: { deny: ["Read(./.env)"] }
+ desktop: {}
+
+When you switch, delete any `serve_to_desktop` line in the same edit that renames the blocks. Where an instruction names the `cli` block, use your `code` block.
+
+####
+
+
+
What goes in `cli`
-Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys include `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
+Each `code` or `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys include `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
managed:
policies:
@@ -903,7 +930,7 @@
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
-[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p` or an Agent SDK session, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p`, an Agent SDK session, or a session in Claude Desktop’s Code tab, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases, and the gateway still accepts that spelling as an alias. For new deployments, use `code`.
####
@@ -944,7 +971,7 @@
##### Settings the gateway derives for Claude Desktop
-The gateway derives much of the bootstrap response from the matched policy’s `cli` block and from top-level gateway config:
+The gateway derives much of the bootstrap response from the matched policy’s `cli` or `code` block and from top-level gateway config:
* The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
@@ -952,6 +979,23 @@
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response.
+
+##### Apply `code` settings in the Code tab
+
+The Claude Code settings a policy holds under its `code` key apply in Claude Desktop’s Code tab when all of these hold:
+
+ * The policy also has a `desktop` key, and an empty `desktop: {}` counts
+ * Claude Desktop is version 2.9939.2 or later
+ * The Claude Code managed settings on the machine name this gateway
+ * That machine reaches the gateway over HTTPS on a private network
+
+The last two conditions apply to whichever machine runs Claude Code for the session. For a local session, that is the user’s own computer. For a Code tab session over SSH, it is the remote host. Deploy the client-side managed settings to those machines before you rename `cli` to `code`. When the first two conditions hold and either of the last two fails, a user the policy matches gets one of these results:
+
+ * **Over HTTPS, where Claude Desktop bundles Claude Code v2.1.296 or later** : the Code tab doesn’t start, and the reply to the user’s prompt says why
+ * **Over HTTPS, where Claude Desktop bundles an earlier version** : the Code tab starts without your `code` settings, and nothing in the session says so
+ * **Over plain HTTP** : the Code tab starts without your `code` settings, whichever version Claude Desktop bundles
+
+When a proxy in front of the gateway answers `/managed/settings` with its own 404, the Code tab also starts without your `code` settings, including on a machine that meets all four conditions. In a policy that has a `desktop` key, a `code` block that holds settings turns off the WebSearch tool in Cowork, Chat, and the Code tab. For MCP servers, see [Where `managedMcpServers` applies](</docs/en/managed-mcp#where-managedmcpservers-applies>).
##### Set Claude Desktop settings directly
@@ -1053,7 +1097,7 @@
`telemetry`
-The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Events that Claude Code logs before the developer signs in [don’t carry this identity](</docs/en/monitoring-usage#standard-attributes>). Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
+The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Events that Claude Code logs before the developer signs in [don’t carry this identity](</docs/en/monitoring-usage#standard-attributes>). To see which attribute follows a change in a developer’s groups, see Group changes during an open session. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
telemetry:
forward_to:
@@ -1118,6 +1162,22 @@
* Values are text, so quote a number, `true`, or `false`
You need Claude Code v2.1.281 or later on the gateway server to set `telemetry.resource_attributes`. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. Terminal sessions signed in through `/login` receive the labels as `OTEL_RESOURCE_ATTRIBUTES`, pushed with the other telemetry variables. If you set `OTEL_RESOURCE_ATTRIBUTES` in a policy’s `env` block, terminal sessions that policy matches get that value instead of the labels. Claude Desktop receives the labels from the gateway alongside `user.email` and the other identity attributes. Claude Code also copies each label onto every metric data point, so you can filter metrics by it in a backend that doesn’t index resource attributes. To turn that copy off, see [Metrics cardinality control](</docs/en/monitoring-usage#metrics-cardinality-control>).
+
+####
+
+
+
+Group changes during an open session
+
+Terminal sessions put `user.groups` on the OTLP resource and again on each metric data point and event. If a developer’s groups change while a session is open, data points and events for usage after the next silent refresh carry the new groups. The resource keeps the old groups until the developer restarts Claude Code, so group by the attribute on the data point or event. If you turn on `resource_to_telemetry_conversion` in the OpenTelemetry Collector’s Prometheus remote write exporter, the exporter replaces each data point’s `user.groups` with the resource’s, so every data point shows the old groups. To keep the data point’s value, delete `user.groups` from the resource ahead of that exporter. This OpenTelemetry Collector `resource` processor deletes the attribute in the pipelines that list it:
+
+ processors:
+ resource/drop-user-groups:
+ attributes:
+ - key: user.groups
+ action: delete
+
+After you add `resource/drop-user-groups` to the metrics pipeline’s `processors`, each series carries the `user_groups` label from its own data point.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1053,7 +1053,7 @@
`telemetry`
-The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
+The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Events that Claude Code logs before the developer signs in [don’t carry this identity](</docs/en/monitoring-usage#standard-attributes>). Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
telemetry:
forward_to:
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -800,8 +800,10 @@
The gateway keeps no user directory of its own. It authorizes each request from the user’s IdP token, reading group membership from the token’s `groups` claim and evaluating policies against it. There is no roster to enumerate and no accounts to pre-create, and therefore no SCIM endpoint, because there is nothing for SCIM to sync into.Run user and group lifecycle management at the source of truth, which is your IdP’s native SCIM provisioning or a dedicated identity-governance platform. Membership and deprovisioning governed there flow into the gateway automatically through the token. If you want SCIM provisioning of Claude accounts themselves, that is a [Claude for Enterprise](</docs/en/admin-setup>) capability.Two propagation clocks apply:
- * **Policy contents** : editing a policy and redeploying reaches connected clients on their next managed-settings poll, within an hour, apart from the [changes that apply only at the next launch](</docs/en/server-managed-settings#fetch-and-caching-behavior>)
+ * **Policy contents** : editing a policy and redeploying reaches connected Claude Code clients on their next managed-settings poll, within an hour, apart from the [changes that apply only at the next launch](</docs/en/server-managed-settings#fetch-and-caching-behavior>)
* **Group membership** : changing a user’s group membership changes which policy matches them. This takes effect on the next session re-mint, meaning the next silent refresh, bounded by `session.ttl_hours`.
+
+Claude Desktop follows its own schedule.
####
@@ -938,14 +940,22 @@
Requires Claude Code v2.1.203 or later on the gateway server, and an explicit opt-in: `/user/bootstrap` returns 404 unless the policy matching the user carries a `desktop` key. An empty `desktop: {}` opts a policy in, and a `desktop` key on the `match: {}` base layer opts in every policy that inherits it. The audit log records each request as `desktop_bootstrap.serve` or `desktop_bootstrap.denied`.
-The gateway derives much of the response from the matched policy’s `cli` block and from top-level gateway config:
+If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; the gateway then returns 404 from `/user/bootstrap` for every user.
+
+##### Settings the gateway derives for Claude Desktop
+
+The gateway derives much of the bootstrap response from the matched policy’s `cli` block and from top-level gateway config:
* The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
-To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
+To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response.
+
+##### Set Claude Desktop settings directly
+
+Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. This example sets three Claude Desktop keys for the `eng-contractors` group alongside its `cli` settings:
managed:
policies:
@@ -958,19 +968,40 @@
disableAutoUpdates: true
banner: { text: "Contractor build: internal use only" }
-Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway validates each `desktop` block at boot against the configuration schema Claude Desktop itself uses, so a mistake surfaces at gateway start as an error naming the key rather than reaching every connected desktop. The gateway fails at boot when a block contains:
+Every key is optional; Claude Desktop applies its own default for any key you omit.
+
+##### What the gateway rejects at boot
+
+The gateway validates each `desktop` block at boot against the configuration schema Claude Desktop itself uses, so a mistake surfaces at gateway start as an error naming the key rather than reaching every connected desktop. The gateway fails at boot when a block contains:
* An unknown key
* A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value or a misspelled sub-key inside a nested entry. Before v2.1.260, the gateway silently dropped a misspelled field inside a nested object of a `managedMcpServers` or `orgPluginSettings` entry instead of failing at boot.
* A key the gateway computes itself: the inference connection, the model list, and the OTLP relay. Configure those through `upstreams`, `models`, and the `telemetry` section’s `forward_to`.
* A legacy alias of a current key. In the boot error, the gateway names the canonical key to write.
-If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
+If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
+
+##### Keys that need a later gateway or Claude Desktop version
+
+The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it.
+
+##### How a role policy inherits the base `desktop` block
+
+The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
* `disabledBuiltinTools`: the gateway uses the union of the base’s list and the policy’s list
* `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
-For every other key, if you set it in the role policy, the gateway uses the role policy’s value. The gateway replaces an array or a nested object such as `banner` whole, so if you set `banner.text` in a role policy, the gateway drops the base’s `banner.backgroundColor`. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; the gateway then returns 404 from `/user/bootstrap` for every user.
+For every other key, if you set it in the role policy, the gateway uses the role policy’s value. The gateway replaces an array or a nested object such as `banner` whole, so if you set `banner.text` in a role policy, the gateway drops the base’s `banner.backgroundColor`.
+
+##### When a policy change reaches Claude Desktop
+
+After you redeploy the gateway with a changed policy, Claude Desktop applies most settings only when it next starts:
+
+ * **Closed** : Claude Desktop fetches the bootstrap response when it starts, so the change applies from the next start
+ * **Open** : Claude Desktop checks for a changed response every 10 minutes by default and applies a few settings without a restart. For the rest, such as [`skillCreationEnabled`](<https://claude.com/docs/third-party/claude-desktop/configuration#skillcreationenabled>), the user sees a **Relaunch Claude Desktop** card in the sidebar and keeps the previous configuration until they restart the app. After 24 hours by default, Claude Desktop shows a restart dialog and restarts on its own after 2 minutes of inactivity
+
+To shorten the 24 hours, set [`relaunchEnforcementHours`](<https://claude.com/docs/third-party/claude-desktop/configuration#relaunchenforcementhours>) in the policy’s `desktop` block. You need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.40609.0 or later on members’ machines. With `0`, the dialog appears as soon as Claude Desktop finds the change.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -152,8 +152,8 @@
The gateway reads the key and certificate once at boot, so a changed file takes effect only after a restart. Rotate in this order so that no token request presents a certificate the IdP doesn’t have:
1. Upload the new certificate to the IdP alongside the old one.
- 2. Replace the key and certificate files that `gateway.yaml` loads, then restart the gateway.
- 3. Remove the old certificate from the IdP.
+ 2. Replace the key and certificate files that `gateway.yaml` loads, then restart the gateway. If you run several replicas, a [rolling restart](</docs/en/claude-apps-gateway-deploy#upgrades>) works, because the IdP has both certificates until you remove the old one.
+ 3. After every replica has restarted, remove the old certificate from the IdP.
####
@@ -217,7 +217,7 @@
Field| Required| Description
---|---|---
-`postgres_url`| Yes| `postgres://` or `postgresql://` URL. Required: the device-grant rendezvous, where the browser callback writes and the polling CLI reads, needs cross-replica state. The gateway runs its own schema migrations at boot and on upgrade, so the role needs rights to create and alter tables on the target schema. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
+`postgres_url`| Yes| `postgres://` or `postgresql://` URL with one host, not a comma-separated list. The gateway runs its own schema migrations at boot and on upgrade, so the role needs rights to create and alter tables on the target schema. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
`username`| No| Overrides the user in `postgres_url`
`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -232,7 +232,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the credential the gateway used against that upstream failed. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the upstream rejected the credential the gateway used, or denied it access, for example to the requested model. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
Show diff (172 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -355,7 +355,7 @@
The gateway doesn’t support guardrail input tags. It adds no guard content tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation.
-Also grant `bedrock:ApplyGuardrail` on the guardrail to the principal that signs this upstream’s requests: the gateway’s AWS principal, or with `assume_role` the role named in `role_arn`. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
+Also grant `bedrock:ApplyGuardrail` on the guardrail to the principal that signs this upstream’s requests: the gateway’s AWS principal, or with `assume_role` the role named in `role_arn`. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail, or refuses to start if that provider is `mantle`. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
##### Bedrock in another AWS account
@@ -393,7 +393,7 @@
* If STS refuses or is unreachable, the gateway doesn’t send the request with the upstream’s own credentials. It logs the STS error with what to check, then tries the next upstream you listed. Upstream error messages covers what the client receives when no upstream succeeds. A later upstream without `assume_role` would serve the request with its own credentials, so list one only if that is what you want.
* The gateway calls the regional STS endpoint `sts.<region>.amazonaws.com`, which its network must reach. For the FIPS endpoint, set `AWS_USE_FIPS_ENDPOINT=true` in the gateway’s environment rather than `use_fips_endpoint` in an AWS config file.
* `assume_role` applies to `provider: bedrock` only and needs SigV4 source credentials: the gateway refuses to start when it’s set beside `aws_bearer_token`.
- * Every developer the gateway admits can use this upstream; `managed` governs which developers may use which models. To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account. Built-in model names are still tried on every upstream in order, this one included, and a request that reaches it is signed with the same role, so list this upstream last unless its account should also serve them.
+ * Every developer the gateway admits can use this upstream; `managed` governs which developers may use which models. To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account. A request for a built-in model name can still reach this upstream, and the gateway signs it with the same role. List this upstream last unless its account should also serve those models.
This example gives one model a custom id that only the isolated upstream serves:
@@ -415,6 +415,39 @@
session_name: email # or sub
`session_name` selects which verified claim becomes the AWS `RoleSessionName`: `email` or `sub`. The gateway writes any character other than ASCII letters, digits, and `_+,.@-` as `=XX` hex per UTF-8 byte, and shortens a result longer than 64 characters to a prefix plus a hash, so each developer’s session name stays valid and unique. A request from a developer whose token lacks the claim isn’t sent through this upstream, and the operator log says to switch to `sub` or set `oidc.email_claim`. An active developer costs one STS call per hour per gateway replica, and concurrent first requests share one call. The gateway also makes one call of its own on this role: the token count for a request the client abandoned, so that [spend limits](</docs/en/claude-apps-gateway-spend-limits>) stay accurate. That count and its one-token fallback request are signed by the shared `claude-apps-gateway` session, so AWS attributes the fallback to `claude-apps-gateway` rather than to the developer. For strict per-developer attribution, set `assume_role` with `session_name` on every Bedrock upstream you list. An upstream without it signs the requests it serves with its own credentials.
+
+####
+
+
+
+Amazon Bedrock Mantle endpoint
+
+The `mantle` provider sends inference to Amazon Bedrock’s [Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>). It requires Claude Code v2.1.283 or later on the gateway server. Earlier gateway releases reject it at boot, so upgrade every replica before adding it. The example below puts Mantle first, with an Amazon Bedrock upstream behind it to serve every model the `models` field leaves out:
+
+ upstreams:
+ - provider: mantle
+ region: us-east-1
+ models: [claude-opus-4-7, claude-haiku-4-5] # required
+ auth: {} # AWS default credential chain
+ - provider: bedrock
+ region: us-east-1
+ auth: {}
+
+The table below lists the fields specific to a `mantle` upstream.
+
+Field| Required| Description
+---|---|---
+`region`| Yes| AWS region. The gateway derives the endpoint from it as `https://bedrock-mantle.<region>.api.aws/anthropic`.
+`models`| Yes| The models your AWS account has been granted on Mantle, named as clients send them, such as `claude-haiku-4-5`. Only these go to this upstream, and every other model skips to the next one.
+`auth`| No| Takes the same keys as the Amazon Bedrock upstream’s `auth` block, under the same rules.
+`base_url`| No| Override the derived endpoint. Keep the `/anthropic` path at the end.
+
+Grant the upstream’s AWS identity Mantle’s own IAM actions for inference and token counting, which [Use the Mantle endpoint](</docs/en/amazon-bedrock#use-the-mantle-endpoint>) lists. For a Mantle model ID that the gateway doesn’t know, add an entry to the top-level `models:` block whose `upstream_model` maps this upstream’s name to that ID. Then put that entry’s `id` in this upstream’s `models` field too. A `bedrock` upstream’s `guardrail` and `assume_role` settings don’t extend to the requests Mantle serves:
+
+ * **`guardrail`** : the gateway applies no Bedrock guardrail to requests it sends to Mantle, so it refuses to start when a `mantle` upstream is listed while any `bedrock` upstream sets `guardrail`.
+ * **`assume_role`** : a `mantle` upstream takes no `assume_role`. Requests that Mantle serves are sent with the `mantle` upstream’s own `auth` credentials, and aren’t attributed per developer.
+
+For what Mantle’s own error responses mean, see [Mantle endpoint errors](</docs/en/amazon-bedrock#mantle-endpoint-errors>).
####
@@ -586,7 +619,7 @@
Different accounts| One Amazon Bedrock upstream per account. The default chain (`auth: {}`) uses the pod’s identity; for a second account, add `assume_role` to reach it with short-lived credentials, or set explicit credentials or a bearer token in `auth:`.
Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
-Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. The gateway tries built-in models on every upstream in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
+Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. A `mantle` upstream is tried only for the models listed in its `models` field. On every other upstream the gateway tries built-in models in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so failover doesn’t send a body field an upstream would reject.
@@ -741,6 +774,9 @@
- match: {}
cli:
availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+ # Make the Default option in /model resolve inside each policy's
+ # list. The eng-contractors policy inherits enforceAvailableModels.
+ enforceAvailableModels: true
A `match: {}` catch-all, conventionally listed last, is treated as a base layer. Every other policy inherits any key it doesn’t set from the catch-all, so per-role entries only need to list what differs from the org default. The merge rules depend on the key type:
@@ -748,7 +784,7 @@
* **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
* **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
-`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. The gateway validates the `model` value itself before it relays a request, so a malformed value never reaches an upstream. It rejects the request with a `400` in two cases:
+`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. An empty list denies every model. The check also covers the model a session starts on before the developer picks one, so start sessions on a model the policy allows. The gateway validates the `model` value itself before it relays a request, so a malformed value never reaches an upstream. It rejects the request with a `400` in two cases:
* When the value is missing or empty, the gateway rejects the request with the message `model is required`. That check requires a gateway running Claude Code v2.1.228 or later.
* When the value is present but isn’t a string, the gateway rejects the request with the message `model must be a string`. Requires a gateway running Claude Code v2.1.221 or later.
@@ -771,6 +807,27 @@
+Start sessions on a model the policy allows
+
+If `availableModels` leaves out Claude Code’s default model, sessions get `400` responses until the developer picks a listed model, for example with `/model`. In gateway sessions the default is the Opus model the `opus` alias resolves to, and `availableModels` on its own doesn’t change it. To fix this, set [`enforceAvailableModels: true`](</docs/en/model-config#enforce-the-allowlist-for-the-default-model>) in the same `cli` block, then check which kind of entry the list has:
+
+ * **An alias such as`sonnet`, or a built-in ID such as `claude-sonnet-4-6`**: sessions start on one of those models, and the Default option in `/model` resolves to it
+ * **No alias or built-in ID in the list** : sessions can keep starting on the built-in default, so also set [`model`](</docs/en/model-config#control-the-model-users-run-on>) to one of the listed IDs in that policy’s `cli` block
+
+This policy lists one custom ID that `models` defines, and starts sessions on that ID:
+
+ managed:
+ policies:
+ - match: { groups: [restricted-projects] }
+ cli:
+ availableModels: [claude-opus-restricted]
+ enforceAvailableModels: true
+ model: claude-opus-restricted
+
+####
+
+
+
Matcher values that stop the gateway at boot
At boot, the gateway checks the `match` block of every policy and the `admin_groups` list. Any of these values stops the gateway with an error that names the field:
@@ -801,6 +858,7 @@
cli:
# Model access (also enforced server-side at /v1/messages)
availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+ enforceAvailableModels: true # Default resolves inside the list
# Permission policy
permissions:
@@ -894,6 +952,7 @@
- match: { groups: [eng-contractors] }
cli:
availableModels: [claude-sonnet-4-6]
+ enforceAvailableModels: true
desktop:
isLocalDevMcpEnabled: false
disableAutoUpdates: true
@@ -1205,6 +1264,11 @@
# region: us-east-1
# auth: {}
+ # - provider: mantle
+ # region: us-east-1
+ # models: [claude-opus-4-8, claude-opus-4-7, claude-haiku-4-5]
+ # auth: {}
+
# - provider: anthropicAws
# region: us-east-1
# workspace_id: wrkspc_...
@@ -1227,6 +1291,7 @@
upstream_model:
anthropic: claude-opus-4-8
# bedrock: us.anthropic.claude-opus-4-8
+ # mantle: anthropic.claude-opus-4-8
# anthropicAws: claude-opus-4-8
# vertex: claude-opus-4-8
# foundry: <your-opus-deployment-name>
@@ -1244,15 +1309,16 @@
- match: { groups: [contractors] }
cli:
availableModels: [claude-haiku-4-5]
- # Constrain the Default picker option to availableModels instead of
- # the tier default, so contractors don't get a 400 on the default.
- enforceAvailableModels: true
# allow auto-approves these tools; it does not block the rest.
# Add deny rules to restrict tools.
permissions: { allow: [Read, Grep] }
- match: {}
cli:
availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+ # Constrain the Default picker option to each policy's availableModels
+ # instead of the built-in default, so no role gets a 400 on Default.
+ # The contractors policy inherits this key.
+ enforceAvailableModels: true
permissions:
allow: [Read, Grep, Bash, Edit]
deny: ["WebFetch"]
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -71,7 +71,8 @@
Field| Required| Description
---|---|---
`issuer`| Yes| OIDC discovery base. Must serve discovery at `/.well-known/openid-configuration`. Use HTTPS in production; the gateway accepts an `http://` issuer. A loopback issuer such as `http://localhost:8081` is rejected by the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) unless `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` is set in the gateway’s environment.
-`client_id` / `client_secret`| Yes| From your OAuth client registration
+`client_id`| Yes| From your OAuth client registration
+`client_secret`| Unless `token_endpoint_auth_method` is `private_key_jwt`| From your OAuth client registration. Leave it out when you use certificate client authentication.
`allowed_email_domains`| No| Reject id_tokens whose `email` claim isn’t in one of these domains, case-insensitive. Defense-in-depth against multi-tenant IdP misconfiguration. Independent of this setting, an id_token whose `email_verified` claim is explicitly `false` is always rejected.
`allowed_groups`| No| Restrict sign-in to members of these IdP groups, matched against `groups_claim`. A user in an allowed email domain but in none of these groups is rejected. Requires the IdP to emit the groups claim. Matching is an exact, case-sensitive string comparison against the values in that claim, and the gateway doesn’t expand nested groups: to admit members of a sub-group, list the sub-group here or configure the IdP to emit flattened membership.
`groups_claim`| No| Which id_token claim carries group membership. Default `groups`. Microsoft Entra emits app roles under `roles`. Accepts a flat key or an RFC 6901 JSON Pointer such as `/resource_access/gateway/roles` for nested claims.
@@ -83,13 +84,76 @@
`userinfo_fallback`| No| When the id_token omits email or groups, fetch them from `/userinfo`. Needed for Keycloak lightweight access tokens, the Okta org server, and ADFS minimal tokens. The id_token stays authoritative; userinfo only fills gaps. Default `false`.
`use_pkce`| No| Send a PKCE (S256) challenge on the authorization request. Default `true`. Set `false` only if your IdP rejects PKCE for this confidential client.
`clock_skew_seconds`| No| Tolerate clock drift when validating id_token time claims. Default `0`, which is strict. Raise if you see “token expired / not yet valid” errors right after sign-in due to host/IdP clock skew.
-`token_endpoint_auth_method`| No| Override the token-endpoint auth method. Accepts `client_secret_basic` or `client_secret_post`. Auto-negotiated by default.
+`token_endpoint_auth_method`| No| How the gateway authenticates to the IdP’s token endpoint: `client_secret_basic`, `client_secret_post`, or `private_key_jwt` for certificate client authentication. By default the gateway picks one of the two `client_secret` methods from what the IdP advertises.
+`client_assertion`| With `private_key_jwt`| A block with `private_key_pem` and `certificate_pem`: the private key and certificate for certificate client authentication. Requires v2.1.284 or later.
`id_token_signed_response_alg`| No| Expected id_token signing algorithm. Default `RS256`. Set for IdPs that sign with ES256, PS256, or EdDSA.
`additional_authorized_parties`| No| Extra `azp` values to accept beyond `client_id`, for Keycloak broker and token-exchange flows
`discovery_url`| No| Fetch the discovery document from this URL instead of deriving it from `issuer`, for IdPs behind a proxy that rewrites the issuer host. The path must contain `/.well-known/`.
`use_proxy`| No| Send the gateway’s own IdP requests through the forward proxy in `HTTPS_PROXY` or `HTTP_PROXY`, honoring `NO_PROXY`. `false` keeps those requests direct. Requires v2.1.227 or later; see IdP requests through a forward proxy below.
`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
`ca_cert_pem`| No| The PEM-encoded CA certificate itself, not a path to a file. It replaces the system trust store for IdP requests only. To load a mounted file, write `${file:/etc/gateway/idp-ca.pem}`. Use for Keycloak or Dex behind corporate PKI.
+
+####
+
+
+
+Certificate client authentication
+
+If your identity provider authenticates OAuth clients with a certificate instead of a client secret, as Microsoft Entra does with certificate credentials, set `token_endpoint_auth_method: private_key_jwt`. Requires Claude Code v2.1.284 or later on the gateway server. With this configuration the gateway sends no secret. It authenticates to the IdP’s token endpoint with a short-lived JWT signed with the certificate’s private key when a developer signs in and each time the gateway refreshes their session. The JWT is signed with RS256 and identifies the certificate by `x5t` and `x5t#S256` thumbprint headers rather than a `kid`. Your IdP must be able to find the registered certificate by thumbprint.
+
+1
+
+Create the key and certificate
+
+Create an unencrypted RSA private key of at least 2048 bits, in PKCS#8 or PKCS#1 PEM form, and a certificate for it. The gateway refuses to start with any key that doesn’t meet these conditions. This `openssl` command creates such a key with a self-signed certificate that is valid for one year:
+
+ openssl req -x509 -newkey rsa:2048 -nodes -keyout idp-client.key -out idp-client.crt -days 365 -subj "/CN=claude-gateway"
+
+It writes `idp-client.key` and `idp-client.crt` to the current directory. Copy or mount both files where the gateway can read them. The example in step 3 uses `/etc/gateway/`.
+
+2
+
+Upload the certificate to the IdP
+
+Upload the certificate, not the private key, to the gateway’s app registration at the IdP.
+
+3
+
+Add the key and certificate to gateway.yaml
+
+Give the gateway the private key and the certificate in a `client_assertion` block. Leave `client_secret` out, because the gateway refuses to start when one is set together with `private_key_jwt`. This `oidc` block authenticates the gateway to a Microsoft Entra tenant with a certificate:
+
+ oidc:
+ issuer: https://login.microsoftonline.com/<tenant-id>/v2.0
+ client_id: <application-id>
+ token_endpoint_auth_method: private_key_jwt
+ client_assertion:
+ private_key_pem: ${file:/etc/gateway/idp-client.key}
+ certificate_pem: ${file:/etc/gateway/idp-client.crt}
+
+Both values are the PEM contents, not file paths, so load mounted files with `${file:/path}` as the example does. The gateway refuses to start unless `certificate_pem` is a single PEM certificate, without the rest of its chain, whose public key matches `private_key_pem`.
+
+4
+
+Restart the gateway and check the boot log
+
+Restart the gateway and find this line in the boot log:
+
+ [gateway] 2026-10-01T23:07:40.512Z info oidc: client authentication private_key_jwt; certificate CN=claude-gateway, SHA-1 thumbprint DE92821854EE8BAA1D98C758FAA04AABE80B9F57, expires Oct 1 23:07:31 2027 GMT
+
+Compare the SHA-1 thumbprint with the one the IdP shows for the certificate you uploaded. If the certificate has expired or isn’t valid yet, the gateway still starts but logs a warning that sign-ins and refreshes will fail until you replace it. To confirm that the IdP accepts the certificate, have one developer sign in through the gateway.
+
+####
+
+
+
+Rotate the client certificate
+
+The gateway reads the key and certificate once at boot, so a changed file takes effect only after a restart. Rotate in this order so that no token request presents a certificate the IdP doesn’t have:
+
+ 1. Upload the new certificate to the IdP alongside the old one.
+ 2. Replace the key and certificate files that `gateway.yaml` loads, then restart the gateway.
+ 3. Remove the old certificate from the IdP.
####
@@ -1006,7 +1070,7 @@
---|---|---|---
`access_control`| `allow_cidrs` / `deny_cidrs`| empty| Inbound IP allow/deny by client address, after `trusted_proxies` resolution. `deny_cidrs` is checked first; a client it matches is rejected even if `allow_cidrs` also matches. If `allow_cidrs` is non-empty the gateway is default-deny. `/healthz` and `/readyz` are exempt from `allow_cidrs`. When a trusted proxy sends an `X-Forwarded-For` entry that isn’t an IP address, the real client is unknown and the gateway logs a warning once naming what to check. Where either list applies to the request, it refuses it with `403` and audit reason `xff_unparseable`. Where neither does, it serves the request and uses the proxy’s own address as the client IP for per-IP rate limits and audit.
`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
-`limits`| `max_request_header_bytes`| unset| When set, oversize headers return `431`
+`limits`| `max_request_header_bytes`| unset| Lowers the gateway’s 256 KiB limit on a request’s total headers. A request over the limit returns `431`, and a value above 256 KiB has no effect. If developers get `431` after signing in, see [Request headers too large after sign-in](</docs/en/claude-apps-gateway-deploy#request-headers-too-large-after-sign-in>).
`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; on every other provider the gateway waits up to one hour for the response to start.
`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how to size it. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -785,6 +785,23 @@
+Context window in terminal sessions
+
+Terminal sessions signed in through `/login` use the 1M context window for Opus 4.7 and later, Sonnet 5 and later, and the Fable models. The model ID needs no `[1m]` suffix, and sessions compact at about 967K tokens. Before Claude Code v2.1.287 on the developer’s machine, Claude Code treated the Opus and Fable models as having a 200K window unless the model ID ended in `[1m]`. To have terminal sessions compact at the 200K boundary instead, set the [auto-compact window](</docs/en/model-config#set-the-auto-compact-window>) in the policy’s `env`:
+
+ managed:
+ policies:
+ - match: {}
+ cli:
+ env:
+ CLAUDE_CODE_AUTO_COMPACT_WINDOW: "200000"
+
+Claude Code applies this variable without showing the developer the approval dialog. The variable applies to every model, including model IDs that end in `[1m]`. To turn off 1M context instead, set [`CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"`](</docs/en/model-config#extended-context>) in the same `env` block. Claude Code then treats every model as having a 200K window. In interactive sessions, each developer approves this variable in the approval dialog before it takes effect.
+
+####
+
+
+
MCP servers in a policy
To provide MCP servers to the Claude Code clients a policy matches, set [`managedMcpServers`](</docs/en/managed-mcp#provide-servers-through-managed-settings>) in that policy’s `cli` block. You need Claude Code v2.1.259 or later on the gateway server and on clients. The gateway checks each entry at boot with [the same rules Claude Code applies on the client](</docs/en/managed-mcp#what-an-entry-can-contain>), and if an entry fails a check, the gateway refuses to start and names the entry. If you write a `${VAR}` reference in `gateway.yaml`, the gateway resolves it from its environment at boot through secret expansion before it runs the entry checks, so every matching client receives the literal value and can read it. The [header guidance for provided servers](</docs/en/managed-mcp#provide-servers-through-managed-settings>) applies to the expanded value. The gateway rejects the `.mcp.json` spelling `mcpServers` in a `cli` block, and its boot error names `managedMcpServers` as the key to use. Before v2.1.259, the gateway rejected any MCP server definition in a `cli` block.
@@ -801,7 +818,7 @@
The gateway derives much of the response from the matched policy’s `cli` block and from top-level gateway config:
- * The model list, from `availableModels`
+ * The model list, from `availableModels`. Extended context in Claude Desktop covers each model’s 1M context option
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
* An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
@@ -831,6 +848,42 @@
* `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
For every other key, if you set it in the role policy, the gateway uses the role policy’s value. The gateway replaces an array or a nested object such as `banner` whole, so if you set `banner.text` in a role policy, the gateway drops the base’s `banner.backgroundColor`. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; the gateway then returns 404 from `/user/bootstrap` for every user.
+
+####
+
+
+
+Extended context in Claude Desktop
+
+If you serve Claude Desktop from the gateway, its model picker offers a 1M context option for each listed model that can run with a 1M context window. These include Claude Opus 4.6 and later, Claude Sonnet 4.6 and later, and the Fable models. The option is the model’s `[1m]` variant, which [Extended context](</docs/en/model-config#extended-context>) describes. You need Claude Code v2.1.284 or later on the gateway server. A `models` entry gets no 1M option when:
+
+ * An upstream that can serve the entry maps it to a model without 1M support, including an upstream the gateway reaches only on failover
+ * Neither its `id` nor any of its `upstream_model` values names a Claude model, such as a custom alias routed to an application inference profile ARN
+
+To change what the picker offers, use one of these:
+
+ * **Start users on the 1M option** : set `modelPrefer1mContext: true` in the policy’s `desktop` block. Users who haven’t yet chosen a model start on the 1M option when the first listed model has one. Users who already chose a model keep their choice.
+ * **Offer the option by hand** : do this if your gateway server runs a version older than v2.1.284, or an entry names no Claude model. List the model twice in `models`, once with its plain ID and once with `[1m]` appended, both with the same `upstream_model` map. Claude Desktop shows the pair as one model with a 1M option. The gateway serves a `[1m]` entry without checking it, so add one only for a model your upstreams serve at 1M.
+
+This example offers the option by hand for a custom alias routed to an application inference profile, and starts new users on it:
+
+ models:
+ - id: corp-sonnet
+ upstream_model:
+ bedrock: arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/sonnet-5-prod
+ - id: corp-sonnet[1m]
+ upstream_model:
+ bedrock: arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/sonnet-5-prod
+
+ managed:
+ policies:
+ - match: {}
+ desktop:
+ modelPrefer1mContext: true
+
+##### Remove the 1M option
+
+To remove the option from the picker, set `CLAUDE_CODE_DISABLE_1M_CONTEXT: "1"` in the `env` block under the policy’s `cli` key. If you also listed an entry whose `id` ends in `[1m]`, the gateway still serves it, so delete that entry too. The variable also reaches the terminal sessions of developers the policy matches. For what it changes there, see [Extended context](</docs/en/model-config#extended-context>).
####
Show diff (106 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -168,7 +168,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the credential the gateway used against that upstream failed. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
@@ -291,7 +291,66 @@
The gateway doesn’t support guardrail input tags. It adds no guard content tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation.
-Also grant the gateway’s AWS principal `bedrock:ApplyGuardrail` on the guardrail. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
+Also grant `bedrock:ApplyGuardrail` on the guardrail to the principal that signs this upstream’s requests: the gateway’s AWS principal, or with `assume_role` the role named in `role_arn`. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
+
+##### Bedrock in another AWS account
+
+Set `assume_role` on a Bedrock upstream and the gateway uses its own AWS identity only to call `sts:AssumeRole` on a role you name, which can be in a different AWS account from the gateway. Every Bedrock request from that upstream is signed with the one-hour credentials STS returns, so no long-lived access key crosses accounts. Requires a gateway running Claude Code v2.1.281 or later. An earlier gateway refuses to start when it finds the key.
+
+ upstreams:
+ - name: bedrock-isolated
+ provider: bedrock
+ region: us-east-1
+ auth: {} # the gateway's own role: it only calls STS
+ assume_role:
+ role_arn: arn:aws:iam::222222222222:role/claude-gateway-bedrock
+ # external_id: ${BEDROCK_ROLE_EXTERNAL_ID} # when the role's trust policy requires one
+
+The `assume_role` block takes three keys:
+
+Key| Meaning
+---|---
+`role_arn`| The IAM role the gateway assumes, as an `arn:aws:iam::` or `arn:aws-us-gov:iam::` ARN. Give it the Bedrock permissions this upstream needs, `bedrock:CountTokens` included, plus `bedrock:ApplyGuardrail` when the upstream sets `guardrail`.
+`external_id`| Optional. Sent as the external ID on every `sts:AssumeRole` call. Set it when the role’s trust policy requires one, and quote it if it’s all digits.
+`session_name`| Optional. `email` or `sub` gives each developer their own session: see Per-developer AWS cost attribution. Unset, every request uses one session named `claude-apps-gateway`.
+
+The role’s trust policy names the gateway’s own principal, such as its IRSA or ECS task role. That principal needs `sts:AssumeRole` on the role and no Bedrock permission of its own. Drop the `Condition` if you set no `external_id`.
+
+ {
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Effect": "Allow",
+ "Principal": { "AWS": "arn:aws:iam::111111111111:role/claude-gateway" },
+ "Action": "sts:AssumeRole",
+ "Condition": { "StringEquals": { "sts:ExternalId": "your-external-id" } }
+ }]
+ }
+
+ * If STS refuses or is unreachable, the gateway doesn’t send the request with the upstream’s own credentials. It logs the STS error with what to check, then tries the next upstream you listed. Upstream error messages covers what the client receives when no upstream succeeds. A later upstream without `assume_role` would serve the request with its own credentials, so list one only if that is what you want.
+ * The gateway calls the regional STS endpoint `sts.<region>.amazonaws.com`, which its network must reach. For the FIPS endpoint, set `AWS_USE_FIPS_ENDPOINT=true` in the gateway’s environment rather than `use_fips_endpoint` in an AWS config file.
+ * `assume_role` applies to `provider: bedrock` only and needs SigV4 source credentials: the gateway refuses to start when it’s set beside `aws_bearer_token`.
+ * Every developer the gateway admits can use this upstream; `managed` governs which developers may use which models. To keep a model served through the role from also being served from another account, give it a custom id whose `upstream_model` map has only this upstream’s name. For such an id the gateway skips every other upstream, so neither the request nor the token count for an aborted request can fail over to another account. Built-in model names are still tried on every upstream in order, this one included, and a request that reaches it is signed with the same role, so list this upstream last unless its account should also serve them.
+
+This example gives one model a custom id that only the isolated upstream serves:
+
+ models:
+ - id: claude-opus-restricted # a custom id, not a built-in model name
+ upstream_model:
+ bedrock-isolated: us.anthropic.claude-opus-4-8 # the only upstream that serves it
+
+##### Per-developer AWS cost attribution
+
+By default the gateway signs every Bedrock request with one credential, so AWS sees all developers’ requests under a single IAM principal. Add `session_name: email` to `assume_role` and the gateway calls `sts:AssumeRole` once per developer per hour, with the session name set to that developer’s email, and signs their requests with the returned credentials, so each developer’s requests reach AWS under their own assumed-role session. The role can be in the gateway’s own account. Requires a gateway running Claude Code v2.1.281 or later. [Cost attribution on AWS](</docs/en/claude-apps-gateway-on-aws#cost-attribution>) covers the IAM role and where AWS billing shows the sessions.
+
+ upstreams:
+ - provider: bedrock
+ region: us-east-1
+ auth: {} # the gateway's own role: it only calls STS
+ assume_role:
+ role_arn: arn:aws:iam::123456789012:role/claude-gateway-bedrock-user
+ session_name: email # or sub
+
+`session_name` selects which verified claim becomes the AWS `RoleSessionName`: `email` or `sub`. The gateway writes any character other than ASCII letters, digits, and `_+,.@-` as `=XX` hex per UTF-8 byte, and shortens a result longer than 64 characters to a prefix plus a hash, so each developer’s session name stays valid and unique. A request from a developer whose token lacks the claim isn’t sent through this upstream, and the operator log says to switch to `sub` or set `oidc.email_claim`. An active developer costs one STS call per hour per gateway replica, and concurrent first requests share one call. The gateway also makes one call of its own on this role: the token count for a request the client abandoned, so that [spend limits](</docs/en/claude-apps-gateway-spend-limits>) stay accurate. That count and its one-token fallback request are signed by the shared `claude-apps-gateway` session, so AWS attributes the fallback to `claude-apps-gateway` rather than to the developer. For strict per-developer attribution, set `assume_role` with `session_name` on every Bedrock upstream you list. An upstream without it signs the requests it serves with its own credentials.
####
@@ -434,7 +493,7 @@
provider: bedrock
region: us-west-2
auth: {}
- # Different account: a separate Bedrock allotment via assumed-role creds.
+ # Different account: a separate Bedrock allotment via static keys.
- name: bedrock-acct2
provider: bedrock
region: us-east-1
@@ -460,7 +519,7 @@
Lever| How
---|---
Different regions| One Amazon Bedrock upstream per region, each with its own `region:`. With `auto_include_builtin_models: true` the cross-region inference profiles route automatically; for region-pinned deployments use a `models:` block.
-Different accounts| One Amazon Bedrock upstream per account, each with its own credentials in `auth:`. The default chain (`auth: {}`) uses the pod’s identity; for a second account, set explicit credentials or a bearer token.
+Different accounts| One Amazon Bedrock upstream per account. The default chain (`auth: {}`) uses the pod’s identity; for a second account, add `assume_role` to reach it with short-lived credentials, or set explicit credentials or a bearer token in `auth:`.
Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. The gateway tries built-in models on every upstream in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
@@ -1102,7 +1161,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in a developer’s own `~/.claude/settings.json` or in the gateway payload doesn’t configure the gateway sign-in. Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. To stop developers from bypassing the gateway with a cloud provider variable or an `ANTHROPIC_BASE_URL` of their own, add `"allowedProviders": ["gateway"]` to the same file. Claude Code then refuses every session on the machine that isn’t set up for a Cloud gateway, and admits a gateway only when it is the one `forceLoginGatewayUrl` names or one whose URL the file’s `env` block sets as `ANTHROPIC_BASE_URL`. `claude gateway` refuses to run on a machine that sets the list, so keep the key off the gateway host. See the [`allowedProviders`](</docs/en/settings-reference#allowedproviders>) entry in the settings reference. Requires Claude Code v2.1.285 or later. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in a developer’s own `~/.claude/settings.json` or in the gateway payload doesn’t configure the gateway sign-in. Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -275,6 +275,23 @@
ECS / EC2| Attach the IAM role to the task definition or instance profile. `auth: {}` picks it up.
Anywhere else| Pass credentials via the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` env vars, or set them explicitly in `auth:` with `${VAR}` expansion
Region| `region:` is the API endpoint region. Cross-region inference profiles route across the geo (US, EU, APAC) regardless of which one you pick. For non-US regions or provisioned-throughput ARNs, add a `models:` block with the right per-upstream IDs.
+
+##### Apply an Amazon Bedrock guardrail
+
+To apply an Amazon Bedrock guardrail to every inference request the gateway sends through a Bedrock upstream, add a `guardrail` block to that upstream. Requires Claude Code v2.1.281 or later on the gateway server.
+
+ upstreams:
+ - provider: bedrock
+ region: us-east-1
+ auth: {}
+ guardrail:
+ id: gr-abc123 # guardrail ID or full ARN
+ version: "1" # a published version number, or DRAFT
+ # keep the quotes: a bare 1 fails at boot
+
+The gateway doesn’t support guardrail input tags. It adds no guard content tags to prompts, so a guardrail filter that Amazon Bedrock applies only to tagged input doesn’t run on traffic through the gateway. For which filters depend on input tags, see [input tags](<https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tagging.html>) in the Amazon Bedrock documentation.
+
+Also grant the gateway’s AWS principal `bedrock:ApplyGuardrail` on the guardrail. Set `guardrail` on every `bedrock` upstream or on none. The gateway refuses to start on a mix, because failover could otherwise send a request to a Bedrock upstream that has no guardrail. The guardrail covers Bedrock upstreams only. If you list another provider in `upstreams`, the gateway sends requests to that provider without the guardrail. When a `/v1/messages` request whose body carries an `amazon-bedrock-*` field, such as `amazon-bedrock-guardrailConfig`, reaches a Bedrock upstream that has `guardrail` set, the gateway answers 400 instead of forwarding it.
####
@@ -703,7 +720,7 @@
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
-[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, Claude Code therefore shows the dialog to every matching developer. It shows the dialog in a running session on the next hourly poll, and otherwise at the developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A [non-interactive run](</docs/en/server-managed-settings#security-approval-dialogs>), such as `claude -p` or an Agent SDK session, can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, every matching developer therefore sees the dialog in their interactive sessions. A running interactive session shows it on the next hourly poll, and otherwise it appears at the developer’s next interactive startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
####
@@ -749,7 +766,7 @@
* A key the gateway computes itself: the inference connection, the model list, and the OTLP relay. Configure those through `upstreams`, `models`, and the `telemetry` section’s `forward_to`.
* A legacy alias of a current key. In the boot error, the gateway names the canonical key to write.
-If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
+If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. `blockReadsOutsideWorkingDirectories`, `disableBypassPermissionsMode`, `configRecheckIntervalMinutes`, and `sshClientPath` need Claude Code v2.1.281 or later on the gateway server. So do the `required` value of `microsoftAuthBroker` and the `continuousAccessEvaluation` field of a Microsoft 365 `managedMcpServers` entry. Claude Desktop releases that predate the `required` value read it as `disabled`, so set `required` only after every member’s Claude Desktop supports it. Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) lists the release that first reads each key. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
* `disabledBuiltinTools`: the gateway uses the union of the base’s list and the policy’s list
* `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
@@ -770,7 +787,7 @@
`telemetry`
-The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
+The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. In sessions signed in through `/login`, the CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
telemetry:
forward_to:
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -158,6 +158,7 @@
`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
`connect_timeout_seconds`| No| Seconds the gateway waits when it opens a Postgres connection. A whole number from `1` to `60`, default `5`. Raise it if connection attempts time out when a new gateway instance starts. Requires Claude Code v2.1.274 or later on the gateway server. Earlier versions refuse to start when the key is set.
+`readiness_grace_seconds`| No| How many seconds `/readyz` keeps reporting ready after Postgres stops answering. A whole number from `0` to `3600`, default `0`. See [Outage behavior](</docs/en/claude-apps-gateway-deploy#outage-behavior>) for how to pick a value. Requires Claude Code v2.1.282 or later on the gateway server. Earlier versions refuse to start when the key is set.
For local development, point `postgres_url` at a throwaway Postgres container, for example `docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres`.
@@ -967,6 +968,7 @@
postgres_url: ${GATEWAY_POSTGRES_URL}
# max_connections: 5
# connect_timeout_seconds: 5
+ # readiness_grace_seconds: 300 # keep passing the readiness check through a database failover
# Enables /v1/organizations/spend_limits (mirrors the Anthropic Admin API)
# and per-developer spend enforcement on /v1/messages. Omit to disable.
@@ -1083,7 +1085,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. Setting them in a developer’s own `~/.claude/settings.json` or in the gateway payload doesn’t configure the gateway sign-in. Leave `forceLoginMethod` and `forceLoginOrgUUID` out of the payload. Claude Code still reads both keys from the payload for its startup credential check, so a developer who keeps an Anthropic-issued credential on the machine gets the startup exit described under [Administrator policy requires a Cloud gateway sign-in](</docs/en/errors#administrator-policy-requires-a-cloud-gateway-sign-in>) even after they sign in.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -23,7 +23,7 @@
* `managed`: managed settings policies by IdP group
* `telemetry`: OTLP forwarding to your observability stack
* `access_control`, `limits`, `timeouts`, `rate_limits`: IP allow/deny, request size caps, upstream time-to-first-byte, and per-IP sign-in limits
- * `load_test_mode`: load test the gateway without calling a model provider
+ * `load_test_mode`: load testing the gateway without calling a model provider
##
@@ -803,12 +803,37 @@
* `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
* `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`
-Before Claude Code v2.1.265 on the gateway server, the gateway pushed all three exporter selectors as `otlp`, including for signals no destination opted into. The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. Developers signed in through `/login` can’t redirect exports with their own OTEL configuration:
+When you add your own labels, the gateway also pushes `OTEL_RESOURCE_ATTRIBUTES`. Before Claude Code v2.1.265 on the gateway server, the gateway pushed all three exporter selectors as `otlp`, including for signals no destination opted into. The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. Developers signed in through `/login` can’t redirect exports with their own OTEL configuration:
* **Locally set variables** : Claude Code applies the pushed variables at the managed tier, so each one overrides the value a developer sets for it locally.
* **Locally configured endpoints** : with OTLP/HTTP export enabled, the CLI ignores any locally configured endpoint, whether or not the gateway pushed the telemetry variables. Its exports go to the gateway unless a policy names your collector as the endpoint.
Without a `forward_to` destination for a signal, the gateway accepts and discards it. If developers already export Claude Code telemetry to one of your collectors, add it as a `forward_to` destination, with logs or traces enabled if they export those, so it keeps receiving their data after they sign in. To skip the relay instead, name the collector in a policy. [Traces](</docs/en/monitoring-usage#traces-beta>) also require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. Set it in a managed policy’s `env` block, since the gateway doesn’t push it. Developers approve it in the same security approval dialog that the pushed endpoint already triggers. Set it to `1` only in the policies whose groups you want traced. A policy that doesn’t set it inherits the value from your `match: {}` catch-all policy if that policy sets one, per the merge rules. To keep a group’s clients from sending traces even when a developer sets the variable locally, set it to `0` in that group’s policy. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+
+####
+
+
+
+Add your own labels
+
+To put fixed labels such as `service.namespace` or `deployment.environment.name` on the telemetry of sessions signed in through the gateway, set `telemetry.resource_attributes`. Each label is an OpenTelemetry resource attribute, and every destination receives the same labels. Sessions get the labels only when you also set `telemetry.forward_to` and `listen.public_url`. This example adds two labels:
+
+ telemetry:
+ forward_to:
+ - url: https://otel-collector.internal.example.com
+ resource_attributes:
+ service.namespace: claude
+ deployment.environment.name: prod
+
+The gateway refuses to start when a label breaks one of these rules, and the startup error names the label:
+
+ * Names use only letters, digits, `.`, `_`, and `-`
+ * Names aren’t reserved. Compared in any letter case, the reserved names are everything that starts with `user.`, `enduser.`, or `identity.`, plus `service.name`, `service.version`, `claude.deployment_mode`, `host.arch`, `os.type`, `os.version`, and `wsl.version`
+ * Values are non-empty printable ASCII with no space and none of `, ; = \ " %`
+ * Values are at most 255 characters as the gateway counts them after percent-encoding, so `/`, `:`, and `@` each count as three
+ * Values are text, so quote a number, `true`, or `false`
+
+You need Claude Code v2.1.281 or later on the gateway server to set `telemetry.resource_attributes`. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. Terminal sessions signed in through `/login` receive the labels as `OTEL_RESOURCE_ATTRIBUTES`, pushed with the other telemetry variables. If you set `OTEL_RESOURCE_ATTRIBUTES` in a policy’s `env` block, terminal sessions that policy matches get that value instead of the labels. Claude Desktop receives the labels from the gateway alongside `user.email` and the other identity attributes. Claude Code also copies each label onto every metric data point, so you can filter metrics by it in a backend that doesn’t index resource attributes. To turn that copy off, see [Metrics cardinality control](</docs/en/monitoring-usage#metrics-cardinality-control>).
####
@@ -870,7 +895,7 @@
`load_test_mode`
-The `load_test_mode` block lets you load test a gateway without calling a model provider. While it’s on, the gateway builds and signs each provider request as usual, discards it instead of sending it, and streams a canned reply back through its normal response path. The reply is filler text that begins with a sentence saying it is canned. Requires v2.1.283 or later. Earlier versions refuse to start when the key is set, so upgrade every replica before you add the block and remove it before you roll back. The example below turns the mode on with the defaults, a reply of 750 output tokens streamed over about 10 seconds:
+The `load_test_mode` block lets you load test a gateway without calling a model provider. While it’s on, the gateway builds and signs each provider request as usual, discards it instead of sending it, and streams a canned reply back through its normal response path. The reply is filler text that begins with a sentence saying it is canned. Requires Claude Code v2.1.282 or later on the gateway server. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the block, and remove the block before you roll back. The example below turns the mode on with the defaults, a reply of roughly 750 tokens of text streamed over about 10 seconds:
load_test_mode:
enabled: true
@@ -883,7 +908,7 @@
`reply_tokens`| No| Default `750`. Roughly how many tokens of text each canned reply carries, a whole number from 1 to 100000.
`reply_seconds`| No| Default `9.5`. How long a streamed reply takes, from 0 to 600. `0` sends the whole reply at once. A reply to a non-streaming request always comes back at once.
-A load test in this mode covers the gateway, your Postgres, and everything in front of the gateway. It doesn’t cover the provider’s limits, speed, or network path. While the mode is on, a request can carry an `x-load-test-user` header holding a whole number of up to seven digits, and the gateway counts each number as a separate developer with the email and groups of the developer whose token came with the request. Give the load-test deployment its own empty database, because the gateway refuses to start with the mode on against a database in which any developer has already spent anything.
+A load test in this mode covers the gateway, your Postgres, and everything in front of the gateway. It doesn’t cover the provider’s limits, speed, or network path. No model request is sent to the provider, so a replica’s CPU per request is an estimate and reads lower than production, which also encrypts its traffic to the provider. Confirm a replica count with a small pilot against the real provider. Before v2.1.283, the estimate reads much lower. While the mode is on, a request can carry an `x-load-test-user` header holding a whole number of up to seven digits. The gateway counts each number as a separate developer, with the email and groups of the developer whose token came with the request. Give the load-test deployment its own empty database, because the gateway refuses to start with the mode on against a database in which any developer has already spent anything.
Never turn this on for a gateway that developers use. Every request gets the canned reply and no model is called. The gateway logs a `load_test_mode is on` warning at boot and marks each `inference` [audit event](</docs/en/claude-apps-gateway-deploy#logs>) with `load_test: true` while the mode is on.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -23,6 +23,7 @@
* `managed`: managed settings policies by IdP group
* `telemetry`: OTLP forwarding to your observability stack
* `access_control`, `limits`, `timeouts`, `rate_limits`: IP allow/deny, request size caps, upstream time-to-first-byte, and per-IP sign-in limits
+ * `load_test_mode`: load test the gateway without calling a model provider
##
@@ -863,6 +864,29 @@
Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. Behind such a front end, set `listen.trusted_proxies` first so the gateway sees real client addresses, and keep the gateway and everything in front of it unreachable from the public internet regardless.
+###
+
+
+
+`load_test_mode`
+
+The `load_test_mode` block lets you load test a gateway without calling a model provider. While it’s on, the gateway builds and signs each provider request as usual, discards it instead of sending it, and streams a canned reply back through its normal response path. The reply is filler text that begins with a sentence saying it is canned. Requires v2.1.283 or later. Earlier versions refuse to start when the key is set, so upgrade every replica before you add the block and remove it before you roll back. The example below turns the mode on with the defaults, a reply of 750 output tokens streamed over about 10 seconds:
+
+ load_test_mode:
+ enabled: true
+ reply_tokens: 750 # roughly how many tokens of text each canned reply carries
+ reply_seconds: 9.5 # how long a streamed reply takes
+
+Field| Required| Description
+---|---|---
+`enabled`| Yes| `true` turns the mode on. `false` keeps your numbers in the file with the mode off. The gateway refuses to start if the block is present without it.
+`reply_tokens`| No| Default `750`. Roughly how many tokens of text each canned reply carries, a whole number from 1 to 100000.
+`reply_seconds`| No| Default `9.5`. How long a streamed reply takes, from 0 to 600. `0` sends the whole reply at once. A reply to a non-streaming request always comes back at once.
+
+A load test in this mode covers the gateway, your Postgres, and everything in front of the gateway. It doesn’t cover the provider’s limits, speed, or network path. While the mode is on, a request can carry an `x-load-test-user` header holding a whole number of up to seven digits, and the gateway counts each number as a separate developer with the email and groups of the developer whose token came with the request. Give the load-test deployment its own empty database, because the gateway refuses to start with the mode on against a database in which any developer has already spent anything.
+
+Never turn this on for a gateway that developers use. Every request gets the canned reply and no model is called. The gateway logs a `load_test_mode is on` warning at boot and marks each `inference` [audit event](</docs/en/claude-apps-gateway-deploy#logs>) with `load_test: true` while the mode is on.
+
##
@@ -936,6 +960,13 @@
# enforcement:
# fail_closed_on_error: false
+
+ # Load test this deployment without calling a model provider. Never on a
+ # gateway that developers use: every request gets a canned reply.
+ # load_test_mode:
+ # enabled: true
+ # # reply_tokens: 750
+ # # reply_seconds: 9.5
# Meter at contracted rates instead of USD list price. Requires admin: or a
# managed: policy. With managed:, the same rates also go to signed-in clients.
Show diff (142 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -86,7 +86,7 @@
`id_token_signed_response_alg`| No| Expected id_token signing algorithm. Default `RS256`. Set for IdPs that sign with ES256, PS256, or EdDSA.
`additional_authorized_parties`| No| Extra `azp` values to accept beyond `client_id`, for Keycloak broker and token-exchange flows
`discovery_url`| No| Fetch the discovery document from this URL instead of deriving it from `issuer`, for IdPs behind a proxy that rewrites the issuer host. The path must contain `/.well-known/`.
-`use_proxy`| No| Send the gateway’s own IdP requests through the forward proxy in `HTTPS_PROXY` or `HTTP_PROXY`, honoring `NO_PROXY`. Unset or `false`, those requests go direct. Requires v2.1.227 or later; see IdP requests through a forward proxy below.
+`use_proxy`| No| Send the gateway’s own IdP requests through the forward proxy in `HTTPS_PROXY` or `HTTP_PROXY`, honoring `NO_PROXY`. `false` keeps those requests direct. Requires v2.1.227 or later; see IdP requests through a forward proxy below.
`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
`ca_cert_pem`| No| The PEM-encoded CA certificate itself, not a path to a file. It replaces the system trust store for IdP requests only. To load a mounted file, write `${file:/etc/gateway/idp-ca.pem}`. Use for Keycloak or Dex behind corporate PKI.
@@ -96,7 +96,38 @@
IdP requests through a forward proxy
-The inference upstreams honor `HTTPS_PROXY` and `HTTP_PROXY` on every version. The gateway’s own requests to the IdP, discovery, JWKS, token, and userinfo, go direct unless you set `oidc.use_proxy: true`, which requires v2.1.227 or later. When a proxy variable is set, `use_proxy` is unset, and the issuer isn’t covered by `NO_PROXY`, the gateway keeps those requests direct and logs a notice at boot asking you to choose; `use_proxy: false` keeps them direct and silences the notice. With `use_proxy: true`, the pod resolves each IdP endpoint’s hostname itself and asks the proxy to `CONNECT` to the resolved IP address, so the proxy must accept `CONNECT` to the IP address of every host the discovery document names, not only the issuer. Use an `http://` proxy URL. `ca_cert_pem` and the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) apply on the proxied path as well.
+The inference upstreams honor `HTTPS_PROXY` and `HTTP_PROXY` on every version. The gateway’s own requests to the IdP, discovery, JWKS, token, and userinfo, go direct unless you set `oidc.use_proxy: true`, which requires v2.1.227 or later. When a proxy variable is set, `use_proxy` is unset, and the issuer isn’t covered by `NO_PROXY`, the gateway keeps those requests direct and logs a notice at boot asking you to choose; `use_proxy: false` keeps them direct and silences the notice. With `use_proxy: true`, the pod resolves each IdP endpoint’s hostname itself and asks the proxy to `CONNECT` to the resolved IP address, so the proxy must accept `CONNECT` to the IP address of every host the discovery document names, not only the issuer. Use an `http://` proxy URL. `ca_cert_pem` and the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) apply on the proxied path as well. Proxy-only egress changes both of these: while it’s active, IdP requests follow the proxy unless you set `use_proxy: false`, and the gateway hands the proxy each IdP hostname without resolving it first.
+
+####
+
+
+
+Proxy-only egress
+
+Set `CLAUDE_GATEWAY_PROXY_IS_EGRESS_BOUNDARY=1` in the gateway’s environment, next to `HTTPS_PROXY`, when the pod reaches other hosts only through that forward proxy and can’t resolve public DNS names itself, or when the proxy refuses `CONNECT` to an IP address. Requires v2.1.277 or later. It’s an environment variable rather than a `gateway.yaml` key so that nothing in the config file can relax the gateway’s address check.
+
+ export HTTPS_PROXY=http://proxy.corp.example.com:3128
+ export NO_PROXY=
+ export no_proxy=
+ export CLAUDE_GATEWAY_PROXY_IS_EGRESS_BOUNDARY=1
+
+The gateway logs one `network:` line at boot while proxy-only egress is active. Each row below is one class of outbound request on a gateway with `HTTPS_PROXY` set, by default and while proxy-only egress is active.
+
+Outbound request| Default| Proxy-only egress active
+---|---|---
+`provider: anthropic` upstreams, Workload Identity Federation token exchange, `telemetry.forward_to` exports| Resolved and checked locally, then `CONNECT` to the checked IP address through the proxy. A telemetry collector listed in `NO_PROXY` is reached directly instead| Hostname handed to the proxy
+IdP discovery, JWKS, token, and userinfo| Direct unless `oidc.use_proxy: true`, then `CONNECT` to the checked IP address| Hostname handed to the proxy, unless `oidc.use_proxy: false` keeps an internal IdP direct
+Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry upstreams; Google group lookups| Hostname handed to the proxy| Unchanged
+
+Proxy-only egress stays off unless the gateway’s environment meets all three of these conditions:
+
+ * `HTTPS_PROXY` or `HTTP_PROXY` is set.
+ * `NO_PROXY` and `no_proxy` are empty. If your platform injects either into pods, set both to an empty value on the gateway container. Listing a telemetry collector in `NO_PROXY` keeps proxy-only egress off.
+ * `CLAUDE_GATEWAY_ALLOW_LOOPBACK` isn’t turned on. A collector or IdP on the pod’s own loopback can’t be combined with proxy-only egress, because a loopback address handed to the proxy would be the proxy host’s own, so give those services an address the proxy can reach instead. For the same reason the gateway refuses `localhost`-style names outright while proxy-only egress is active.
+
+When one of those conditions isn’t met, the gateway logs a warning at boot naming the variable that stopped it and keeps the default behavior. Once proxy-only egress is active, allow every destination in the proxy, including an internal collector and any host configured by IP address. You can still keep an internal IdP direct with `oidc.use_proxy: false`.
+
+Turn this on only when the proxy’s allowlist is at least as strict as the gateway’s own check. The proxy must refuse cloud metadata endpoints such as `169.254.169.254` and `metadata.google.internal`, link-local addresses, and the proxy host’s own loopback, and it must refuse them by the address a name resolves to, not only by name, because the gateway no longer catches a hostname that resolves to one of them. A proxy that connects anywhere it’s asked removes the gateway’s [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) for these requests.
###
@@ -125,6 +156,7 @@
`username`| No| Overrides the user in `postgres_url`
`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
+`connect_timeout_seconds`| No| Seconds the gateway waits when it opens a Postgres connection. A whole number from `1` to `60`, default `5`. Raise it if connection attempts time out when a new gateway instance starts. Requires Claude Code v2.1.274 or later on the gateway server. Earlier versions refuse to start when the key is set.
For local development, point `postgres_url` at a throwaway Postgres container, for example `docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres`.
@@ -335,9 +367,42 @@
+Static headers on upstream requests
+
+To add fixed headers to the requests the gateway sends to one upstream, set `headers:` on that upstream. Use it when a proxy you run in front of the provider routes or attributes traffic by a header. `headers:` requires Claude Code v2.1.277 or later on the gateway server. An earlier gateway refuses to start when it finds the key. Upgrade every replica before you add the key, and remove the key before you roll back to an earlier version. The headers go to the server that `base_url` names, or to the provider’s own endpoint when `base_url` is unset. The provider receives them too unless your proxy removes them. This example reaches a `provider: vertex` upstream through a proxy at `upstream-proxy.internal.example.com`. It sets the `x-source` header the proxy reads, and sends a token from the `PROXY_TOKEN` environment variable as `x-proxy-token`:
+
+ upstreams:
+ - provider: vertex
+ region: us-east5
+ project_id: example-prod
+ base_url: https://upstream-proxy.internal.example.com
+ auth: {}
+ headers:
+ x-source: claude-apps-gateway
+ x-proxy-token: ${PROXY_TOKEN}
+
+Values are printable ASCII text with no space at either end. Quote a number, `true`, or `false` so YAML reads it as text. To keep a secret out of the config file, use secret expansion to load the value from an environment variable with `${VAR}` or from a file with `${file:/path}`. A `${VAR}` that resolves to an empty value stops the gateway from starting. `headers:` works on every provider, and each upstream sends only its own. Not every request that the gateway sends to an upstream carries them:
+
+Request the gateway sends to this upstream| Carries `headers:`
+---|---
+`/v1/messages`, streaming or not, and `/v1/messages/count_tokens`| Yes
+A request that failed over from another upstream| Yes, this upstream’s `headers:` only
+Amazon Bedrock’s `CountTokens` call for a request the client abandoned| No
+The Workload Identity Federation token exchange| No
+
+On an Amazon Bedrock or Claude Platform on AWS upstream that signs requests with AWS SigV4, these headers are part of the signature, so your proxy must pass them through unchanged. If you use a name the gateway reserves, it refuses to start, and the startup error names the header. Reserved names include:
+
+ * `authorization` and `x-api-key`
+ * `host`, `content-type`, and `user-agent`
+ * Any name starting with `anthropic-`, `x-goog-`, `x-amz-`, or `x-amzn-`
+
+####
+
+
+
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. Every request starts at the first upstream. A request reaches a later upstream only when every upstream ahead of it has failed or doesn’t serve the requested model. The gateway keeps no record of failed upstreams, so while an upstream is down, every request that reaches it still tries it and waits for it to fail before moving on. For an Anthropic API upstream, `timeouts.upstream_ttfb_ms` bounds the wait on a down upstream. That setting doesn’t apply to the other providers, where the gateway waits up to one hour for an upstream to start responding. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
upstreams:
# Primary: provisioned throughput in your home region.
@@ -703,7 +768,7 @@
`telemetry`
-The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`.
+The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Desktop and Cowork telemetry also carries `enduser.sub`, the `sub` claim your identity provider issues for the user, which stays the same when a user’s email changes. Terminal sessions stamp the same value under `user.id`, so a query that matches `enduser.sub` against terminal `user.id` covers one user’s terminal, Desktop, and Cowork usage together. On Desktop and Cowork exports, `user.id` is an anonymous identifier, not the subject. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. The gateway leaves `enduser.sub` off when the subject is longer than 255 characters once percent-encoded, or contains a space, a character outside printable ASCII, or one of `,` `;` `=` `\` `"` `%`. That user’s Desktop and Cowork telemetry keeps its other attributes. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`. You need Claude Code v2.1.274 or later on the gateway server for `enduser.sub`.
telemetry:
forward_to:
@@ -730,7 +795,7 @@
* `http://localhost:<port>` passes config validation, but the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) blocks every export with `ECONNREFUSED_SSRF` unless you set `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` in the gateway’s environment
* `http://127.0.0.1:<port>` or `http://[::1]:<port>` fails boot unless that variable is set
-For an in-cluster collector, expose it over HTTPS at its own internal address, or run it as a sidecar with the variable set. Telemetry is off in the CLI by default. When you set both `telemetry.forward_to` and `listen.public_url`, the gateway turns it on for connected clients by pushing six environment variables through `/managed/settings`:
+For an in-cluster collector, expose it over HTTPS at its own internal address, or run it as a sidecar with the variable set. When `HTTPS_PROXY` is set, the gateway sends exports through that proxy. To reach an internal collector directly, add it to `NO_PROXY` by hostname or by a domain with a leading dot such as `.internal.example.com`, which requires Claude Code v2.1.277 or later on the gateway server. Make sure the gateway can reach the collector without the proxy. An entry without a leading dot matches only that exact name, not names under it. CIDR ranges don’t match. With proxy-only egress turned on, allow the collector in the proxy instead, since any `NO_PROXY` entry keeps proxy-only egress off. Telemetry is off in the CLI by default. When you set both `telemetry.forward_to` and `listen.public_url`, the gateway turns it on for connected clients by pushing six environment variables through `/managed/settings`:
* `CLAUDE_CODE_ENABLE_TELEMETRY=1`
* `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER`, and `OTEL_TRACES_EXPORTER`, each set to `otlp` if at least one `forward_to` destination enables that signal and to `none` otherwise
@@ -787,9 +852,9 @@
`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
`limits`| `max_request_header_bytes`| unset| When set, oversize headers return `431`
`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
-`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; every other provider is bounded by its provider SDK’s own timeout.
-`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
-`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`
+`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; on every other provider the gateway waits up to one hour for the response to start.
+`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how to size it. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
+`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`. It is what stops someone from guessing another developer’s code. [Large rollouts](</docs/en/claude-apps-gateway-deploy#large-rollouts>) shows how far to raise it.
If you leave both `access_control` lists empty, which is the default, the gateway serves any client address, so only your network restricts who can reach it. That matters because a gateway can push managed settings that run commands on developer machines. While `allow_cidrs` is empty, the gateway warns in two places, without changing how it answers any request:
@@ -852,6 +917,7 @@
store:
postgres_url: ${GATEWAY_POSTGRES_URL}
# max_connections: 5
+ # connect_timeout_seconds: 5
# Enables /v1/organizations/spend_limits (mirrors the Anthropic Admin API)
# and per-developer spend enforcement on /v1/messages. Omit to disable.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -521,7 +521,7 @@
`managed`
-The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; the first match is selected, then merged onto the `match: {}` catch-all base described below. They are served per-user at `GET /managed/settings` with ETag/304 caching.
+The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; the first match is selected, then merged onto the `match: {}` catch-all base. They are served per-user at `GET /managed/settings` with ETag/304 caching.
managed:
policies:
@@ -721,7 +721,7 @@
Each destination opts into `metrics`, `logs`, and `traces` independently, and the default is metrics only. The signals differ in sensitivity:
* **Metrics** : aggregate counters such as token counts, request counts, and latency
- * **Logs and traces** : can carry full bash commands, tool inputs, and file paths, covering anything Claude Code does on a developer’s machine
+ * **Logs and traces** : can carry full Bash commands, tool inputs, and file paths, covering anything Claude Code does on a developer’s machine
Enable logs and traces only on destinations with the access controls and retention policy that data warrants.
@@ -790,6 +790,13 @@
`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; every other provider is bounded by its provider SDK’s own timeout.
`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`
+
+If you leave both `access_control` lists empty, which is the default, the gateway serves any client address, so only your network restricts who can reach it. That matters because a gateway can push managed settings that run commands on developer machines. While `allow_cidrs` is empty, the gateway warns in two places, without changing how it answers any request:
+
+ * **At boot** : a warning in the operational log recommends allowing only the private ranges `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `100.64.0.0/10`, `127.0.0.0/8`, `::1/128`, and `fc00::/7`, plus any other internal ranges your developers connect from. If you bind the gateway to a loopback address and set neither `trusted_proxies` nor `public_url`, as in local development, the warning doesn’t appear.
+ * **At runtime** : the first time a request arrives from an address outside those private ranges, the gateway logs a warning and emits an [`access.public_client` audit event](</docs/en/claude-apps-gateway-deploy#logs>) carrying the client IP. Both fire once per process. Link-local addresses, `169.254.0.0/16` and `fe80::/10`, don’t count as public. The gateway answers `/healthz` and `/readyz` before this check runs, so health probes from public ranges don’t trigger it.
+
+Both signals use the client address as the gateway resolves it. If a load balancer, port-forward, or tunnel relays traffic and isn’t listed in `listen.trusted_proxies`, the gateway sees the relay’s address, which is usually private, so neither the runtime warning nor a private allow list catches traffic relayed through it. Behind such a front end, set `listen.trusted_proxies` first so the gateway sees real client addresses, and keep the gateway and everything in front of it unreachable from the public internet regardless.
##
@@ -954,7 +961,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. Claude Code honors [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), [`gatewayInternalNetworks`](</docs/en/settings-reference#gatewayinternalnetworks>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>) only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -18,7 +18,7 @@
* `admin`: Admin API auth and retention for spend limits
* `enforcement`: spend-limit fail-open or fail-closed behavior
- * `pricing`: contracted rates and a discount multiplier for the spend meter and for the cost figures developers see
+ * `pricing`: contracted rates and a multiplier for the spend meter and for the cost figures developers see
* `models` and `auto_include_builtin_models`: admin-curated model list and per-upstream IDs
* `managed`: managed settings policies by IdP group
* `telemetry`: OTLP forwarding to your observability stack
@@ -457,7 +457,7 @@
Field| Required| Description
---|---|---
-`multiplier`| No| Default `1`. The meter multiplies every metered amount by this, whether list-priced or overridden, so `0.85` bills 85% of the price. Must be greater than 0 and at most 1.
+`multiplier`| No| Default `1`. The meter multiplies every metered amount by this, whether list-priced or overridden, so `0.85` bills 85% of the price. Must be greater than 0 and at most 10, and a value above 1 is a markup.
`overrides`| No| Rows of `{upstream, model, input, output, cache_read, cache_write}` in USD per million tokens. All four rates are required. Each must be greater than 0 and at most 10000.
How the meter matches an override row:
@@ -469,6 +469,19 @@
* Web-search requests stay at the $0.01 list price; the multiplier still applies to them.
For per-region rates, give each region its own named upstream and one row per upstream.
+
+####
+
+
+
+Mark prices up
+
+With v2.1.271 or later on the gateway server, you can set `multiplier` above 1, up to 10, to meter more than the provider charges, for example an internal chargeback rate. This example meters every request at 120% of the price:
+
+ pricing:
+ multiplier: 1.2
+
+With an `admin:` block, the markup also applies to spend limits. The meter counts 120% of the price, so developers reach their caps sooner. The gateway logs a warning at boot that says so. The multiplier doesn’t change what the upstream provider charges for the requests. If the gateway also sends the rates to signed-in clients, developers need Claude Code v2.1.271 or later to see the markup. Earlier clients ignore a `multiplier` above 1 and show costs without it. A gateway server earlier than v2.1.271 refuses to start if you set a `multiplier` above 1.
####
@@ -851,8 +864,8 @@
# enforcement:
# fail_closed_on_error: false
- # Meter at contracted rates instead of USD list price. Requires admin:.
- # With managed:, the same rates also go to signed-in clients.
+ # Meter at contracted rates instead of USD list price. Requires admin: or a
+ # managed: policy. With managed:, the same rates also go to signed-in clients.
# Rates below are placeholders, not real contract prices.
# pricing:
# multiplier: 0.85
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -573,7 +573,7 @@
What goes in `cli`
-Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
+Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys include `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
managed:
policies:
Show diff (172 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -18,7 +18,7 @@
* `admin`: Admin API auth and retention for spend limits
* `enforcement`: spend-limit fail-open or fail-closed behavior
- * `pricing`: contracted rates and a discount multiplier for the spend meter
+ * `pricing`: contracted rates and a discount multiplier for the spend meter and for the cost figures developers see
* `models` and `auto_include_builtin_models`: admin-curated model list and per-upstream IDs
* `managed`: managed settings policies by IdP group
* `telemetry`: OTLP forwarding to your observability stack
@@ -134,7 +134,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream, and a `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout the gateway fails over to the next upstream; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream. A `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. If you set `forward_user_identity: true` on an upstream, a `429` it returns to a request that carried the developer’s email doesn’t fail over. See how a per-user limit denial reaches the developer. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
@@ -206,7 +206,7 @@
`x-claude-gateway-user-id`| The developer’s IdP subject, from the token’s `sub` claim.
`x-claude-gateway-user-email`| The developer’s email, when the IdP supplied one.
-When the IdP token carries no email, the gateway sends only `x-claude-gateway-user-id` and omits the two email headers. If your IdP puts the email in a different claim, set `oidc.email_claim` to that claim. Set `forward_user_identity` only on an upstream whose `base_url` is a proxy you operate. The gateway sends developer emails to whatever server that `base_url` names. If the `base_url` is the Anthropic API, which is the default, the gateway refuses to start.
+When the IdP token carries no email, the gateway sends only `x-claude-gateway-user-id` and omits the two email headers. If your IdP puts the email in a different claim, set `oidc.email_claim` to that claim. When your proxy answers `429` to a request that carried the developer’s email, the gateway returns that response to the developer as-is instead of failing over to the next upstream, so your proxy’s per-user budget or rate limit holds. The proxy’s other responses follow the ordinary failover rules. If a developer’s IdP token carries no email, the gateway forwards their requests without the email headers, so a `429` to one of those requests counts as upstream capacity and fails over. Before v2.1.267 on the gateway server, every `429` failed over. Set `forward_user_identity` only on an upstream whose `base_url` is a proxy you operate. The gateway sends developer emails to whatever server that `base_url` names. If the `base_url` is the Anthropic API, which is the default, the gateway refuses to start.
####
@@ -337,7 +337,7 @@
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. If you set `forward_user_identity: true` on an upstream, a `429` to a request that carried the developer’s email is a per-user denial instead and doesn’t fail over. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
upstreams:
# Primary: provisioned throughput in your home region.
@@ -443,7 +443,7 @@
The `pricing` block tells the spend meter what to charge instead of USD list price, so caps and [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) reflect your contracted rates. Amounts stay in USD and remain an estimate, not an invoice. Two prerequisites:
* Claude Code v2.1.227 or later on the gateway server. Earlier versions reject the unknown key at boot.
- * An `admin:` block, because only the spend meter reads `pricing`. The gateway refuses to start with `pricing` set and no `admin`.
+ * An `admin:` block or, in v2.1.268 or later, a `managed:` block with at least one policy. The gateway refuses to start with `pricing` set and neither block, because nothing would read it.
pricing:
multiplier: 0.85
@@ -458,7 +458,7 @@
Field| Required| Description
---|---|---
`multiplier`| No| Default `1`. The meter multiplies every metered amount by this, whether list-priced or overridden, so `0.85` bills 85% of the price. Must be greater than 0 and at most 1.
-`overrides`| No| Rows of `{upstream, model, input, output, cache_read, cache_write}` in USD per million tokens. All four rates are required and must be positive.
+`overrides`| No| Rows of `{upstream, model, input, output, cache_read, cache_write}` in USD per million tokens. All four rates are required. Each must be greater than 0 and at most 10000.
How the meter matches an override row:
@@ -469,6 +469,18 @@
* Web-search requests stay at the $0.01 list price; the multiplier still applies to them.
For per-region rates, give each region its own named upstream and one row per upstream.
+
+####
+
+
+
+Send the rates to signed-in clients
+
+With v2.1.268 or later on the gateway server, the gateway also puts the rates from `pricing` into the `managed` policies it serves, as the [`modelPricing`](</docs/en/settings-reference#modelpricing>) managed setting. Developers matched by a policy then see the `pricing` rates for the first upstream that serves each model ID in `/usage`, the status line, and OpenTelemetry. A developer who matches no policy receives no managed settings, so their figures stay at list price. Clients apply the setting in Claude Code v2.1.242 or later.
+
+ * What the gateway adds: unless a policy’s `cli` block already sets `modelPricing`, the gateway adds the `multiplier` and, for every model ID a client can request, the override row of the first upstream that serves that ID. A rate that only a failover upstream charges stays on the gateway.
+ * Opt one policy out: set `modelPricing` to `{}` in that policy’s `cli` block, and its developers stay at list price.
+ * Keep a policy’s own rates: a policy whose `cli` block sets `modelPricing` with its own `multiplier` or `overrides` keeps that `modelPricing` whole, and the gateway adds no rates of its own to it.
###
@@ -636,7 +648,7 @@
* The model list, from `availableModels`
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
- * An OTLP endpoint that points at the gateway itself, which fans out to your destinations, included when `telemetry` forwarding is configured. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
+ * An OTLP endpoint that points at the gateway itself, and the signed-in user’s identity attributes. The gateway relays the exports it receives at that endpoint to your `forward_to` destinations. It includes the endpoint and the attributes when you set both `telemetry.forward_to` and `listen.public_url`. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
@@ -678,7 +690,7 @@
`telemetry`
-The CLI sends OpenTelemetry Protocol (OTLP) over HTTP metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration.
+The CLI sends metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. The exports use OpenTelemetry Protocol (OTLP) over HTTP. To skip the relay and have sessions export straight to your collector, name the collector in a policy. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration. Claude Desktop and Cowork sessions signed in through the gateway stamp their telemetry with `user.email` and `user.groups` alongside `enduser.id`, so you can cover terminal, Desktop, and Cowork usage with one query on `user.email` or `user.groups`. `user.groups` is the comma-separated IdP group list. Like all OpenTelemetry data from Claude Code, these attributes go only to destinations your organization configures, never to Anthropic. If a user’s group list is longer than 255 characters once percent-encoded, or a group name contains a comma or equals sign, the gateway leaves `user.groups` off that user’s Desktop and Cowork telemetry rather than truncating it. That user’s terminal sessions still carry the full list. You need Claude Code v2.1.265 or later on the gateway server for `user.email` and `user.groups` on Desktop and Cowork telemetry, and Claude Desktop 1.24012 or later on each developer’s machine for `user.groups`.
telemetry:
forward_to:
@@ -705,16 +717,48 @@
* `http://localhost:<port>` passes config validation, but the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) blocks every export with `ECONNREFUSED_SSRF` unless you set `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` in the gateway’s environment
* `http://127.0.0.1:<port>` or `http://[::1]:<port>` fails boot unless that variable is set
-For an in-cluster collector, expose it over HTTPS at its own internal address, or run it as a sidecar with the variable set. Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes six env vars to every connected client through `/managed/settings`:
+For an in-cluster collector, expose it over HTTPS at its own internal address, or run it as a sidecar with the variable set. Telemetry is off in the CLI by default. When you set both `telemetry.forward_to` and `listen.public_url`, the gateway turns it on for connected clients by pushing six environment variables through `/managed/settings`:
* `CLAUDE_CODE_ENABLE_TELEMETRY=1`
- * `OTEL_METRICS_EXPORTER=otlp`
- * `OTEL_LOGS_EXPORTER=otlp`
- * `OTEL_TRACES_EXPORTER=otlp`
+ * `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER`, and `OTEL_TRACES_EXPORTER`, each set to `otlp` if at least one `forward_to` destination enables that signal and to `none` otherwise
* `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
* `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`
-The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. Whether or not the gateway pushes these variables, a CLI signed in through `/login` that has OTLP/HTTP export enabled sends its exports to the gateway rather than to a locally configured endpoint, and without a `forward_to` destination for a signal the gateway accepts and discards it; if you already collect Claude Code telemetry directly, add your collector as a `forward_to` destination. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+Before Claude Code v2.1.265 on the gateway server, the gateway pushed all three exporter selectors as `otlp`, including for signals no destination opted into. The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. Developers signed in through `/login` can’t redirect exports with their own OTEL configuration:
+
+ * **Locally set variables** : Claude Code applies the pushed variables at the managed tier, so each one overrides the value a developer sets for it locally.
+ * **Locally configured endpoints** : with OTLP/HTTP export enabled, the CLI ignores any locally configured endpoint, whether or not the gateway pushed the telemetry variables. Its exports go to the gateway unless a policy names your collector as the endpoint.
+
+Without a `forward_to` destination for a signal, the gateway accepts and discards it. If developers already export Claude Code telemetry to one of your collectors, add it as a `forward_to` destination, with logs or traces enabled if they export those, so it keeps receiving their data after they sign in. To skip the relay instead, name the collector in a policy. [Traces](</docs/en/monitoring-usage#traces-beta>) also require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. Set it in a managed policy’s `env` block, since the gateway doesn’t push it. Developers approve it in the same security approval dialog that the pushed endpoint already triggers. Set it to `1` only in the policies whose groups you want traced. A policy that doesn’t set it inherits the value from your `match: {}` catch-all policy if that policy sets one, per the merge rules. To keep a group’s clients from sending traces even when a developer sets the variable locally, set it to `0` in that group’s policy. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+
+####
+
+
+
+Export directly to your collector
+
+To have sessions signed in through `/login` send telemetry straight to your collector instead of through the relay, set `OTEL_EXPORTER_OTLP_ENDPOINT` to the collector’s `https://` base URL in the `env` block of a managed policy. Claude Code appends `/v1/metrics`, `/v1/logs`, or `/v1/traces` to the URL you set, such as `https://otel-collector.example.com:4318`, and exports each signal there over OTLP/HTTP. Requires Claude Code v2.1.265 or later on each developer’s machine. Earlier clients export through the relay. To authenticate to the collector, set `OTEL_EXPORTER_OTLP_HEADERS` in the same `env` block. Sessions never send the developer’s gateway session token to a collector named this way. When you add or change this endpoint in a policy, Claude Code asks each developer to approve it in the security approval dialog before applying it in an interactive session. Claude Code checks the endpoint before it exports a signal directly, and keeps that signal on the relay when a check fails. The checks include:
+
+ * The endpoint comes from the gateway itself. If you set the same variable in an MDM profile or a local `managed-settings.json`, exports stay on the relay.
+ * The URL uses `https://`, or `http://` to a loopback address
+ * The URL resolves to a path ending in `/v1/<signal>`, with no query or fragment. Claude Code builds that path itself from the generic variable. It uses a per-signal variable such as `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` as written, so include the full path there.
+ * The URL isn’t the gateway’s own host. An endpoint addressed to the gateway keeps the relay path and its session token.
+ * Neither you nor the developer has configured [`otelHeadersHelper`](</docs/en/settings-reference#otelheadershelper>) in any settings source. With a helper configured, every signal stays on the relay.
+
+The endpoint you name changes only where exports go. You still choose which signals export at all with the `OTEL_*_EXPORTER` selectors. The endpoint alone doesn’t turn export on, so also set the variables that do, unless the gateway already pushes them:
+
+ * If the gateway already pushes the telemetry variables, they cover enablement, selectors, and protocol, and your explicit endpoint overrides the pushed `<public_url>` value. Set an `OTEL_*_EXPORTER` selector to `otlp` yourself only for a signal that no `forward_to` destination enables.
+ * If it doesn’t, also set `CLAUDE_CODE_ENABLE_TELEMETRY=1`, the `OTEL_*_EXPORTER` selectors, and `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`.
+
+When the developer signs out, or signs in to a different gateway, exports to the collector stop and Claude Code drops each remaining batch rather than sending it.
+
+####
+
+
+
+When a destination fails
+
+The gateway doesn’t buffer, retry, or store telemetry, so it drops an export that doesn’t reach a destination rather than delivering it late. Each destination succeeds or fails on its own, and the exporting client receives a success response either way, so a failed delivery appears only in the gateway’s log. After five consecutive failed deliveries to a destination, the gateway pauses forwarding to it in 30-second stretches, logging each pause, until a delivery succeeds. Any error response, timeout, or connection error counts as a failed delivery, except `400`, `413`, `415`, `422`, and `431`, which mean the collector refused that export’s payload as malformed or too large. A refused payload neither advances nor resets the failure count: the gateway keeps forwarding to the destination and logs a warning naming it and the status, on the destination’s first refusal and every hundredth after.
###
@@ -808,6 +852,7 @@
# fail_closed_on_error: false
# Meter at contracted rates instead of USD list price. Requires admin:.
+ # With managed:, the same rates also go to signed-in clients.
# Rates below are placeholders, not real contract prices.
# pricing:
# multiplier: 0.85
@@ -896,15 +941,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform:
-
-Platform| Path
----|---
-macOS| `/Library/Application Support/ClaudeCode/managed-settings.json`, or the `com.anthropic.claudecode` managed preferences domain
-Linux and WSL| `/etc/claude-code/managed-settings.json`
-Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
-
-By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform. See [where each mechanism stores the policy](</docs/en/managed-settings#where-each-mechanism-stores-the-policy>). By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -57,7 +57,7 @@
`port`| No| Bind port. Default `8080`.
`public_url`| Unless `host` is loopback| The externally visible `https://` origin, used to build the IdP `redirect_uri` and discovery metadata. Required whenever `host` isn’t a loopback address, whether TLS terminates at a proxy such as an ALB, Ingress, or Cloud Run or at the gateway itself through `tls`, because the gateway never derives its own origin from `X-Forwarded-*` headers; they are client-spoofable. Boot fails without it. `trusted_proxies` below governs client-IP resolution only. Also required to enable telemetry, because the gateway builds the OTLP endpoint it pushes to clients from this URL.
`tls.cert` / `tls.key`| No| PEM paths if the gateway terminates TLS itself
-`trusted_proxies`| No| CIDRs or IPs of load balancers in front of the gateway. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit. Equivalent to nginx `set_real_ip_from`.
+`trusted_proxies`| No| CIDRs or IPs of load balancers in front of the gateway. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit. Equivalent to nginx `set_real_ip_from`. `X-Forwarded-For` entries written as `ipv4:port` or `[ipv6]:port`, as some load balancers do, are read with the port dropped. An IPv6 address with a port appended and no brackets may be read as a different address or not read at all, so turn off the port option on any proxy that writes that form.
###
@@ -77,6 +77,7 @@
`google_groups`| No| Look up the signed-in user’s groups through the Google Workspace Admin SDK Directory API, because Google’s id_token carries no groups claim. Set `service_account_json_path` to a service-account key file with domain-wide delegation on the `https://www.googleapis.com/auth/admin.directory.group.readonly` scope, and `admin_email` to a Workspace administrator the service account impersonates; the Directory API requires a real admin subject. Each user’s group email addresses become their groups claim, so `allowed_groups` and `managed.policies.match.groups` match on group emails.
`email_claim`| No| Which id_token claim carries the user’s email. Default `email`. Some IdPs, such as ADFS and Entra B2C, emit `upn` or `preferred_username` instead. Accepts a flat key, a JSON Pointer, or a list of fallback keys where the first present key is used.
`scopes`| No| Full override of the OIDC scopes the gateway requests. Default `[openid, profile, email, offline_access]`. Set when your IdP rejects scopes it doesn’t recognize, or requires a custom scope to emit groups or email. Must include `openid`. Dropping `offline_access` disables refresh tokens, so developers re-run the browser login every `session.ttl_hours`. See [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for per-IdP scope recipes such as Google’s refresh-token flow.
+`scope_on_refresh`| No| Also send `scope`, with the same list as the sign-in request, when the gateway exchanges a refresh token. Default `false`: the refresh request omits `scope`. Most IdPs return an id_token on every refresh and don’t need this. Set `true` when your IdP returns an id_token on refresh only if asked for `openid` again, which Okta documents for its refresh grant. Without an id_token, every refresh depends on the IdP’s userinfo endpoint accepting the refreshed access token. If you gate sign-in or match policies on groups and your IdP’s refresh-time id_token omits them, also set `userinfo_fallback: true` so the gateway fills them from the userinfo endpoint. An IdP that granted fewer scopes than requested can reject the refresh with `invalid_scope`, including for existing sessions if you add entries to `scopes` while this is on. Unset the key if refreshes start failing at `token_endpoint` after you set it. Requires Claude Code v2.1.260 or later on the gateway server.
`extra_auth_params`| No| Extra query parameters appended to the IdP authorization request, verbatim. This is the override mechanism for IdP-specific behavior, such as `access_type: offline` for Google refresh tokens, `domain_hint` for some Entra tenants, or `acr_values` for step-up flows. Cannot override the gateway-managed protocol params: `state`, `nonce`, `redirect_uri`, PKCE, `scope`, `response_type`, `response_mode`, and `client_id`.
`userinfo_fallback`| No| When the id_token omits email or groups, fetch them from `/userinfo`. Needed for Keycloak lightweight access tokens, the Okta org server, and ADFS minimal tokens. The id_token stays authoritative; userinfo only fills gaps. Default `false`.
`use_pkce`| No| Send a PKCE (S256) challenge on the authorization request. Default `true`. Set `false` only if your IdP rejects PKCE for this confidential client.
@@ -234,7 +235,7 @@
Setup| How
---|---
-IAM permissions| Grant the gateway’s principal `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on both the inference-profile ARNs and the underlying foundation-model ARNs. For the built-in catalog in US regions: `arn:aws:bedrock:<region>:<account>:inference-profile/us.anthropic.*` and `arn:aws:bedrock:*::foundation-model/anthropic.*`.
+IAM permissions| Grant the gateway’s principal `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on both the inference-profile ARNs and the underlying foundation-model ARNs. For the built-in catalog in US regions: `arn:aws:bedrock:<region>:<account>:inference-profile/us.anthropic.*` and `arn:aws:bedrock:*::foundation-model/anthropic.*`. Also grant `bedrock:CountTokens` on the foundation-model ARNs. The gateway uses it, at no charge, to count the input tokens of a request the client abandoned, so spend limits stay accurate. Without it the gateway falls back to a one-token Bedrock request for that count.
Model access| Amazon Bedrock enables model access by default in commercial regions. The remaining account-level gate is Anthropic’s one-time use case form: if no one in your AWS account has submitted it, open the Amazon Bedrock console, select an Anthropic model from the Model catalog, and complete the form. See [Submit use case details](</docs/en/amazon-bedrock#1-submit-use-case-details>) for the AWS Organizations form and the permissions the submitter needs.
EKS (IRSA)| Create an IAM role with the policy above and a trust policy for your cluster’s OIDC provider scoped to the gateway’s service account. Annotate the service account with `eks.amazonaws.com/role-arn: arn:aws:iam::<acct>:role/claude-gateway`. `auth: {}` picks it up.
ECS / EC2| Attach the IAM role to the task definition or instance profile. `auth: {}` picks it up.
@@ -600,6 +601,7 @@
`allowManagedPermissionRulesOnly`| CLI| When `true`, managed settings become the only settings source of permission rules. The [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) entry lists every source Claude Code then ignores.
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
+`managedMcpServers`| CLI| Remote MCP servers [provided to every matching developer](</docs/en/managed-mcp#provide-servers-through-managed-settings>) alongside the servers they add themselves, `http` and `sse` only. See MCP servers in a policy. Requires Claude Code v2.1.259 or later on the gateway server and on clients. Earlier clients ignore the key.
Because these settings arrive over the network, the CLI shows each developer a security approval dialog before applying the settings listed below:
@@ -615,6 +617,14 @@
+MCP servers in a policy
+
+To provide MCP servers to the Claude Code clients a policy matches, set [`managedMcpServers`](</docs/en/managed-mcp#provide-servers-through-managed-settings>) in that policy’s `cli` block. You need Claude Code v2.1.259 or later on the gateway server and on clients. The gateway checks each entry at boot with [the same rules Claude Code applies on the client](</docs/en/managed-mcp#what-an-entry-can-contain>), and if an entry fails a check, the gateway refuses to start and names the entry. If you write a `${VAR}` reference in `gateway.yaml`, the gateway resolves it from its environment at boot through secret expansion before it runs the entry checks, so every matching client receives the literal value and can read it. The [header guidance for provided servers](</docs/en/managed-mcp#provide-servers-through-managed-settings>) applies to the expanded value. The gateway rejects the `.mcp.json` spelling `mcpServers` in a `cli` block, and its boot error names `managedMcpServers` as the key to use. Before v2.1.259, the gateway rejected any MCP server definition in a `cli` block.
+
+####
+
+
+
Claude Desktop overlay
If your organization also deploys [Claude Desktop](</docs/en/desktop>), the same gateway serves both clients. Point `bootstrapUrl`, in Claude Desktop’s [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>), at `<listen.public_url>/user/bootstrap`. Claude Desktop derives the OAuth issuer from that URL, runs the same device-code sign-in against this gateway, and fetches its configuration from the response.
@@ -626,9 +636,9 @@
* The model list, from `availableModels`
* Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
* The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
- * An OTLP endpoint that points at the gateway itself, which fans out to your destinations, included when `telemetry` forwarding is configured
-
-To set `disabledBuiltinTools` or `coworkEgressAllowedHosts` in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
+ * An OTLP endpoint that points at the gateway itself, which fans out to your destinations, included when `telemetry` forwarding is configured. Claude Desktop exports every signal with one encoding: `http/protobuf`, or `http/json` when you set `OTEL_EXPORTER_OTLP_PROTOCOL` or one of its per-signal variants to `http/json` in the policy’s `env`. Before Claude Code v2.1.261 on the gateway server, the response set `http/json` regardless, so a collector that accepts only protobuf rejected Claude Desktop’s exports
+
+To set `disabledBuiltinTools`, `coworkEgressAllowedHosts`, or Claude Desktop’s own `managedMcpServers` setting in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. Claude Desktop’s `managedMcpServers` takes an array value rather than an object. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
managed:
policies:
@@ -643,11 +653,11 @@
Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway validates each `desktop` block at boot against the configuration schema Claude Desktop itself uses, so a mistake surfaces at gateway start as an error naming the key rather than reaching every connected desktop. The gateway fails at boot when a block contains:
* An unknown key
- * A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value or a misspelled sub-key inside a nested entry
+ * A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value or a misspelled sub-key inside a nested entry. Before v2.1.260, the gateway silently dropped a misspelled field inside a nested object of a `managedMcpServers` or `orgPluginSettings` entry instead of failing at boot.
* A key the gateway computes itself: the inference connection, the model list, and the OTLP relay. Configure those through `upstreams`, `models`, and the `telemetry` section’s `forward_to`.
* A legacy alias of a current key. In the boot error, the gateway names the canonical key to write.
-As with the `cli` block, the gateway validates against the schema bundled with its installed version. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
+If you use a deprecated value or entry shape, such as a `managedMcpServers` entry without `transport`, the gateway starts and logs a warning that names the replacement. The gateway validates a `desktop` block against the schema bundled with its installed version, as it does the `cli` block. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. For example, `userPluginMarketplacesEnabled` and `userPluginUploadsEnabled` need Claude Code v2.1.260 or later on the gateway server and Claude Desktop 1.37937.0 or later on members’ machines. If you set `orgPluginSettings` in a policy’s `desktop` block, the gateway serves it in the array form that Claude Desktop 1.15200.0 and later reads. Older desktops ignore the array and enforce no plugin tool policy, so update members to 1.15200.0 or later before you rely on it. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
* `disabledBuiltinTools`: the gateway uses the union of the base’s list and the policy’s list
* `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
@@ -661,8 +671,6 @@
Precedence with other managed sources
If a device also has an MDM-delivered policy or a local `managed-settings.json`, gateway-delivered settings rank first. [Precedence within the managed tier](</docs/en/managed-settings#precedence-within-the-managed-tier>) on the managed settings page says when the local sources apply, and has the [keys Claude Code reads from every admin source](</docs/en/managed-settings#keys-read-from-every-admin-source>) regardless of which source it selected, such as the sandbox lock keys, `forceRemoteSettingsRefresh`, and the per-variable `env` merge. A [`policyHelper`](</docs/en/settings-reference#policyhelper>) configured in an MDM profile or the managed settings file runs only when the gateway delivers no settings; the entry says what its output replaces. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. [Parent settings from embedding hosts](</docs/en/managed-settings#parent-settings-from-embedding-hosts>) says when Claude Code applies it, and [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
-
-At boot, the gateway rejects `mcpServers` inside a policy’s `cli` block. You can’t distribute MCP servers per group to Claude Code clients; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally. You can deliver Claude Desktop’s `managedMcpServers` setting to Claude Desktop clients through a policy’s `desktop` block. To set it, you need Claude Code v2.1.232 or later on the gateway server.
###
@@ -718,7 +726,7 @@
Block| Key| Default| Description
---|---|---|---
-`access_control`| `allow_cidrs` / `deny_cidrs`| empty| Inbound IP allow/deny by client address, after `trusted_proxies` resolution. `deny_cidrs` is checked first; a client it matches is rejected even if `allow_cidrs` also matches. If `allow_cidrs` is non-empty the gateway is default-deny. `/healthz` and `/readyz` are exempt from `allow_cidrs`.
+`access_control`| `allow_cidrs` / `deny_cidrs`| empty| Inbound IP allow/deny by client address, after `trusted_proxies` resolution. `deny_cidrs` is checked first; a client it matches is rejected even if `allow_cidrs` also matches. If `allow_cidrs` is non-empty the gateway is default-deny. `/healthz` and `/readyz` are exempt from `allow_cidrs`. When a trusted proxy sends an `X-Forwarded-For` entry that isn’t an IP address, the real client is unknown and the gateway logs a warning once naming what to check. Where either list applies to the request, it refuses it with `403` and audit reason `xff_unparseable`. Where neither does, it serves the request and uses the proxy’s own address as the client IP for per-IP rate limits and audit.
`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
`limits`| `max_request_header_bytes`| unset| When set, oversize headers return `431`
`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -608,7 +608,6 @@
* shell-execution settings such as `apiKeyHelper` and `statusLine`
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
- * managed CLAUDE.md content
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, Claude Code therefore shows the dialog to every matching developer. It shows the dialog in a running session on the next hourly poll, and otherwise at the developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -597,7 +597,7 @@
`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that skips permission prompts, and the `--dangerously-skip-permissions` flag
-`allowManagedPermissionRulesOnly`| CLI| When `true`, user and project permission rules are ignored; only rules from this document apply
+`allowManagedPermissionRulesOnly`| CLI| When `true`, managed settings become the only settings source of permission rules. The [`allowManagedPermissionRulesOnly`](</docs/en/settings-reference#allowmanagedpermissionrulesonly>) entry lists every source Claude Code then ignores.
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -607,6 +607,7 @@
* `env` variables that require the developer’s approval, such as proxy and base-URL variables
* shell-execution settings such as `apiKeyHelper` and `statusLine`
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
+ * Sandbox settings that intercept traffic, inject credentials, or weaken isolation, such as `sandbox.network.tlsTerminate` and the proxy port settings. [Security approval dialogs](</docs/en/server-managed-settings#security-approval-dialogs>) lists them all.
* managed CLAUDE.md content
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, Claude Code therefore shows the dialog to every matching developer. It shows the dialog in a running session on the next hourly poll, and otherwise at the developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -560,7 +560,7 @@
What goes in `cli`
-Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
+Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
managed:
policies:
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -531,7 +531,7 @@
The gateway keeps no user directory of its own. It authorizes each request from the user’s IdP token, reading group membership from the token’s `groups` claim and evaluating policies against it. There is no roster to enumerate and no accounts to pre-create, and therefore no SCIM endpoint, because there is nothing for SCIM to sync into.Run user and group lifecycle management at the source of truth, which is your IdP’s native SCIM provisioning or a dedicated identity-governance platform. Membership and deprovisioning governed there flow into the gateway automatically through the token. If you want SCIM provisioning of Claude accounts themselves, that is a [Claude for Enterprise](</docs/en/admin-setup>) capability.Two propagation clocks apply:
- * **Policy contents** : editing a policy and redeploying reaches connected clients on their next managed-settings poll, within an hour
+ * **Policy contents** : editing a policy and redeploying reaches connected clients on their next managed-settings poll, within an hour, apart from the [changes that apply only at the next launch](</docs/en/server-managed-settings#fetch-and-caching-behavior>)
* **Group membership** : changing a user’s group membership changes which policy matches them. This takes effect on the next session re-mint, meaning the next silent refresh, bounded by `session.ttl_hours`.
####
@@ -660,7 +660,7 @@
Precedence with other managed sources
-If a device also has an MDM-delivered policy or a local `managed-settings.json`, Claude Code doesn’t merge the managed sources: gateway-delivered settings rank first, so the local sources supply the policy only when the gateway delivers no policy key. [Precedence within the managed tier](</docs/en/managed-settings#precedence-within-the-managed-tier>) on the managed settings page has the full ranking and the [keys Claude Code reads from every admin source](</docs/en/managed-settings#keys-read-from-every-admin-source>) regardless of which source it selected, such as the sandbox lock keys, `forceRemoteSettingsRefresh`, and the per-variable `env` merge. A [`policyHelper`](</docs/en/settings-reference#policyhelper>) configured in an MDM profile or the managed settings file runs only when the gateway delivers no settings; the entry says what its output replaces. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. [Parent settings from embedding hosts](</docs/en/managed-settings#parent-settings-from-embedding-hosts>) says when Claude Code applies it, and [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
+If a device also has an MDM-delivered policy or a local `managed-settings.json`, gateway-delivered settings rank first. [Precedence within the managed tier](</docs/en/managed-settings#precedence-within-the-managed-tier>) on the managed settings page says when the local sources apply, and has the [keys Claude Code reads from every admin source](</docs/en/managed-settings#keys-read-from-every-admin-source>) regardless of which source it selected, such as the sandbox lock keys, `forceRemoteSettingsRefresh`, and the per-variable `env` merge. A [`policyHelper`](</docs/en/settings-reference#policyhelper>) configured in an MDM profile or the managed settings file runs only when the gateway delivers no settings; the entry says what its output replaces. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. [Parent settings from embedding hosts](</docs/en/managed-settings#parent-settings-from-embedding-hosts>) says when Claude Code applies it, and [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
At boot, the gateway rejects `mcpServers` inside a policy’s `cli` block. You can’t distribute MCP servers per group to Claude Code clients; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally. You can deliver Claude Desktop’s `managedMcpServers` setting to Claude Desktop clients through a policy’s `desktop` block. To set it, you need Claude Code v2.1.232 or later on the gateway server.
@@ -896,7 +896,7 @@
Linux and WSL| `/etc/claude-code/managed-settings.json`
Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
-A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
+By default, a registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -560,7 +560,7 @@
What goes in `cli`
-Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
+Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings, in place of server-managed settings. It therefore ignores the settings [restricted to OS-level policy sources](</docs/en/server-managed-settings#current-limitations>), such as `policyHelper` and `wslInheritsWindowsSettings`. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
managed:
policies:
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -134,6 +134,25 @@
`upstreams`
`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream, and a `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+
+####
+
+
+
+Upstream error messages
+
+The gateway returns one upstream’s error response, or its own `502`, depending on how the upstreams answered:
+
+ * **An upstream returned a status the gateway doesn’tfail over on**: that upstream’s response. The gateway tries no further upstreams.
+ * **Every upstream the gateway tried failed in a way itfails over on**: the last `429`. When none returned a `429`, the gateway prefers, in order, the last `401` or `403`, the last `404`, and the last `501`. When none returned any of those, the gateway’s own `502`, `all upstreams failed (N attempted)`, where N counts every entry in `upstreams`, including entries the gateway skipped because they don’t serve the requested model.
+
+When the gateway returns an upstream’s response, it keeps the upstream’s status code. Whether it keeps the upstream’s message depends on the provider. An Anthropic API upstream’s error body reaches the developer unchanged. The Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry upstreams can name your account IDs, role ARNs, and project IDs in their error text. The gateway records that full text in the [operational log](</docs/en/claude-apps-gateway-deploy#logs>). What the developer sees from those upstreams depends on the rejection:
+
+ * `400` or `413` in Anthropic’s standard error envelope: the upstream’s own message, such as `prompt is too long`. Claude Platform on AWS, Agent Platform, and Microsoft Foundry return this envelope for model API rejections.
+ * `400` or `413` in the provider’s own shape: a `capability_rejected:` token. When the gateway can’t classify the rejection, `upstream rejected the request` on a `400` or `request too large for this upstream` on a `413`.
+ * Any other status: generic per-status copy, such as `upstream rate limit exceeded` on a `429`.
+
+For example, the gateway replaces Amazon Bedrock’s `Input is too long for requested model.` with `capability_rejected: prompt_too_long`. Claude Code [compacts automatically](</docs/en/errors#prompt-is-too-long>) on that token, as it does on `prompt is too long`. Keeping a cloud upstream’s `400` or `413` message, or replacing it with a `capability_rejected:` token, requires gateway v2.1.233 or later.
####
@@ -541,7 +560,7 @@
What goes in `cli`
-Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings#available-settings>). The keys most operators reach for first:
+Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings-reference#all-settings>). The keys most operators reach for first:
managed:
policies:
@@ -590,7 +609,7 @@
* the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* managed CLAUDE.md content
-[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook, or any env var that triggers the dialog, to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits that session rather than applying the policy. When you push a new hook, or any env var that triggers the dialog, to a broad policy, Claude Code therefore shows the dialog to every matching developer. It shows the dialog in a running session on the next hourly poll, and otherwise at the developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
####
@@ -641,34 +660,7 @@
Precedence with other managed sources
-If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge, with two per-key exceptions:
-
- * The `env` block, in Claude Code v2.1.223 or later
- * The [cross-source lock keys](</docs/en/settings#precedence-within-the-managed-tier>)
-
-Both are covered in the list later in this section. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
-
- 1. Gateway-delivered settings
- 2. MDM, via the HKLM registry on Windows or a plist on macOS
- 3. The `managed-settings.json` file
- 4. The HKCU registry, on Windows only
-
-When an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>), the helper’s output replaces that source and neither per-key exception applies. A `policyHelper` in those sources doesn’t run while the gateway delivers a non-empty configuration. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
-
- * On machines with an admin-deployed managed source, it is ignored unless the highest-priority source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>).
- * It is never merged when an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>).
- * When merged, it passes through a restrictive-only allowlist. [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks.
-
-The following keys are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy. When an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>), the helper’s output is the only source these checks read:
-
- * `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
- * [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
- * `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
- * [`sandbox.ripgrep`](</docs/en/settings#sandbox-settings>): the `ripgrep` binary the sandbox uses
- * [`forceRemoteSettingsRefresh`](</docs/en/server-managed-settings>): blocks startup until remote managed settings are freshly fetched, so an MDM or file policy that sets it is honored even when a cached remote payload that lacks the key is the highest-priority source
- * `env`: each variable comes from the highest-priority admin source that defines it, and lower admin sources fill in variables the higher sources leave unset. The telemetry unit and credential-paired routing variables follow their own rules; see [Per-key exceptions across managed sources](</docs/en/server-managed-settings#per-key-exceptions-across-managed-sources>). Requires Claude Code v2.1.223 or later
-
-Every other key, including `disableBypassPermissionsMode`, comes from the highest-priority source only. One [parent-settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) check reads every admin source: when any admin source sets `allowManagedPermissionRulesOnly`, Claude Code drops parent-supplied permission allow rules and `additionalDirectories`. The key’s effect on the developer’s own rules still follows the highest-priority source. A `forceLoginOrgUUID` or `allowedMcpServers` value in the highest-priority admin source blocks a parent-supplied one and is the value Claude Code enforces. A value in a non-winning admin source neither applies nor blocks the parent’s. Before v2.1.223, a value in any admin source blocked the parent’s. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rules on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
+If a device also has an MDM-delivered policy or a local `managed-settings.json`, Claude Code doesn’t merge the managed sources: gateway-delivered settings rank first, so the local sources supply the policy only when the gateway delivers no policy key. [Precedence within the managed tier](</docs/en/managed-settings#precedence-within-the-managed-tier>) on the managed settings page has the full ranking and the [keys Claude Code reads from every admin source](</docs/en/managed-settings#keys-read-from-every-admin-source>) regardless of which source it selected, such as the sandbox lock keys, `forceRemoteSettingsRefresh`, and the per-variable `env` merge. A [`policyHelper`](</docs/en/settings-reference#policyhelper>) configured in an MDM profile or the managed settings file runs only when the gateway delivers no settings; the entry says what its output replaces. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. [Parent settings from embedding hosts](</docs/en/managed-settings#parent-settings-from-embedding-hosts>) says when Claude Code applies it, and [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
At boot, the gateway rejects `mcpServers` inside a policy’s `cli` block. You can’t distribute MCP servers per group to Claude Code clients; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally. You can deliver Claude Desktop’s `managedMcpServers` setting to Claude Desktop clients through a policy’s `desktop` block. To set it, you need Claude Code v2.1.232 or later on the gateway server.
@@ -888,7 +880,7 @@
Client-side managed settings
-Everything above configures the gateway server. You point developer machines at the gateway separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
+Everything above configures the gateway server. You point developer machines at the gateway separately, on each device, through Claude Code’s [managed settings](</docs/en/managed-settings>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
{
"forceLoginMethod": "gateway",
@@ -904,7 +896,7 @@
Linux and WSL| `/etc/claude-code/managed-settings.json`
Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
-A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. `forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
+A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. [`forceLoginGatewayUrl`](</docs/en/settings-reference#forcelogingatewayurl>), and the `"gateway"` value of [`forceLoginMethod`](</docs/en/settings-reference#forceloginmethod>), are honored only from a managed source on the machine: `managed-settings.json`, the macOS plist or Windows HKLM registry, or a policy helper. A developer setting them in their own `~/.claude/settings.json` has no effect, and neither does setting them in the gateway payload.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -641,26 +641,25 @@
Precedence with other managed sources
-If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge, with two per-key exceptions while no [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is supplying managed settings, since a helper’s output replaces the managed sources entirely:
+If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge, with two per-key exceptions:
* The `env` block, in Claude Code v2.1.223 or later
* The [cross-source lock keys](</docs/en/settings#precedence-within-the-managed-tier>)
Both are covered in the list later in this section. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
- 1. The [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>)
- 2. Gateway-delivered settings
- 3. MDM, via the HKLM registry on Windows or a plist on macOS
- 4. The `managed-settings.json` file
- 5. The HKCU registry, on Windows only
-
-Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
+ 1. Gateway-delivered settings
+ 2. MDM, via the HKLM registry on Windows or a plist on macOS
+ 3. The `managed-settings.json` file
+ 4. The HKCU registry, on Windows only
+
+When an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>), the helper’s output replaces that source and neither per-key exception applies. A `policyHelper` in those sources doesn’t run while the gateway delivers a non-empty configuration. Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
* On machines with an admin-deployed managed source, it is ignored unless the highest-priority source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>).
- * It is never merged while a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is configured.
+ * It is never merged when an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>).
* When merged, it passes through a restrictive-only allowlist. [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks.
-The following keys are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy. When a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is configured, its output is the only source these checks read:
+The following keys are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy. When an MDM or file-based source wins and configures a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>), the helper’s output is the only source these checks read:
* `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
* [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -166,6 +166,27 @@
identity_token_file: /var/run/secrets/anthropic/id-token
# workspace_id: wrkspc_... # required if the rule covers >1 workspace
# service_account_id: svac_... # optional expected-target check
+
+##### Per-user identity headers for a proxy you run
+
+You can point a `provider: anthropic` upstream’s `base_url` at a proxy you run instead of at the Anthropic API. To tell that proxy which developer sent each request, set `forward_user_identity: true` on that upstream. The proxy can then attribute spend per developer. Requires a gateway running Claude Code v2.1.233 or later. For example, for a proxy at `upstream-gateway.internal.example.com`:
+
+ upstreams:
+ - provider: anthropic
+ base_url: https://upstream-gateway.internal.example.com
+ auth:
+ api_key: ${PROXY_KEY}
+ forward_user_identity: true # default false
+
+The gateway adds these headers to every request it forwards to that upstream.
+
+Header| Value
+---|---
+`x-litellm-end-user-id`| The developer’s email, when the IdP supplied one.
+`x-claude-gateway-user-id`| The developer’s IdP subject, from the token’s `sub` claim.
+`x-claude-gateway-user-email`| The developer’s email, when the IdP supplied one.
+
+When the IdP token carries no email, the gateway sends only `x-claude-gateway-user-id` and omits the two email headers. If your IdP puts the email in a different claim, set `oidc.email_claim` to that claim. Set `forward_user_identity` only on an upstream whose `base_url` is a proxy you operate. The gateway sends developer emails to whatever server that `base_url` names. If the `base_url` is the Anthropic API, which is the default, the gateway refuses to start.
####
@@ -374,7 +395,7 @@
---|---|---
`write_keys`| No| Array of `{id, key}`. An `x-api-key` matching one of these can list, set, and delete spend limits. Key values must be at least 32 characters; `id`s must be unique across `read_keys` and `write_keys`.
`read_keys`| No| Array of `{id, key}`. Read-only: every `GET` endpoint, including listing caps, fetching one by ID, and reading [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) and [`/audit`](</docs/en/claude-apps-gateway-spend-limits#%2Faudit>).
-`admin_groups`| No| IdP group names. A gateway JWT whose `groups` claim includes one of these has full admin access, read and write, and audits as `oidc:<sub>`. Use this for human admins; use API keys for machines.
+`admin_groups`| No| IdP group names. A gateway JWT whose `groups` claim includes one of these has full admin access, read and write, and audits as `oidc:<sub>`. Use this for human admins; use API keys for machines. An empty entry in this list stops the gateway at boot. See Matcher values that stop the gateway at boot.
`blocked_message`| No| Appended verbatim to the `429 billing_error` a blocked developer sees. Write the whole instruction, such as a URL or a Slack channel. When unset, the gateway sends only the default message. See [How enforcement works](</docs/en/claude-apps-gateway-spend-limits#how-enforcement-works>).
`audit_retention_days`| No| Default `365`. Older `admin_audit` rows are swept.
`spend_retention_months`| No| Default `13`. `spend` counter rows older than this are swept. The default keeps a full year plus the current partial month for year-over-year reporting.
@@ -498,6 +519,26 @@
+Matcher values that stop the gateway at boot
+
+At boot, the gateway checks the `match` block of every policy and the `admin_groups` list. Any of these values stops the gateway with an error that names the field:
+
+ * An empty `groups` list
+ * An empty entry in `groups` or in `admin_groups`
+ * An empty `email_domain`
+ * An `email_domain` that contains `@`, whitespace, or a comma. The gateway trims the value and strips one leading `@` before this check. Write one bare domain, such as `example.com`.
+
+Before v2.1.232, the gateway started with these values. Each value had this effect:
+
+ * An empty `email_domain`: the gateway skipped the domain check, so a policy with an empty `email_domain` and no `groups` list matched every authenticated user
+ * An empty `groups` list: the policy matched no one
+ * An `email_domain` containing `@`, whitespace, or a comma: the policy matched no one
+ * An empty entry in `groups` or in `admin_groups`: the entry matched a user only when that user’s IdP `groups` claim also contained an empty entry. In `admin_groups`, that match granted admin access. If your `admin_groups` list never contained an empty entry, no one gained admin access this way.
+
+####
+
+
+
What goes in `cli`
Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings#available-settings>). The keys most operators reach for first:
@@ -546,6 +587,7 @@
* `hooks`
* `env` variables that require the developer’s approval, such as proxy and base-URL variables
* shell-execution settings such as `apiKeyHelper` and `statusLine`
+ * the sandbox binary settings `sandbox.bwrapPath`, `sandbox.socatPath`, and `sandbox.ripgrep`
* managed CLAUDE.md content
[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook, or any env var that triggers the dialog, to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
@@ -623,6 +665,7 @@
* `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
* [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
* `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
+ * [`sandbox.ripgrep`](</docs/en/settings#sandbox-settings>): the `ripgrep` binary the sandbox uses
* [`forceRemoteSettingsRefresh`](</docs/en/server-managed-settings>): blocks startup until remote managed settings are freshly fetched, so an MDM or file policy that sets it is honored even when a cached remote payload that lacks the key is the highest-priority source
* `env`: each variable comes from the highest-priority admin source that defines it, and lower admin sources fill in variables the higher sources leave unset. The telemetry unit and credential-paired routing variables follow their own rules; see [Per-key exceptions across managed sources](</docs/en/server-managed-settings#per-key-exceptions-across-managed-sources>). Requires Claude Code v2.1.223 or later
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -322,12 +322,7 @@
auth:
api_key: ${ANTHROPIC_API_KEY}
- # Per-upstream model IDs are keyed on the upstream's `name:`; an upstream
- # without a `name:` defaults to its provider string (e.g. `bedrock`). For a
- # built-in Claude model, an upstream you leave out of the map still serves it
- # with that provider's default ID; list the upstream to override the ID, for
- # example with a provisioned-throughput ARN. Only a custom `id` that isn't a
- # built-in model skips the upstreams missing from its map.
+ # Per-upstream model IDs are keyed on the upstream's `name:`.
models:
- id: claude-opus-4-8
label: Claude Opus 4.8
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -568,11 +568,11 @@
The gateway derives much of the response from the matched policy’s `cli` block and from top-level gateway config:
* The model list, from `availableModels`
- * Disabled tools, from bare tool-name `permissions.deny` entries
- * The egress allowlist, from `sandbox.network.allowedDomains`
+ * Disabled tools, from bare tool-name `permissions.deny` entries. If you set `disabledBuiltinTools` in the policy’s `desktop` block, the gateway serves the union of your value and the derived list, so you can disable more tools this way but can’t re-enable one you disabled through `permissions.deny`
+ * The egress allowlist, from `sandbox.network.allowedDomains`. If you set `coworkEgressAllowedHosts` in the policy’s `desktop` block, the gateway uses that value instead of the derived list
* An OTLP endpoint that points at the gateway itself, which fans out to your destinations, included when `telemetry` forwarding is configured
-The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. The optional `desktop` block alongside `cli` holds the Claude Desktop feature gates that have no CLI equivalent:
+To set `disabledBuiltinTools` or `coworkEgressAllowedHosts` in a policy’s `desktop` block, you need Claude Code v2.1.232 or later on the gateway server. The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. Add the optional `desktop` block alongside `cli` to set Claude Desktop settings directly. Write settings from Claude Desktop’s [managed configuration reference](<https://claude.com/docs/third-party/claude-desktop/configuration>) as flat key names. Leave out keys Claude Desktop reads only from MDM or local files, such as `bootstrapUrl`; the gateway rejects them at boot. Before v2.1.232, the gateway accepted a fixed list of 11 feature-gate keys, such as `chatTabEnabled` and `disableAutoUpdates`, and rejected every other key at boot. Before v2.1.227, the gateway also rejected `chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` at boot.
managed:
policies:
@@ -584,18 +584,19 @@
disableAutoUpdates: true
banner: { text: "Contractor build: internal use only" }
-Key| Effect
----|---
-`modelDiscoveryEnabled`| Whether Claude Desktop fetches `/v1/models` for its picker. Set `false` to rely solely on the policy’s model list.
-`coworkTabEnabled`, `isClaudeCodeForDesktopEnabled`| Show or hide the Cowork and Code tabs. Both show unless set `false`
-`chatTabEnabled`| Show or hide the Chat tab. Hidden unless set `true`
-`chatAdvancedFileAnalysisEnabled`| Let Claude run code in a local sandbox from the Chat tab to analyze attached files it can’t read natively, such as spreadsheets and presentations. Off unless set `true`. Has no effect when the policy’s `permissions.deny` disables `Bash`
-`isDesktopExtensionEnabled`, `isDesktopExtensionSignatureRequired`| Desktop extension loading and signature checks
-`isLocalDevMcpEnabled`| Allow locally defined MCP servers
-`disableAutoUpdates`, `autoUpdaterEnforcementHours`| Auto-update policy
-`banner`| Persistent banner at the top of the app: `enabled`, `text`, `backgroundColor`, `textColor`, `linkUrl`
-
-`chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` require Claude Code v2.1.227 or later on the gateway server. Earlier releases reject them at boot. Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway rejects unknown keys at boot. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; `/user/bootstrap` then returns 404 for every user.
+Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway validates each `desktop` block at boot against the configuration schema Claude Desktop itself uses, so a mistake surfaces at gateway start as an error naming the key rather than reaching every connected desktop. The gateway fails at boot when a block contains:
+
+ * An unknown key
+ * A recognized key whose value Claude Desktop would reject or silently drop, such as an empty value or a misspelled sub-key inside a nested entry
+ * A key the gateway computes itself: the inference connection, the model list, and the OTLP relay. Configure those through `upstreams`, `models`, and the `telemetry` section’s `forward_to`.
+ * A legacy alias of a current key. In the boot error, the gateway names the canonical key to write.
+
+As with the `cli` block, the gateway validates against the schema bundled with its installed version. To deliver a setting introduced by a newer Claude Desktop release, upgrade the gateway first. The gateway fills in keys a policy’s `desktop` block doesn’t set from the `match: {}` catch-all’s `desktop` block, the same way it fills in a policy’s `cli` block from the base. If you set `disabledBuiltinTools` or `builtinToolPolicy` in both the base and a role policy, the gateway keeps the base’s restriction:
+
+ * `disabledBuiltinTools`: the gateway uses the union of the base’s list and the policy’s list
+ * `builtinToolPolicy`: if you set a tool to a value other than `allow` in the base, the gateway keeps that value even if you set `allow` for the same tool in a role policy
+
+For every other key, if you set it in the role policy, the gateway uses the role policy’s value. The gateway replaces an array or a nested object such as `banner` whole, so if you set `banner.text` in a role policy, the gateway drops the base’s `banner.backgroundColor`. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; the gateway then returns 404 from `/user/bootstrap` for every user.
####
@@ -632,7 +633,7 @@
Every other key, including `disableBypassPermissionsMode`, comes from the highest-priority source only. One [parent-settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) check reads every admin source: when any admin source sets `allowManagedPermissionRulesOnly`, Claude Code drops parent-supplied permission allow rules and `additionalDirectories`. The key’s effect on the developer’s own rules still follows the highest-priority source. A `forceLoginOrgUUID` or `allowedMcpServers` value in the highest-priority admin source blocks a parent-supplied one and is the value Claude Code enforces. A value in a non-winning admin source neither applies nor blocks the parent’s. Before v2.1.223, a value in any admin source blocked the parent’s. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rules on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
-`mcpServers` inside a policy’s `cli` block is rejected at gateway boot. Per-group MCP distribution is not available; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally.
+At boot, the gateway rejects `mcpServers` inside a policy’s `cli` block. You can’t distribute MCP servers per group to Claude Code clients; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally. You can deliver Claude Desktop’s `managedMcpServers` setting to Claude Desktop clients through a policy’s `desktop` block. To set it, you need Claude Code v2.1.232 or later on the gateway server.
###
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -606,7 +606,7 @@
If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge, with two per-key exceptions while no [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is supplying managed settings, since a helper’s output replaces the managed sources entirely:
* The `env` block, in Claude Code v2.1.223 or later
- * The [cross-source lock keys](</docs/en/settings#settings-precedence>)
+ * The [cross-source lock keys](</docs/en/settings#precedence-within-the-managed-tier>)
Both are covered in the list later in this section. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
@@ -676,7 +676,7 @@
* `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
* `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`
-The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. Independently of the push, a signed-in CLI that has OTLP/HTTP export enabled sends those exports to the gateway rather than to a locally configured endpoint, and without a `forward_to` destination for a signal the gateway accepts and discards it; if you already collect Claude Code telemetry directly, add your collector as a `forward_to` destination. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. Whether or not the gateway pushes these variables, a CLI signed in through `/login` that has OTLP/HTTP export enabled sends its exports to the gateway rather than to a locally configured endpoint, and without a `forward_to` destination for a signal the gateway accepts and discards it; if you already collect Claude Code telemetry directly, add your collector as a `forward_to` destination. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
###
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -480,7 +480,10 @@
* **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
* **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
-`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. When a request’s `model` value isn’t a string, the gateway rejects the request with a `400` and the message `model must be a string`, so a malformed value never reaches an upstream. Requires a gateway running Claude Code v2.1.221 or later.
+`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. The gateway validates the `model` value itself before it relays a request, so a malformed value never reaches an upstream. It rejects the request with a `400` in two cases:
+
+ * When the value is missing or empty, the gateway rejects the request with the message `model is required`. That check requires a gateway running Claude Code v2.1.228 or later.
+ * When the value is present but isn’t a string, the gateway rejects the request with the message `model must be a string`. Requires a gateway running Claude Code v2.1.221 or later.
Matcher| Behavior
---|---
@@ -584,13 +587,15 @@
Key| Effect
---|---
`modelDiscoveryEnabled`| Whether Claude Desktop fetches `/v1/models` for its picker. Set `false` to rely solely on the policy’s model list.
-`coworkTabEnabled`, `isClaudeCodeForDesktopEnabled`| Show or hide individual tabs
+`coworkTabEnabled`, `isClaudeCodeForDesktopEnabled`| Show or hide the Cowork and Code tabs. Both show unless set `false`
+`chatTabEnabled`| Show or hide the Chat tab. Hidden unless set `true`
+`chatAdvancedFileAnalysisEnabled`| Let Claude run code in a local sandbox from the Chat tab to analyze attached files it can’t read natively, such as spreadsheets and presentations. Off unless set `true`. Has no effect when the policy’s `permissions.deny` disables `Bash`
`isDesktopExtensionEnabled`, `isDesktopExtensionSignatureRequired`| Desktop extension loading and signature checks
`isLocalDevMcpEnabled`| Allow locally defined MCP servers
`disableAutoUpdates`, `autoUpdaterEnforcementHours`| Auto-update policy
`banner`| Persistent banner at the top of the app: `enabled`, `text`, `backgroundColor`, `textColor`, `linkUrl`
-Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway rejects unknown keys at boot. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; `/user/bootstrap` then returns 404 for every user.
+`chatTabEnabled` and `chatAdvancedFileAnalysisEnabled` require Claude Code v2.1.227 or later on the gateway server. Earlier releases reject them at boot. Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway rejects unknown keys at boot. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; `/user/bootstrap` then returns 404 for every user.
####
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -18,6 +18,7 @@
* `admin`: Admin API auth and retention for spend limits
* `enforcement`: spend-limit fail-open or fail-closed behavior
+ * `pricing`: contracted rates and a discount multiplier for the spend meter
* `models` and `auto_include_builtin_models`: admin-curated model list and per-upstream IDs
* `managed`: managed settings policies by IdP group
* `telemetry`: OTLP forwarding to your observability stack
@@ -379,7 +380,7 @@
`write_keys`| No| Array of `{id, key}`. An `x-api-key` matching one of these can list, set, and delete spend limits. Key values must be at least 32 characters; `id`s must be unique across `read_keys` and `write_keys`.
`read_keys`| No| Array of `{id, key}`. Read-only: every `GET` endpoint, including listing caps, fetching one by ID, and reading [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) and [`/audit`](</docs/en/claude-apps-gateway-spend-limits#%2Faudit>).
`admin_groups`| No| IdP group names. A gateway JWT whose `groups` claim includes one of these has full admin access, read and write, and audits as `oidc:<sub>`. Use this for human admins; use API keys for machines.
-`blocked_message`| No| Appended verbatim to the `429 billing_error` a blocked developer sees. Write the whole instruction, such as a URL or a Slack channel. Unset, the error is `spend limit reached`.
+`blocked_message`| No| Appended verbatim to the `429 billing_error` a blocked developer sees. Write the whole instruction, such as a URL or a Slack channel. When unset, the gateway sends only the default message. See [How enforcement works](</docs/en/claude-apps-gateway-spend-limits#how-enforcement-works>).
`audit_retention_days`| No| Default `365`. Older `admin_audit` rows are swept.
`spend_retention_months`| No| Default `13`. `spend` counter rows older than this are swept. The default keeps a full year plus the current partial month for year-over-year reporting.
`identity_retention_days`| No| Default `90`. Last-seen TTL for `principal_emails` rows, which hold each developer’s email, display name, and groups (PII). Deliberately shorter than spend retention so a deprovisioned identity ages out while its anonymous spend counters remain.
@@ -396,6 +397,42 @@
Field| Required| Description
---|---|---
`fail_closed_on_error`| No| Default `false`. Spend enforcement fails open on a Postgres outage, so inference stays up. Set `true` to fail closed: over-cap developers are blocked, but so is everyone else if the store is unreachable. Requires an `admin:` block: spend enforcement only runs when `admin` is configured, and the gateway refuses to start if you set this `true` without one.
+
+###
+
+
+
+`pricing`
+
+The `pricing` block tells the spend meter what to charge instead of USD list price, so caps and [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) reflect your contracted rates. Amounts stay in USD and remain an estimate, not an invoice. Two prerequisites:
+
+ * Claude Code v2.1.227 or later on the gateway server. Earlier versions reject the unknown key at boot.
+ * An `admin:` block, because only the spend meter reads `pricing`. The gateway refuses to start with `pricing` set and no `admin`.
+
+ pricing:
+ multiplier: 0.85
+ overrides:
+ - upstream: bedrock-eu
+ model: claude-sonnet-4-6
+ input: 3.30
+ output: 16.50
+ cache_read: 0.33
+ cache_write: 4.125
+
+Field| Required| Description
+---|---|---
+`multiplier`| No| Default `1`. The meter multiplies every metered amount by this, whether list-priced or overridden, so `0.85` bills 85% of the price. Must be greater than 0 and at most 1.
+`overrides`| No| Rows of `{upstream, model, input, output, cache_read, cache_write}` in USD per million tokens. All four rates are required and must be positive.
+
+How the meter matches an override row:
+
+ * A row replaces list price for requests that `upstream`, an `upstreams[].name`, serves for `model`. That includes the higher [fast mode](</docs/en/fast-mode#understand-the-cost-tradeoff>) rate, so fast and standard requests meter at the same four rates.
+ * A built-in ID such as `claude-sonnet-4-6`, matched like `models[].id`, covers every dated form, regional Amazon Bedrock form, or Google Cloud’s Agent Platform form the meter prices as that model. Any other string, such as an alias or an inference-profile ARN, matches the ID the client sent or the string sent upstream, case-insensitively.
+ * Where rows overlap, the meter picks the most specific row rather than the first row: a row whose `model` is the exact model string sent upstream, then a row matching the exact ID the client sent, then a row naming the built-in model.
+ * An unknown upstream name fails boot, and so do two rows for one upstream that name the same model, including two spellings of one built-in model. The gateway warns at boot about a row no requestable model can use.
+ * Web-search requests stay at the $0.01 list price; the multiplier still applies to them.
+
+For per-region rates, give each region its own named upstream and one row per upstream.
###
@@ -506,14 +543,14 @@
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
-Because these settings arrive over the network, the CLI shows each developer a one-time security approval dialog before applying the settings listed below:
+Because these settings arrive over the network, the CLI shows each developer a security approval dialog before applying the settings listed below:
* `hooks`
* `env` variables that require the developer’s approval, such as proxy and base-URL variables
* shell-execution settings such as `apiKeyHelper` and `statusLine`
* managed CLAUDE.md content
-Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook, or any env var that triggers the dialog, to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+[Approval memory](</docs/en/server-managed-settings#approval-memory>) covers how long an approval lasts and when the dialog appears again. Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook, or any env var that triggers the dialog, to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
####
@@ -726,6 +763,13 @@
# enforcement:
# fail_closed_on_error: false
+
+ # Meter at contracted rates instead of USD list price. Requires admin:.
+ # Rates below are placeholders, not real contract prices.
+ # pricing:
+ # multiplier: 0.85
+ # overrides:
+ # - { upstream: anthropic, model: claude-sonnet-4-6, input: 3.30, output: 16.50, cache_read: 0.33, cache_write: 4.125 }
upstreams:
- provider: anthropic
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -84,8 +84,17 @@
`id_token_signed_response_alg`| No| Expected id_token signing algorithm. Default `RS256`. Set for IdPs that sign with ES256, PS256, or EdDSA.
`additional_authorized_parties`| No| Extra `azp` values to accept beyond `client_id`, for Keycloak broker and token-exchange flows
`discovery_url`| No| Fetch the discovery document from this URL instead of deriving it from `issuer`, for IdPs behind a proxy that rewrites the issuer host. The path must contain `/.well-known/`.
+`use_proxy`| No| Send the gateway’s own IdP requests through the forward proxy in `HTTPS_PROXY` or `HTTP_PROXY`, honoring `NO_PROXY`. Unset or `false`, those requests go direct. Requires v2.1.227 or later; see IdP requests through a forward proxy below.
`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
`ca_cert_pem`| No| The PEM-encoded CA certificate itself, not a path to a file. It replaces the system trust store for IdP requests only. To load a mounted file, write `${file:/etc/gateway/idp-ca.pem}`. Use for Keycloak or Dex behind corporate PKI.
+
+####
+
+
+
+IdP requests through a forward proxy
+
+The inference upstreams honor `HTTPS_PROXY` and `HTTP_PROXY` on every version. The gateway’s own requests to the IdP, discovery, JWKS, token, and userinfo, go direct unless you set `oidc.use_proxy: true`, which requires v2.1.227 or later. When a proxy variable is set, `use_proxy` is unset, and the issuer isn’t covered by `NO_PROXY`, the gateway keeps those requests direct and logs a notice at boot asking you to choose; `use_proxy: false` keeps them direct and silences the notice. With `use_proxy: true`, the pod resolves each IdP endpoint’s hostname itself and asks the proxy to `CONNECT` to the resolved IP address, so the proxy must accept `CONNECT` to the IP address of every host the discovery document names, not only the issuer. Use an `http://` proxy URL. `ca_cert_pem` and the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) apply on the proxied path as well.
###
Show diff (142 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -34,7 +34,7 @@
Form| Resolves to| Use for
---|---|---
`${VAR}`| The environment variable `VAR`. Boot fails if undefined.| Container environment variables, AWS Secrets Manager via env injection
-`${file:/path}`| File contents, trimmed| Kubernetes Secret volume mounts, Vault Agent, SOPS
+`${file:/path}`| Contents of the file at that absolute path, trimmed. The reference must be the field’s entire value: unlike `${VAR}`, it isn’t expanded inside a longer string, so for a database password set `store.password` rather than embedding it in `postgres_url`.| Kubernetes Secret volume mounts, Vault Agent, SOPS
##
@@ -54,7 +54,7 @@
---|---|---
`host`| No| Bind address. Default `0.0.0.0`.
`port`| No| Bind port. Default `8080`.
-`public_url`| Behind a proxy| The externally visible `https://` origin, used to build the IdP `redirect_uri` and discovery metadata. Required behind any TLS-terminating proxy such as an ALB, Ingress, or Cloud Run, because the gateway doesn’t trust `X-Forwarded-*` headers when constructing its own origin; they are client-spoofable. `trusted_proxies` below governs client-IP resolution only. Also required to enable telemetry, because the gateway builds the OTLP endpoint it pushes to clients from this URL.
+`public_url`| Unless `host` is loopback| The externally visible `https://` origin, used to build the IdP `redirect_uri` and discovery metadata. Required whenever `host` isn’t a loopback address, whether TLS terminates at a proxy such as an ALB, Ingress, or Cloud Run or at the gateway itself through `tls`, because the gateway never derives its own origin from `X-Forwarded-*` headers; they are client-spoofable. Boot fails without it. `trusted_proxies` below governs client-IP resolution only. Also required to enable telemetry, because the gateway builds the OTLP endpoint it pushes to clients from this URL.
`tls.cert` / `tls.key`| No| PEM paths if the gateway terminates TLS itself
`trusted_proxies`| No| CIDRs or IPs of load balancers in front of the gateway. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit. Equivalent to nginx `set_real_ip_from`.
@@ -71,7 +71,7 @@
`issuer`| Yes| OIDC discovery base. Must serve discovery at `/.well-known/openid-configuration`. Use HTTPS in production; the gateway accepts an `http://` issuer. A loopback issuer such as `http://localhost:8081` is rejected by the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) unless `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` is set in the gateway’s environment.
`client_id` / `client_secret`| Yes| From your OAuth client registration
`allowed_email_domains`| No| Reject id_tokens whose `email` claim isn’t in one of these domains, case-insensitive. Defense-in-depth against multi-tenant IdP misconfiguration. Independent of this setting, an id_token whose `email_verified` claim is explicitly `false` is always rejected.
-`allowed_groups`| No| Restrict sign-in to members of these IdP groups, matched against `groups_claim`. A user in an allowed email domain but in none of these groups is rejected. Requires the IdP to emit the groups claim.
+`allowed_groups`| No| Restrict sign-in to members of these IdP groups, matched against `groups_claim`. A user in an allowed email domain but in none of these groups is rejected. Requires the IdP to emit the groups claim. Matching is an exact, case-sensitive string comparison against the values in that claim, and the gateway doesn’t expand nested groups: to admit members of a sub-group, list the sub-group here or configure the IdP to emit flattened membership.
`groups_claim`| No| Which id_token claim carries group membership. Default `groups`. Microsoft Entra emits app roles under `roles`. Accepts a flat key or an RFC 6901 JSON Pointer such as `/resource_access/gateway/roles` for nested claims.
`google_groups`| No| Look up the signed-in user’s groups through the Google Workspace Admin SDK Directory API, because Google’s id_token carries no groups claim. Set `service_account_json_path` to a service-account key file with domain-wide delegation on the `https://www.googleapis.com/auth/admin.directory.group.readonly` scope, and `admin_email` to a Workspace administrator the service account impersonates; the Directory API requires a real admin subject. Each user’s group email addresses become their groups claim, so `allowed_groups` and `managed.policies.match.groups` match on group emails.
`email_claim`| No| Which id_token claim carries the user’s email. Default `email`. Some IdPs, such as ADFS and Entra B2C, emit `upn` or `preferred_username` instead. Accepts a flat key, a JSON Pointer, or a list of fallback keys where the first present key is used.
@@ -85,7 +85,7 @@
`additional_authorized_parties`| No| Extra `azp` values to accept beyond `client_id`, for Keycloak broker and token-exchange flows
`discovery_url`| No| Fetch the discovery document from this URL instead of deriving it from `issuer`, for IdPs behind a proxy that rewrites the issuer host. The path must contain `/.well-known/`.
`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
-`ca_cert_pem`| No| PEM CA cert that replaces the system trust store for IdP requests only. Use for Keycloak or Dex behind corporate PKI.
+`ca_cert_pem`| No| The PEM-encoded CA certificate itself, not a path to a file. It replaces the system trust store for IdP requests only. To load a mounted file, write `${file:/etc/gateway/idp-ca.pem}`. Use for Keycloak or Dex behind corporate PKI.
###
@@ -110,7 +110,7 @@
Field| Required| Description
---|---|---
-`postgres_url`| Yes| `postgres://` or `postgresql://` URL. Required: the device-grant rendezvous, where the browser callback writes and the polling CLI reads, needs cross-replica state. The gateway runs its own schema migrations at boot, so the role needs `CREATE TABLE` on the target schema. If your security policy prohibits DDL from the application role, run the migrations with an admin role, initially and again whenever a new release ships migrations, and grant the app role `SELECT, INSERT, UPDATE, DELETE` on the gateway’s tables. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
+`postgres_url`| Yes| `postgres://` or `postgresql://` URL. Required: the device-grant rendezvous, where the browser callback writes and the polling CLI reads, needs cross-replica state. The gateway runs its own schema migrations at boot and on upgrade, so the role needs rights to create and alter tables on the target schema. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
`username`| No| Overrides the user in `postgres_url`
`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
@@ -185,7 +185,7 @@
Setup| How
---|---
IAM permissions| Grant the gateway’s principal `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on both the inference-profile ARNs and the underlying foundation-model ARNs. For the built-in catalog in US regions: `arn:aws:bedrock:<region>:<account>:inference-profile/us.anthropic.*` and `arn:aws:bedrock:*::foundation-model/anthropic.*`.
-Model access| In the Amazon Bedrock console, per region, request and enable model access for the Claude models you want. Cross-region inference profiles (`us.anthropic.*`) require model access in each region the profile spans.
+Model access| Amazon Bedrock enables model access by default in commercial regions. The remaining account-level gate is Anthropic’s one-time use case form: if no one in your AWS account has submitted it, open the Amazon Bedrock console, select an Anthropic model from the Model catalog, and complete the form. See [Submit use case details](</docs/en/amazon-bedrock#1-submit-use-case-details>) for the AWS Organizations form and the permissions the submitter needs.
EKS (IRSA)| Create an IAM role with the policy above and a trust policy for your cluster’s OIDC provider scoped to the gateway’s service account. Annotate the service account with `eks.amazonaws.com/role-arn: arn:aws:iam::<acct>:role/claude-gateway`. `auth: {}` picks it up.
ECS / EC2| Attach the IAM role to the task definition or instance profile. `auth: {}` picks it up.
Anywhere else| Pass credentials via the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` env vars, or set them explicitly in `auth:` with `${VAR}` expansion
@@ -313,9 +313,11 @@
api_key: ${ANTHROPIC_API_KEY}
# Per-upstream model IDs are keyed on the upstream's `name:`; an upstream
- # without a `name:` defaults to its provider string (e.g. `bedrock`). Any
- # upstream not listed for a model is skipped, which is how you route a model
- # to provisioned throughput while everything else stays on-demand.
+ # without a `name:` defaults to its provider string (e.g. `bedrock`). For a
+ # built-in Claude model, an upstream you leave out of the map still serves it
+ # with that provider's default ID; list the upstream to override the ID, for
+ # example with a provisioned-throughput ARN. Only a custom `id` that isn't a
+ # built-in model skips the upstreams missing from its map.
models:
- id: claude-opus-4-8
label: Claude Opus 4.8
@@ -331,7 +333,7 @@
Different accounts| One Amazon Bedrock upstream per account, each with its own credentials in `auth:`. The default chain (`auth: {}`) uses the pod’s identity; for a second account, set explicit credentials or a bearer token.
Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
-Model-scoped routing| Omit an upstream from a model’s `upstream_model:` map and that upstream is skipped for that model. For example, route Opus to provisioned throughput and Sonnet and Haiku to on-demand.
+Model-scoped routing| Only a custom model `id`, one that isn’t a built-in Claude model, skips the upstreams absent from its `upstream_model:` map. The gateway tries built-in models on every upstream in order and uses the provider’s default ID where the map has no entry, so for built-in models the map changes which ID an upstream receives rather than whether it is tried; an upstream that rejects the ID follows the same failover rules as any other upstream error.
Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so failover doesn’t send a body field an upstream would reject.
@@ -384,7 +386,7 @@
Field| Required| Description
---|---|---
-`fail_closed_on_error`| No| Default `false`. Spend enforcement fails open on a Postgres outage, so inference stays up. Set `true` to fail closed: over-cap developers are blocked, but so is everyone else if the store is unreachable. Has no effect without an `admin:` block.
+`fail_closed_on_error`| No| Default `false`. Spend enforcement fails open on a Postgres outage, so inference stays up. Set `true` to fail closed: over-cap developers are blocked, but so is everyone else if the store is unreachable. Requires an `admin:` block: spend enforcement only runs when `admin` is configured, and the gateway refuses to start if you set this `true` without one.
###
@@ -403,6 +405,8 @@
anthropic: claude-opus-4-8
bedrock: us.anthropic.claude-opus-4-8 # or an inference-profile ARN
foundry: your-opus-deployment-name
+
+Each key under `upstream_model` must match the `name` of a configured upstream, which defaults to the provider name. A key that matches no upstream fails boot, so omit the lines for providers you don’t use.
###
@@ -607,7 +611,12 @@
Enable logs and traces only on destinations with the access controls and retention policy that data warrants.
-Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes six env vars to every connected client through `/managed/settings`:
+Each `forward_to` URL must use `https://`, with one exception for a collector on the gateway’s own loopback interface:
+
+ * `http://localhost:<port>` passes config validation, but the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) blocks every export with `ECONNREFUSED_SSRF` unless you set `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` in the gateway’s environment
+ * `http://127.0.0.1:<port>` or `http://[::1]:<port>` fails boot unless that variable is set
+
+For an in-cluster collector, expose it over HTTPS at its own internal address, or run it as a sidecar with the variable set. Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes six env vars to every connected client through `/managed/settings`:
* `CLAUDE_CODE_ENABLE_TELEMETRY=1`
* `OTEL_METRICS_EXPORTER=otlp`
@@ -616,7 +625,7 @@
* `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
* `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`
-The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. Independently of the push, a signed-in CLI that has OTLP/HTTP export enabled sends those exports to the gateway rather than to a locally configured endpoint, and without a `forward_to` destination for a signal the gateway accepts and discards it; if you already collect Claude Code telemetry directly, add your collector as a `forward_to` destination. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
###
@@ -650,8 +659,9 @@
# claude gateway --config gateway.yaml
#
# Operational log verbosity is controlled by the CLAUDE_GATEWAY_LOG_LEVEL
- # environment variable (info | warn | error; default info). It does not
- # affect audit events, which are always emitted.
+ # environment variable (debug | info | warn | error; default info). debug
+ # also logs the claim names in each id_token, for groups_claim diagnosis.
+ # It does not affect audit events, which are always emitted.
listen:
host: 0.0.0.0
@@ -790,7 +800,7 @@
"parentSettingsBehavior": "merge"
}
-`parentSettingsBehavior: "merge"` keeps Claude Desktop’s policy delivery to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform:
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s delivery of the egress allowlist to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform:
Platform| Path
---|---
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -548,7 +548,12 @@
Precedence with other managed sources
-If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
+If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge, with two per-key exceptions while no [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is supplying managed settings, since a helper’s output replaces the managed sources entirely:
+
+ * The `env` block, in Claude Code v2.1.223 or later
+ * The [cross-source lock keys](</docs/en/settings#settings-precedence>)
+
+Both are covered in the list later in this section. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
1. The [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>)
2. Gateway-delivered settings
@@ -568,13 +573,9 @@
* [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
* `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
* [`forceRemoteSettingsRefresh`](</docs/en/server-managed-settings>): blocks startup until remote managed settings are freshly fetched, so an MDM or file policy that sets it is honored even when a cached remote payload that lacks the key is the highest-priority source
-
-Every other key, including `disableBypassPermissionsMode`, comes from the highest-priority source only. Two [parent-settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) checks read every admin source:
-
- * When any admin source sets `allowManagedPermissionRulesOnly`, Claude Code drops parent-supplied permission allow rules and `additionalDirectories`. The key’s effect on the developer’s own rules still follows the highest-priority source.
- * A `forceLoginOrgUUID` or `allowedMcpServers` value in any admin source blocks a parent-supplied one. The value that applies still comes from the highest-priority source.
-
-See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rules on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
+ * `env`: each variable comes from the highest-priority admin source that defines it, and lower admin sources fill in variables the higher sources leave unset. The telemetry unit and credential-paired routing variables follow their own rules; see [Per-key exceptions across managed sources](</docs/en/server-managed-settings#per-key-exceptions-across-managed-sources>). Requires Claude Code v2.1.223 or later
+
+Every other key, including `disableBypassPermissionsMode`, comes from the highest-priority source only. One [parent-settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) check reads every admin source: when any admin source sets `allowManagedPermissionRulesOnly`, Claude Code drops parent-supplied permission allow rules and `additionalDirectories`. The key’s effect on the developer’s own rules still follows the highest-priority source. A `forceLoginOrgUUID` or `allowedMcpServers` value in the highest-priority admin source blocks a parent-supplied one and is the value Claude Code enforces. A value in a non-winning admin source neither applies nor blocks the parent’s. Before v2.1.223, a value in any admin source blocked the parent’s. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rules on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
`mcpServers` inside a policy’s `cli` block is rejected at gateway boot. Per-group MCP distribution is not available; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally.
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -430,7 +430,7 @@
* **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
* **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
-`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends.
+`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends. When a request’s `model` value isn’t a string, the gateway rejects the request with a `400` and the message `model must be a string`, so a malformed value never reaches an upstream. Requires a gateway running Claude Code v2.1.221 or later.
Matcher| Behavior
---|---
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -781,7 +781,7 @@
Client-side managed settings
-Everything above configures the gateway server. Pointing developer machines at it is configured separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
+Everything above configures the gateway server. You point developer machines at the gateway separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
{
"forceLoginMethod": "gateway",
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -493,19 +493,14 @@
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
-Because these settings arrive over the network, the CLI shows each developer a one-time security approval dialog before applying anything that can run a shell command or alter where traffic goes. The dialog covers:
+Because these settings arrive over the network, the CLI shows each developer a one-time security approval dialog before applying the settings listed below:
* `hooks`
- * `env` variables that aren’t on the CLI’s built-in safe list
+ * `env` variables that require the developer’s approval, such as proxy and base-URL variables
* shell-execution settings such as `apiKeyHelper` and `statusLine`
* managed CLAUDE.md content
-The safe list determines which `env` variables apply without approval:
-
- * **On the safe list** : auto-update and model-name vars
- * **Not on the safe list** : proxy vars, base-URL vars, and `OTEL_EXPORTER_OTLP_ENDPOINT`
-
-The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook or non-safe env var to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+Claude Code applies some delivered `env` variables without showing the developer the approval dialog, such as model selection settings and numeric limits. Other delivered variables can require the developer’s approval before they take effect; a non-empty proxy, base-URL, or `OTEL_EXPORTER_OTLP_ENDPOINT` value always does. When a delivered variable needs approval, the dialog names it. [Environment variables and the approval dialog](</docs/en/server-managed-settings#environment-variables-and-the-approval-dialog>) has the details, including four privacy toggles whose delivered value decides whether they need approval. Before v2.1.218, Claude Code applied fewer variables without asking the developer, so more delivered variables triggered the dialog. The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook, or any env var that triggers the dialog, to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
####
@@ -611,15 +606,16 @@
Enable logs and traces only on destinations with the access controls and retention policy that data warrants.
-Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes five env vars to every connected client through `/managed/settings`:
+Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes six env vars to every connected client through `/managed/settings`:
* `CLAUDE_CODE_ENABLE_TELEMETRY=1`
* `OTEL_METRICS_EXPORTER=otlp`
* `OTEL_LOGS_EXPORTER=otlp`
* `OTEL_TRACES_EXPORTER=otlp`
* `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
-
-The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t on the CLI’s safe list, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+ * `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`
+
+The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t among the variables Claude Code applies without the developer’s approval, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
###
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -511,6 +511,46 @@
+Claude Desktop overlay
+
+If your organization also deploys [Claude Desktop](</docs/en/desktop>), the same gateway serves both clients. Point `bootstrapUrl`, in Claude Desktop’s [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>), at `<listen.public_url>/user/bootstrap`. Claude Desktop derives the OAuth issuer from that URL, runs the same device-code sign-in against this gateway, and fetches its configuration from the response.
+
+Requires Claude Code v2.1.203 or later on the gateway server, and an explicit opt-in: `/user/bootstrap` returns 404 unless the policy matching the user carries a `desktop` key. An empty `desktop: {}` opts a policy in, and a `desktop` key on the `match: {}` base layer opts in every policy that inherits it. The audit log records each request as `desktop_bootstrap.serve` or `desktop_bootstrap.denied`.
+
+The gateway derives much of the response from the matched policy’s `cli` block and from top-level gateway config:
+
+ * The model list, from `availableModels`
+ * Disabled tools, from bare tool-name `permissions.deny` entries
+ * The egress allowlist, from `sandbox.network.allowedDomains`
+ * An OTLP endpoint that points at the gateway itself, which fans out to your destinations, included when `telemetry` forwarding is configured
+
+The gateway omits keys with no Claude Desktop equivalent, such as `hooks` and scoped permission rules like `Bash(npm *)`, from the bootstrap response. The optional `desktop` block alongside `cli` holds the Claude Desktop feature gates that have no CLI equivalent:
+
+ managed:
+ policies:
+ - match: { groups: [eng-contractors] }
+ cli:
+ availableModels: [claude-sonnet-4-6]
+ desktop:
+ isLocalDevMcpEnabled: false
+ disableAutoUpdates: true
+ banner: { text: "Contractor build: internal use only" }
+
+Key| Effect
+---|---
+`modelDiscoveryEnabled`| Whether Claude Desktop fetches `/v1/models` for its picker. Set `false` to rely solely on the policy’s model list.
+`coworkTabEnabled`, `isClaudeCodeForDesktopEnabled`| Show or hide individual tabs
+`isDesktopExtensionEnabled`, `isDesktopExtensionSignatureRequired`| Desktop extension loading and signature checks
+`isLocalDevMcpEnabled`| Allow locally defined MCP servers
+`disableAutoUpdates`, `autoUpdaterEnforcementHours`| Auto-update policy
+`banner`| Persistent banner at the top of the app: `enabled`, `text`, `backgroundColor`, `textColor`, `linkUrl`
+
+Every key is optional; Claude Desktop applies its own default for any key you omit. The gateway rejects unknown keys at boot. If you don’t deploy Claude Desktop, leave `desktop` out of your policies entirely; `/user/bootstrap` then returns 404 for every user.
+
+####
+
+
+
Precedence with other managed sources
If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
@@ -521,7 +561,7 @@
4. The `managed-settings.json` file
5. The HKCU registry, on Windows only
-Embedding hosts can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
+Embedding hosts such as [Claude Desktop](</docs/en/desktop>) can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
* On machines with an admin-deployed managed source, it is ignored unless the highest-priority source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>).
* It is never merged while a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is configured.
@@ -761,7 +801,7 @@
Linux and WSL| `/etc/claude-code/managed-settings.json`
Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
-A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. `forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
+A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. For Claude Desktop, set the `bootstrapUrl` key in Claude Desktop’s own [managed configuration](<https://claude.com/docs/third-party/claude-desktop/configuration>) to `<listen.public_url>/user/bootstrap`. The sign-in flow and per-group policy then match the CLI’s once a policy opts in server-side with a `desktop` key; without the opt-in, `/user/bootstrap` returns 404. See Claude Desktop overlay for the server-side half. `forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -521,14 +521,25 @@
4. The `managed-settings.json` file
5. The HKCU registry, on Windows only
-Embedding hosts can supply policy through the SDK `managedSettings` option. It is ignored by default and applies only when a managed source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>), filtered so it can tighten policy but not loosen it. The only exception is the following keys, which are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy:
+Embedding hosts can supply policy through the SDK `managedSettings` option. Whether it applies depends on the machine’s managed configuration:
+
+ * On machines with an admin-deployed managed source, it is ignored unless the highest-priority source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>).
+ * It is never merged while a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is configured.
+ * When merged, it passes through a restrictive-only allowlist. [Restrict parent settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) lists which allow-direction settings still apply without the `allowManaged*Only` locks.
+
+The following keys are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy. When a [`policyHelper`](</docs/en/settings#compute-managed-settings-with-a-policy-helper>) is configured, its output is the only source these checks read:
* `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
* [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
* `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
* [`forceRemoteSettingsRefresh`](</docs/en/server-managed-settings>): blocks startup until remote managed settings are freshly fetched, so an MDM or file policy that sets it is honored even when a cached remote payload that lacks the key is the highest-priority source
-Every other key, including `allowManagedPermissionRulesOnly` and `disableBypassPermissionsMode`, comes from the highest-priority source only. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rule on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
+Every other key, including `disableBypassPermissionsMode`, comes from the highest-priority source only. Two [parent-settings](</docs/en/claude-apps-gateway#restrict-parent-settings>) checks read every admin source:
+
+ * When any admin source sets `allowManagedPermissionRulesOnly`, Claude Code drops parent-supplied permission allow rules and `additionalDirectories`. The key’s effect on the developer’s own rules still follows the highest-priority source.
+ * A `forceLoginOrgUUID` or `allowedMcpServers` value in any admin source blocks a parent-supplied one. The value that applies still comes from the highest-priority source.
+
+See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rules on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
`mcpServers` inside a policy’s `cli` block is rejected at gateway boot. Per-group MCP distribution is not available; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally.
@@ -734,14 +745,15 @@
Client-side managed settings
-Everything above configures the gateway server. Pointing developer machines at it is configured separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push these keys itself, because they’re what tell the client where the gateway is. For the CLI, set both keys in the per-OS `managed-settings.json`:
+Everything above configures the gateway server. Pointing developer machines at it is configured separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push the login keys itself, because they’re what tell the client where the gateway is. For the CLI, set these keys in the per-OS `managed-settings.json`. The two login keys route each developer’s `/login` to your gateway:
{
"forceLoginMethod": "gateway",
- "forceLoginGatewayUrl": "https://claude-gateway.internal.example.com"
+ "forceLoginGatewayUrl": "https://claude-gateway.internal.example.com",
+ "parentSettingsBehavior": "merge"
}
-Deploy that file to each device, typically via your MDM platform. The file path differs by platform:
+`parentSettingsBehavior: "merge"` keeps Claude Desktop’s policy delivery to its embedded Claude Code sessions working; [Deliver policy to Claude Desktop sessions](</docs/en/claude-apps-gateway#deliver-policy-to-claude-desktop-sessions>) explains the mechanism and where the opt-in must sit. Deploy the `managed-settings.json` file to each device, typically via your MDM platform. The file path differs by platform:
Platform| Path
---|---
@@ -749,7 +761,7 @@
Linux and WSL| `/etc/claude-code/managed-settings.json`
Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
-`forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
+A registry policy on Windows or a managed-preferences plist on macOS replaces the `managed-settings.json` file rather than merging with it, apart from the exception keys and cross-source checks above. All three keys in this snippet follow the highest-priority-source rule, so fleets that deliver policy through Group Policy or configuration profiles must put all three in that mechanism instead. `forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
##
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -488,7 +488,7 @@
---|---|---
`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
-`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that auto-approves every tool call, and the `--dangerously-skip-permissions` flag
+`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that skips permission prompts, and the `--dangerously-skip-permissions` flag
`allowManagedPermissionRulesOnly`| CLI| When `true`, user and project permission rules are ignored; only rules from this document apply
`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -180,7 +180,7 @@
# Override the bedrock-runtime endpoint for FIPS or VPC-endpoint deployments:
# base_url: https://bedrock-runtime-fips.us-east-1.amazonaws.com
-An empty `auth` block uses the AWS SDK’s default credential chain: env vars, `~/.aws/credentials`, ECS task role, EC2 instance metadata, or IRSA on EKS. In production, give the gateway pod an IAM role instead of embedding static keys in a container image.
+An empty `auth` block uses the AWS SDK’s default credential chain: env vars, `~/.aws/credentials`, ECS task role, EC2 instance metadata, or IRSA on EKS. In production, give the gateway pod an IAM role instead of embedding static keys in a container image. Explicit credentials must be complete: the gateway fails at boot when `aws_access_key_id` and `aws_secret_access_key` aren’t set together, or when `aws_session_token` is set without them. Before v2.1.207, a partial `auth:` block passed validation.
Setup| How
---|---
@@ -505,7 +505,7 @@
* **On the safe list** : auto-update and model-name vars
* **Not on the safe list** : proxy vars, base-URL vars, and `OTEL_EXPORTER_OTLP_ENDPOINT`
-The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. Non-interactive runs with the `-p` flag skip the dialog and apply settings without approval. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer, so the `-p` skip is intentional rather than a gap. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook or non-safe env var to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer. A non-interactive run with the `-p` flag can’t show the dialog. It applies the pushed settings for that run only and doesn’t record them as approved, so the developer’s next interactive session still shows the dialog. Before v2.1.207, a non-interactive run saved the settings as approved and no later interactive session showed the dialog for them. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook or non-safe env var to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
####
Show diff (106 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -12,7 +12,7 @@
* `oidc`: your identity provider (IdP), including issuer, client, claim mapping, and who may sign in
* `session`: the bearer tokens the gateway mints, with secret and lifetime
* `store`: PostgreSQL, for device grants and rate-limit counters
- * `upstreams`: where inference goes, whether Anthropic, Bedrock, Claude Platform on AWS, Agent Platform, or Foundry
+ * `upstreams`: where inference goes, whether Anthropic, Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, or Microsoft Foundry
**Optional sections:**
@@ -123,7 +123,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream, and a `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Bedrock, Claude Platform on AWS, Agent Platform, and Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream, and a `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, and Microsoft Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
@@ -163,7 +163,7 @@
Amazon Bedrock
-For the client-side Bedrock deployment that the gateway replaces or fronts, see [Claude Code on Amazon Bedrock](</docs/en/amazon-bedrock>). The gateway-side upstream:
+For the client-side Amazon Bedrock deployment that the gateway replaces or fronts, see [Claude Code on Amazon Bedrock](</docs/en/amazon-bedrock>). The gateway-side upstream:
upstreams:
- provider: bedrock
@@ -185,7 +185,7 @@
Setup| How
---|---
IAM permissions| Grant the gateway’s principal `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on both the inference-profile ARNs and the underlying foundation-model ARNs. For the built-in catalog in US regions: `arn:aws:bedrock:<region>:<account>:inference-profile/us.anthropic.*` and `arn:aws:bedrock:*::foundation-model/anthropic.*`.
-Model access| In the Bedrock console, per region, request and enable model access for the Claude models you want. Cross-region inference profiles (`us.anthropic.*`) require model access in each region the profile spans.
+Model access| In the Amazon Bedrock console, per region, request and enable model access for the Claude models you want. Cross-region inference profiles (`us.anthropic.*`) require model access in each region the profile spans.
EKS (IRSA)| Create an IAM role with the policy above and a trust policy for your cluster’s OIDC provider scoped to the gateway’s service account. Annotate the service account with `eks.amazonaws.com/role-arn: arn:aws:iam::<acct>:role/claude-gateway`. `auth: {}` picks it up.
ECS / EC2| Attach the IAM role to the task definition or instance profile. `auth: {}` picks it up.
Anywhere else| Pass credentials via the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` env vars, or set them explicitly in `auth:` with `${VAR}` expansion
@@ -244,11 +244,11 @@
# Override the aiplatform endpoint for Private Service Connect:
# base_url: https://us-east5-aiplatform.p.googleapis.com
-An empty `auth` block uses Application Default Credentials: `GOOGLE_APPLICATION_CREDENTIALS`, GCE metadata, or GKE Workload Identity. Service-account JSON key files are supported but discouraged; use Workload Identity or attach a service account to the GCE or Cloud Run instance. Set `region: global` to use [Agent Platform’s global endpoint](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>) instead of a regional one. Google then routes each request to an available region, so you don’t track per-region model availability. Setting a specific region pins every request to it.
+An empty `auth` block uses Application Default Credentials: `GOOGLE_APPLICATION_CREDENTIALS`, GCE metadata, or GKE Workload Identity. Service-account JSON key files are supported but discouraged; use Workload Identity or attach a service account to the GCE or Cloud Run instance. Set `region: global` to use the [global endpoint for Google Cloud’s Agent Platform](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>) instead of a regional one. Google then routes each request to an available region, so you don’t track per-region model availability. Setting a specific region pins every request to it.
Setup| How
---|---
-IAM permissions| Grant the gateway’s service account `roles/aiplatform.user` on the project, or a custom role with `aiplatform.endpoints.predict`. Enable the Agent Platform API (`aiplatform.googleapis.com`).
+IAM permissions| Grant the gateway’s service account `roles/aiplatform.user` on the project, or a custom role with `aiplatform.endpoints.predict`. Enable Google Cloud’s Agent Platform API (`aiplatform.googleapis.com`).
Model access| In Model Garden, enable the Claude models for your project. They publish to specific regions; check the model card for supported regions.
GKE (Workload Identity)| Bind a GCP service account to the gateway’s Kubernetes service account and annotate the KSA with `iam.gke.io/gcp-service-account: claude-gateway@<proj>.iam.gserviceaccount.com`. `auth: {}` picks it up.
Cloud Run / GCE| Set the service’s service account to one with `roles/aiplatform.user`. `auth: {}` picks it up.
@@ -260,7 +260,7 @@
Microsoft Foundry
-For the client-side Foundry deployment, see [Claude Code on Microsoft Foundry](</docs/en/microsoft-foundry>). The gateway-side upstream:
+For the client-side Microsoft Foundry deployment, see [Claude Code on Microsoft Foundry](</docs/en/microsoft-foundry>). The gateway-side upstream:
upstreams:
- provider: foundry
@@ -270,12 +270,12 @@
# auth:
# api_key: ${FOUNDRY_API_KEY}
-`use_azure_ad: true` resolves through `DefaultAzureCredential`: Managed Identity on AKS, ACI, or App Service; the Azure CLI; or environment credentials. API keys work but are project-wide and don’t rotate automatically. Foundry’s endpoint is derived from `resource:`; set the optional `base_url` to override it for sovereign clouds such as Azure Government.
+`use_azure_ad: true` resolves through `DefaultAzureCredential`: Managed Identity on AKS, ACI, or App Service; the Azure CLI; or environment credentials. API keys work but are project-wide and don’t rotate automatically. Microsoft Foundry’s endpoint is derived from `resource:`; set the optional `base_url` to override it for sovereign clouds such as Azure Government.
Setup| How
---|---
-RBAC| Grant the gateway’s identity `Azure AI User` or `Cognitive Services User` on the Foundry resource
-Deployments| Foundry uses admin-chosen deployment names, not canonical model IDs. Add a `models:` block mapping each canonical ID to your deployment name.
+RBAC| Grant the gateway’s identity `Azure AI User` or `Cognitive Services User` on the Microsoft Foundry resource
+Deployments| Microsoft Foundry uses admin-chosen deployment names, not canonical model IDs. Add a `models:` block mapping each canonical ID to your deployment name.
AKS (workload identity)| Federate a User-Assigned Managed Identity with the cluster’s OIDC issuer and bind it to the gateway’s service account. `use_azure_ad: true` picks it up via `WorkloadIdentityCredential`.
ACI / App Service| Enable system-assigned or user-assigned managed identity on the resource. `use_azure_ad: true` picks it up.
Anywhere else| `auth: { api_key: "${FOUNDRY_API_KEY}" }`. Quote `${…}` inside `{ }`.
@@ -286,7 +286,7 @@
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Amazon Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
upstreams:
# Primary: provisioned throughput in your home region.
@@ -327,8 +327,8 @@
Lever| How
---|---
-Different regions| One Bedrock upstream per region, each with its own `region:`. With `auto_include_builtin_models: true` the cross-region inference profiles route automatically; for region-pinned deployments use a `models:` block.
-Different accounts| One Bedrock upstream per account, each with its own credentials in `auth:`. The default chain (`auth: {}`) uses the pod’s identity; for a second account, set explicit credentials or a bearer token.
+Different regions| One Amazon Bedrock upstream per region, each with its own `region:`. With `auto_include_builtin_models: true` the cross-region inference profiles route automatically; for region-pinned deployments use a `models:` block.
+Different accounts| One Amazon Bedrock upstream per account, each with its own credentials in `auth:`. The default chain (`auth: {}`) uses the pod’s identity; for a second account, set explicit credentials or a bearer token.
Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
Model-scoped routing| Omit an upstream from a model’s `upstream_model:` map and that upstream is skipped for that model. For example, route Opus to provisioned throughput and Sonnet and Haiku to on-demand.
@@ -392,7 +392,7 @@
`models`
-The `models` block is an optional admin-curated model list, served at `/v1/models` and used to translate model IDs per upstream. It is required for non-US Bedrock regions, Bedrock provisioned-throughput ARNs, and Foundry deployment names.
+The `models` block is an optional admin-curated model list, served at `/v1/models` and used to translate model IDs per upstream. It is required for non-US Amazon Bedrock regions, Amazon Bedrock provisioned-throughput ARNs, and Microsoft Foundry deployment names.
auto_include_builtin_models: true # false: expose only the list below
models:
Show diff (124 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -1,4 +1,4 @@
-A Claude apps gateway deployment is configured by one YAML file, conventionally `gateway.yaml`. The file defines everything the gateway does: where it listens, how developers sign in, where inference goes, and which policies and telemetry apply. This page is the reference for every option in that file. To write your first one, start from the [quickstart](</docs/en/claude-apps-gateway#quickstart>), which builds a minimal working config and runs it; once you have a config you’re happy with, the [deployment guide](</docs/en/claude-apps-gateway-deploy>) covers containerizing and hosting it on Kubernetes, Cloud Run, or your own platform. The gateway reads the file once, at startup, with `claude gateway --config /path/to/gateway.yaml`. Every option is validated against a schema at boot, so a malformed config fails at start with a field-level error rather than at first use. The complete example at the end of this page exercises every section.
+A Claude apps gateway deployment is configured by one YAML file, conventionally `gateway.yaml`. The file defines everything the gateway does: where it listens, how developers sign in, where inference goes, and which policies and telemetry apply. This page is the reference for every option in that file. To write your first one, start from the [quickstart](</docs/en/claude-apps-gateway#quickstart>), which builds a minimal working config and runs it. Once you have a config you’re happy with, the [deployment guide](</docs/en/claude-apps-gateway-deploy>) covers containerizing and hosting it on Kubernetes, Cloud Run, or your own platform. The gateway reads the file once, at startup, with `claude gateway --config /path/to/gateway.yaml`. Every option is validated against a schema at boot, so a malformed config fails at start with a field-level error rather than at first use. The complete example at the end of this page exercises every section.
##
@@ -12,7 +12,7 @@
* `oidc`: your identity provider (IdP), including issuer, client, claim mapping, and who may sign in
* `session`: the bearer tokens the gateway mints, with secret and lifetime
* `store`: PostgreSQL, for device grants and rate-limit counters
- * `upstreams`: where inference goes, whether Anthropic, Bedrock, Agent Platform, or Foundry
+ * `upstreams`: where inference goes, whether Anthropic, Bedrock, Claude Platform on AWS, Agent Platform, or Foundry
**Optional sections:**
@@ -64,7 +64,7 @@
`oidc`
-OpenID Connect (OIDC) is the SSO protocol the gateway uses with your identity provider; see [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for what to register on the IdP side. The `oidc` block connects the gateway to your identity provider and decides who can sign in. It names the issuer and OAuth client, maps the claims that carry email and groups, and restricts sign-in by email domain or group.
+The `oidc` block connects the gateway to your identity provider and decides who can sign in. It names the issuer and OAuth client, maps the claims that carry email and groups, and restricts sign-in by email domain or group. OpenID Connect (OIDC) is the SSO protocol the gateway uses with your identity provider; see [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for what to register on the IdP side.
Field| Required| Description
---|---|---
@@ -123,7 +123,7 @@
`upstreams`
-`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. Multiple upstreams of the same provider must set a distinct `name:`. Bedrock, Agent Platform, and Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, `401`, `403`, `404`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. A `401` or `403` means the gateway’s own credential failed against that upstream, and a `404` means that upstream doesn’t serve the requested model, so a later upstream in the list still can. Failover on `404` requires gateway v2.1.198 or later. Earlier releases returned the first `404` to the client even when a later upstream in the list served the model. Multiple upstreams of the same provider must set a distinct `name:`. Bedrock, Claude Platform on AWS, Agent Platform, and Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
####
@@ -195,6 +195,41 @@
+Claude Platform on AWS
+
+Claude Platform on AWS serves the first-party Anthropic API on AWS infrastructure at `aws-external-anthropic.<region>.api.aws`. It uses first-party model IDs, honors `anthropic-beta` headers as sent, and serves `count_tokens`, so none of the Bedrock-specific translation applies. The `anthropicAws` provider requires Claude Code v2.1.198 or later; earlier gateway releases reject it at boot. For the client-side deployment of the same platform, see [Claude Code on Claude Platform on AWS](</docs/en/claude-platform-on-aws>). The gateway-side upstream:
+
+ upstreams:
+ - provider: anthropicAws
+ region: us-east-1
+ workspace_id: wrkspc_...
+ auth:
+ api_key: ${ANTHROPIC_AWS_API_KEY} # sent as x-api-key
+ # OR SigV4 via the AWS default credential chain:
+ # auth: {}
+ # OR explicit SigV4 credentials:
+ # auth:
+ # aws_access_key_id: ${AWS_ACCESS_KEY_ID}
+ # aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
+ # Override the derived endpoint:
+ # base_url: https://aws-external-anthropic.us-east-1.api.aws
+
+The platform runs in a separate AWS account from Amazon Bedrock and signs SigV4 requests for its own service name, `aws-external-anthropic`, so a Bedrock-scoped IAM role doesn’t authorize it. An API key in `auth.api_key` takes precedence when SigV4 credentials are also set. An empty `auth` block uses the AWS SDK’s default credential chain, the same chain the Amazon Bedrock upstream uses.
+
+Field| Required| Description
+---|---|---
+`region`| Yes| AWS region, lowercase letters, digits, and hyphens. The gateway derives the endpoint from it as `https://aws-external-anthropic.<region>.api.aws`.
+`workspace_id`| Yes| Sent as a header on every request; the platform requires it
+`auth.api_key`| No| API key for the platform, sent as `x-api-key`. Not a bearer token: the two auth modes are an API key or SigV4.
+`auth.aws_access_key_id` / `auth.aws_secret_access_key`| No| Explicit SigV4 credentials. Setting one without the other fails at boot. `auth.aws_session_token` is accepted alongside them.
+`base_url`| No| Override the derived endpoint
+
+Because the platform resolves first-party model IDs, the built-in catalog routes to it with no `models:` block. When you curate a `models:` list, key the entry `anthropicAws:` with the first-party ID.
+
+####
+
+
+
Google Cloud Agent Platform
For the equivalent client-side setup, see [Claude Code on Google Cloud](</docs/en/google-vertex-ai>). The gateway-side upstream:
@@ -251,7 +286,7 @@
Multiple upstreams
-The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, `401`, `403`, `404`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. `404` is per-upstream model availability, so an upstream that hasn’t enabled a model doesn’t block a later upstream that serves it. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
upstreams:
# Primary: provisioned throughput in your home region.
@@ -491,6 +526,7 @@
* `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
* [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
* `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
+ * [`forceRemoteSettingsRefresh`](</docs/en/server-managed-settings>): blocks startup until remote managed settings are freshly fetched, so an MDM or file policy that sets it is honored even when a cached remote payload that lacks the key is the highest-priority source
Every other key, including `allowManagedPermissionRulesOnly` and `disableBypassPermissionsMode`, comes from the highest-priority source only. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rule on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
@@ -548,7 +584,7 @@
`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
`limits`| `max_request_header_bytes`| unset| When set, oversize headers return `431`
`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
-`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; Bedrock, Agent Platform, and Foundry are bounded by their provider SDK’s own timeout.
+`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; every other provider is bounded by its provider SDK’s own timeout.
`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`
@@ -633,6 +669,12 @@
# region: us-east-1
# auth: {}
+ # - provider: anthropicAws
+ # region: us-east-1
+ # workspace_id: wrkspc_...
+ # auth:
+ # api_key: ${ANTHROPIC_AWS_API_KEY}
+
# - provider: vertex
# region: us-east5
# project_id: example-prod
@@ -649,6 +691,7 @@
upstream_model:
anthropic: claude-opus-4-8
# bedrock: us.anthropic.claude-opus-4-8
+ # anthropicAws: claude-opus-4-8
# vertex: claude-opus-4-8
# foundry: <your-opus-deployment-name>
- id: claude-sonnet-4-6
Show diff (722 lines)
--- a/claude-apps-gateway-config.md
+++ b/claude-apps-gateway-config.md
@@ -0,0 +1,719 @@
+A Claude apps gateway deployment is configured by one YAML file, conventionally `gateway.yaml`. The file defines everything the gateway does: where it listens, how developers sign in, where inference goes, and which policies and telemetry apply. This page is the reference for every option in that file. To write your first one, start from the [quickstart](</docs/en/claude-apps-gateway#quickstart>), which builds a minimal working config and runs it; once you have a config you’re happy with, the [deployment guide](</docs/en/claude-apps-gateway-deploy>) covers containerizing and hosting it on Kubernetes, Cloud Run, or your own platform. The gateway reads the file once, at startup, with `claude gateway --config /path/to/gateway.yaml`. Every option is validated against a schema at boot, so a malformed config fails at start with a field-level error rather than at first use. The complete example at the end of this page exercises every section.
+
+##
+
+
+
+File structure
+
+Five sections are required. Every other section is optional, and an omitted section takes its defaults. Unknown keys fail boot, so a typo surfaces as a named error rather than a silently ignored setting. **Required sections:**
+
+ * `listen`: bind address, public URL, TLS termination
+ * `oidc`: your identity provider (IdP), including issuer, client, claim mapping, and who may sign in
+ * `session`: the bearer tokens the gateway mints, with secret and lifetime
+ * `store`: PostgreSQL, for device grants and rate-limit counters
+ * `upstreams`: where inference goes, whether Anthropic, Bedrock, Agent Platform, or Foundry
+
+**Optional sections:**
+
+ * `admin`: Admin API auth and retention for spend limits
+ * `enforcement`: spend-limit fail-open or fail-closed behavior
+ * `models` and `auto_include_builtin_models`: admin-curated model list and per-upstream IDs
+ * `managed`: managed settings policies by IdP group
+ * `telemetry`: OTLP forwarding to your observability stack
+ * `access_control`, `limits`, `timeouts`, `rate_limits`: IP allow/deny, request size caps, upstream time-to-first-byte, and per-IP sign-in limits
+
+##
+
+
+
+Secret expansion
+
+Don’t write secrets such as `client_secret`, `jwt_secret`, or `postgres_url` directly in `gateway.yaml`. Reference them with one of the forms below, and the gateway resolves the value at boot from an environment variable or a file:
+
+Form| Resolves to| Use for
+---|---|---
+`${VAR}`| The environment variable `VAR`. Boot fails if undefined.| Container environment variables, AWS Secrets Manager via env injection
+`${file:/path}`| File contents, trimmed| Kubernetes Secret volume mounts, Vault Agent, SOPS
+
+##
+
+
+
+Required sections
+
+###
+
+
+
+`listen`
+
+The `listen` block controls where the gateway serves: the bind address and port, the externally visible origin, and optional TLS termination.
+
+Field| Required| Description
+---|---|---
+`host`| No| Bind address. Default `0.0.0.0`.
+`port`| No| Bind port. Default `8080`.
+`public_url`| Behind a proxy| The externally visible `https://` origin, used to build the IdP `redirect_uri` and discovery metadata. Required behind any TLS-terminating proxy such as an ALB, Ingress, or Cloud Run, because the gateway doesn’t trust `X-Forwarded-*` headers when constructing its own origin; they are client-spoofable. `trusted_proxies` below governs client-IP resolution only. Also required to enable telemetry, because the gateway builds the OTLP endpoint it pushes to clients from this URL.
+`tls.cert` / `tls.key`| No| PEM paths if the gateway terminates TLS itself
+`trusted_proxies`| No| CIDRs or IPs of load balancers in front of the gateway. When set, the gateway trusts `X-Forwarded-For` only from these peers and records the real client IP for per-IP rate limiting and audit. Equivalent to nginx `set_real_ip_from`.
+
+###
+
+
+
+`oidc`
+
+OpenID Connect (OIDC) is the SSO protocol the gateway uses with your identity provider; see [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for what to register on the IdP side. The `oidc` block connects the gateway to your identity provider and decides who can sign in. It names the issuer and OAuth client, maps the claims that carry email and groups, and restricts sign-in by email domain or group.
+
+Field| Required| Description
+---|---|---
+`issuer`| Yes| OIDC discovery base. Must serve discovery at `/.well-known/openid-configuration`. Use HTTPS in production; the gateway accepts an `http://` issuer. A loopback issuer such as `http://localhost:8081` is rejected by the [SSRF guard](</docs/en/claude-apps-gateway-deploy#threat-model-summary>) unless `CLAUDE_GATEWAY_ALLOW_LOOPBACK=1` is set in the gateway’s environment.
+`client_id` / `client_secret`| Yes| From your OAuth client registration
+`allowed_email_domains`| No| Reject id_tokens whose `email` claim isn’t in one of these domains, case-insensitive. Defense-in-depth against multi-tenant IdP misconfiguration. Independent of this setting, an id_token whose `email_verified` claim is explicitly `false` is always rejected.
+`allowed_groups`| No| Restrict sign-in to members of these IdP groups, matched against `groups_claim`. A user in an allowed email domain but in none of these groups is rejected. Requires the IdP to emit the groups claim.
+`groups_claim`| No| Which id_token claim carries group membership. Default `groups`. Microsoft Entra emits app roles under `roles`. Accepts a flat key or an RFC 6901 JSON Pointer such as `/resource_access/gateway/roles` for nested claims.
+`google_groups`| No| Look up the signed-in user’s groups through the Google Workspace Admin SDK Directory API, because Google’s id_token carries no groups claim. Set `service_account_json_path` to a service-account key file with domain-wide delegation on the `https://www.googleapis.com/auth/admin.directory.group.readonly` scope, and `admin_email` to a Workspace administrator the service account impersonates; the Directory API requires a real admin subject. Each user’s group email addresses become their groups claim, so `allowed_groups` and `managed.policies.match.groups` match on group emails.
+`email_claim`| No| Which id_token claim carries the user’s email. Default `email`. Some IdPs, such as ADFS and Entra B2C, emit `upn` or `preferred_username` instead. Accepts a flat key, a JSON Pointer, or a list of fallback keys where the first present key is used.
+`scopes`| No| Full override of the OIDC scopes the gateway requests. Default `[openid, profile, email, offline_access]`. Set when your IdP rejects scopes it doesn’t recognize, or requires a custom scope to emit groups or email. Must include `openid`. Dropping `offline_access` disables refresh tokens, so developers re-run the browser login every `session.ttl_hours`. See [Identity provider setup](</docs/en/claude-apps-gateway-deploy#identity-provider-setup>) for per-IdP scope recipes such as Google’s refresh-token flow.
+`extra_auth_params`| No| Extra query parameters appended to the IdP authorization request, verbatim. This is the override mechanism for IdP-specific behavior, such as `access_type: offline` for Google refresh tokens, `domain_hint` for some Entra tenants, or `acr_values` for step-up flows. Cannot override the gateway-managed protocol params: `state`, `nonce`, `redirect_uri`, PKCE, `scope`, `response_type`, `response_mode`, and `client_id`.
+`userinfo_fallback`| No| When the id_token omits email or groups, fetch them from `/userinfo`. Needed for Keycloak lightweight access tokens, the Okta org server, and ADFS minimal tokens. The id_token stays authoritative; userinfo only fills gaps. Default `false`.
+`use_pkce`| No| Send a PKCE (S256) challenge on the authorization request. Default `true`. Set `false` only if your IdP rejects PKCE for this confidential client.
+`clock_skew_seconds`| No| Tolerate clock drift when validating id_token time claims. Default `0`, which is strict. Raise if you see “token expired / not yet valid” errors right after sign-in due to host/IdP clock skew.
+`token_endpoint_auth_method`| No| Override the token-endpoint auth method. Accepts `client_secret_basic` or `client_secret_post`. Auto-negotiated by default.
+`id_token_signed_response_alg`| No| Expected id_token signing algorithm. Default `RS256`. Set for IdPs that sign with ES256, PS256, or EdDSA.
+`additional_authorized_parties`| No| Extra `azp` values to accept beyond `client_id`, for Keycloak broker and token-exchange flows
+`discovery_url`| No| Fetch the discovery document from this URL instead of deriving it from `issuer`, for IdPs behind a proxy that rewrites the issuer host. The path must contain `/.well-known/`.
+`form_action_origins`| No| Additional origins for the `/device` page’s `Content-Security-Policy: form-action` directive. The gateway already allows `'self'` and the discovered `authorization_endpoint` origin, but Chrome enforces `form-action` against the entire redirect chain. If your IdP redirects through a second host, such as Azure AD federated to ADFS, hub-spoke Okta, or a corporate SSO interceptor, list every origin the authorization request may redirect through.
+`ca_cert_pem`| No| PEM CA cert that replaces the system trust store for IdP requests only. Use for Keycloak or Dex behind corporate PKI.
+
+###
+
+
+
+`session`
+
+The `session` block shapes the bearer tokens the gateway mints after sign-in: the secret that signs them and how long they live.
+
+Field| Required| Description
+---|---|---
+`jwt_secret`| Yes| At least 32 bytes of entropy, for example from `openssl rand -base64 32`. Signs the gateway’s HS256 bearer tokens. Accepts a single string or an array for rotation: index 0 signs and all entries verify. To rotate, prepend a new secret, wait `ttl_hours`, then drop the old one.
+`ttl_hours`| No| Gateway bearer token lifetime. Default `1`. The CLI silently refreshes before expiry when the IdP issues refresh tokens. A shorter lifetime deprovisions faster; a longer one makes fewer IdP round-trips. If your IdP can’t issue refresh tokens because `offline_access` is unavailable, there is no silent refresh, so raise this to `8` or `12` to avoid sending developers back to the browser login every hour.
+
+###
+
+
+
+`store`
+
+The `store` block points the gateway at its PostgreSQL database, which holds device grants and rate-limit counters.
+
+Field| Required| Description
+---|---|---
+`postgres_url`| Yes| `postgres://` or `postgresql://` URL. Required: the device-grant rendezvous, where the browser callback writes and the polling CLI reads, needs cross-replica state. The gateway runs its own schema migrations at boot, so the role needs `CREATE TABLE` on the target schema. If your security policy prohibits DDL from the application role, run the migrations with an admin role, initially and again whenever a new release ships migrations, and grant the app role `SELECT, INSERT, UPDATE, DELETE` on the gateway’s tables. See [Upgrades](</docs/en/claude-apps-gateway-deploy#upgrades>) and [Postgres](</docs/en/claude-apps-gateway-deploy#postgres>).
+`username`| No| Overrides the user in `postgres_url`
+`password`| No| Database credential. Set it here rather than in `postgres_url` so the credential stays out of the URL. Accepts any characters and takes precedence over URL credentials.
+`max_connections`| No| Postgres connection-pool size per replica. Default `5`, which is conservative and friendly to shared databases. With spend limits enabled, the hot path does a few operations per inference request, so raise it for a dedicated database under load, and keep replicas × this below the database’s `max_connections`.
+
+For local development, point `postgres_url` at a throwaway Postgres container, for example `docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres`.
+
+###
+
+
+
+`upstreams`
+
+`upstreams` is an ordered list. The gateway forwards inference to the first upstream that resolves the requested model. On `5xx`, `429`, or timeout it fails over to the next; other `4xx` doesn’t, because those errors are attributable to the request rather than the upstream. Multiple upstreams of the same provider must set a distinct `name:`. Bedrock, Agent Platform, and Foundry clients are built once at startup, and their SDKs refresh credentials internally, so rotating cloud credentials doesn’t require a restart. Static Anthropic API keys and bearers are read at startup; see Anthropic API.
+
+####
+
+
+
+Anthropic API
+
+The minimal Anthropic upstream is an API key from the [Claude Console](<https://platform.claude.com>):
+
+ upstreams:
+ - provider: anthropic
+ auth:
+ api_key: ${ANTHROPIC_API_KEY}
+ # OR an OAuth bearer (e.g. a Workload-Identity-Federation-exchanged token):
+ # oauth_token: ${file:/var/run/secrets/anthropic-oauth-token}
+ # base_url: https://api.anthropic.com # default; override for a forward proxy
+
+The two credential forms differ in the header they send:
+
+ * **`api_key`** : sends `x-api-key`. Rotate it in the Claude Console and update the env var.
+ * **`oauth_token`** : sends `Authorization: Bearer`. Use the bearer form when your org issues short-lived tokens instead of long-lived API keys. The bearer is read once at startup, so refresh by remounting the secret and restarting.
+
+Instead of a static key or bearer, you can use Workload Identity Federation. Create a federation rule by following the [Workload Identity Federation guide](<https://platform.claude.com/docs/en/manage-claude/workload-identity-federation>), then mount your workload’s OIDC JWT as a file, such as a Kubernetes projected service-account token or a CI platform’s id-token. The gateway exchanges the JWT for a short-lived bearer and refreshes it automatically. The token file is re-read on every exchange, so rotated projected tokens are picked up without a restart.
+
+ upstreams:
+ - provider: anthropic
+ auth:
+ federation_rule_id: ${ANTHROPIC_FEDERATION_RULE_ID}
+ organization_id: ${ANTHROPIC_ORGANIZATION_ID}
+ identity_token_file: /var/run/secrets/anthropic/id-token
+ # workspace_id: wrkspc_... # required if the rule covers >1 workspace
+ # service_account_id: svac_... # optional expected-target check
+
+####
+
+
+
+Amazon Bedrock
+
+For the client-side Bedrock deployment that the gateway replaces or fronts, see [Claude Code on Amazon Bedrock](</docs/en/amazon-bedrock>). The gateway-side upstream:
+
+ upstreams:
+ - provider: bedrock
+ region: us-east-1
+ auth: {} # preferred: AWS default credential chain
+ # OR explicit credentials:
+ # auth:
+ # aws_access_key_id: ${AWS_AKID}
+ # aws_secret_access_key: ${AWS_SK}
+ # aws_session_token: ${AWS_ST}
+ # OR a Bedrock API bearer token:
+ # auth:
+ # aws_bearer_token: ${AWS_BEARER_TOKEN}
+ # Override the bedrock-runtime endpoint for FIPS or VPC-endpoint deployments:
+ # base_url: https://bedrock-runtime-fips.us-east-1.amazonaws.com
+
+An empty `auth` block uses the AWS SDK’s default credential chain: env vars, `~/.aws/credentials`, ECS task role, EC2 instance metadata, or IRSA on EKS. In production, give the gateway pod an IAM role instead of embedding static keys in a container image.
+
+Setup| How
+---|---
+IAM permissions| Grant the gateway’s principal `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on both the inference-profile ARNs and the underlying foundation-model ARNs. For the built-in catalog in US regions: `arn:aws:bedrock:<region>:<account>:inference-profile/us.anthropic.*` and `arn:aws:bedrock:*::foundation-model/anthropic.*`.
+Model access| In the Bedrock console, per region, request and enable model access for the Claude models you want. Cross-region inference profiles (`us.anthropic.*`) require model access in each region the profile spans.
+EKS (IRSA)| Create an IAM role with the policy above and a trust policy for your cluster’s OIDC provider scoped to the gateway’s service account. Annotate the service account with `eks.amazonaws.com/role-arn: arn:aws:iam::<acct>:role/claude-gateway`. `auth: {}` picks it up.
+ECS / EC2| Attach the IAM role to the task definition or instance profile. `auth: {}` picks it up.
+Anywhere else| Pass credentials via the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` env vars, or set them explicitly in `auth:` with `${VAR}` expansion
+Region| `region:` is the API endpoint region. Cross-region inference profiles route across the geo (US, EU, APAC) regardless of which one you pick. For non-US regions or provisioned-throughput ARNs, add a `models:` block with the right per-upstream IDs.
+
+####
+
+
+
+Google Cloud Agent Platform
+
+For the equivalent client-side setup, see [Claude Code on Google Cloud](</docs/en/google-vertex-ai>). The gateway-side upstream:
+
+ upstreams:
+ - provider: vertex
+ region: us-east5
+ project_id: example-prod
+ auth: {} # preferred: Application Default Credentials
+ # OR a service account key file:
+ # auth: { service_account_json: /secrets/sa.json }
+ # Override the aiplatform endpoint for Private Service Connect:
+ # base_url: https://us-east5-aiplatform.p.googleapis.com
+
+An empty `auth` block uses Application Default Credentials: `GOOGLE_APPLICATION_CREDENTIALS`, GCE metadata, or GKE Workload Identity. Service-account JSON key files are supported but discouraged; use Workload Identity or attach a service account to the GCE or Cloud Run instance. Set `region: global` to use [Agent Platform’s global endpoint](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations>) instead of a regional one. Google then routes each request to an available region, so you don’t track per-region model availability. Setting a specific region pins every request to it.
+
+Setup| How
+---|---
+IAM permissions| Grant the gateway’s service account `roles/aiplatform.user` on the project, or a custom role with `aiplatform.endpoints.predict`. Enable the Agent Platform API (`aiplatform.googleapis.com`).
+Model access| In Model Garden, enable the Claude models for your project. They publish to specific regions; check the model card for supported regions.
+GKE (Workload Identity)| Bind a GCP service account to the gateway’s Kubernetes service account and annotate the KSA with `iam.gke.io/gcp-service-account: claude-gateway@<proj>.iam.gserviceaccount.com`. `auth: {}` picks it up.
+Cloud Run / GCE| Set the service’s service account to one with `roles/aiplatform.user`. `auth: {}` picks it up.
+Anywhere else| `auth: { service_account_json: /secrets/sa.json }`, the path to a JSON key file mounted as a secret. The field takes a file path, not the key contents, so no `${file:…}` expansion is involved.
+
+####
+
+
+
+Microsoft Foundry
+
+For the client-side Foundry deployment, see [Claude Code on Microsoft Foundry](</docs/en/microsoft-foundry>). The gateway-side upstream:
+
+ upstreams:
+ - provider: foundry
+ resource: example-foundry # https://example-foundry.services.ai.azure.com
+ auth: { use_azure_ad: true } # preferred: DefaultAzureCredential / Managed Identity
+ # OR an API key:
+ # auth:
+ # api_key: ${FOUNDRY_API_KEY}
+
+`use_azure_ad: true` resolves through `DefaultAzureCredential`: Managed Identity on AKS, ACI, or App Service; the Azure CLI; or environment credentials. API keys work but are project-wide and don’t rotate automatically. Foundry’s endpoint is derived from `resource:`; set the optional `base_url` to override it for sovereign clouds such as Azure Government.
+
+Setup| How
+---|---
+RBAC| Grant the gateway’s identity `Azure AI User` or `Cognitive Services User` on the Foundry resource
+Deployments| Foundry uses admin-chosen deployment names, not canonical model IDs. Add a `models:` block mapping each canonical ID to your deployment name.
+AKS (workload identity)| Federate a User-Assigned Managed Identity with the cluster’s OIDC issuer and bind it to the gateway’s service account. `use_azure_ad: true` picks it up via `WorkloadIdentityCredential`.
+ACI / App Service| Enable system-assigned or user-assigned managed identity on the resource. `use_azure_ad: true` picks it up.
+Anywhere else| `auth: { api_key: "${FOUNDRY_API_KEY}" }`. Quote `${…}` inside `{ }`.
+
+####
+
+
+
+Multiple upstreams
+
+The same provider can appear more than once with a distinct `name:`. This covers different regions, different accounts via different credential chains, provisioned throughput versus on-demand, and cross-provider fallback. The gateway tries upstreams in order. `5xx`, `429`, timeouts, and missing-endpoint (`501`) fail over; other `4xx` doesn’t. `429` is per-upstream capacity, so provisioned-throughput (PT) exhaustion fails over to on-demand. An upstream that can’t resolve the requested model is skipped without a network round-trip. This example routes a provisioned-throughput Bedrock allotment first, overflows to on-demand and a second account, and falls back to the Anthropic API last:
+
+ upstreams:
+ # Primary: provisioned throughput in your home region.
+ - name: bedrock-pt
+ provider: bedrock
+ region: us-east-1
+ auth: {}
+ # Overflow: on-demand cross-region.
+ - name: bedrock-od
+ provider: bedrock
+ region: us-west-2
+ auth: {}
+ # Different account: a separate Bedrock allotment via assumed-role creds.
+ - name: bedrock-acct2
+ provider: bedrock
+ region: us-east-1
+ auth:
+ aws_access_key_id: ${ACCT2_AKID}
+ aws_secret_access_key: ${ACCT2_SK}
+ # Last resort: direct Anthropic API.
+ - name: anthropic-fallback
+ provider: anthropic
+ auth:
+ api_key: ${ANTHROPIC_API_KEY}
+
+ # Per-upstream model IDs are keyed on the upstream's `name:`; an upstream
+ # without a `name:` defaults to its provider string (e.g. `bedrock`). Any
+ # upstream not listed for a model is skipped, which is how you route a model
+ # to provisioned throughput while everything else stays on-demand.
+ models:
+ - id: claude-opus-4-8
+ label: Claude Opus 4.8
+ upstream_model:
+ bedrock-pt: arn:aws:bedrock:us-east-1:111111111111:provisioned-model/abcdef
+ bedrock-od: us.anthropic.claude-opus-4-8
+ bedrock-acct2: us.anthropic.claude-opus-4-8
+ anthropic-fallback: claude-opus-4-8
+
+Lever| How
+---|---
+Different regions| One Bedrock upstream per region, each with its own `region:`. With `auto_include_builtin_models: true` the cross-region inference profiles route automatically; for region-pinned deployments use a `models:` block.
+Different accounts| One Bedrock upstream per account, each with its own credentials in `auth:`. The default chain (`auth: {}`) uses the pod’s identity; for a second account, set explicit credentials or a bearer token.
+Provisioned throughput| Map the model to the provisioned-throughput ARN in `models:` for that upstream’s name. Other upstreams keep the on-demand ID, so PT capacity is exhausted before failing over.
+VPC / FIPS endpoints| Set `base_url:` on the upstream to your VPC endpoint or FIPS endpoint URL
+Model-scoped routing| Omit an upstream from a model’s `upstream_model:` map and that upstream is skipped for that model. For example, route Opus to provisioned throughput and Sonnet and Haiku to on-demand.
+
+Failing over between cloud providers, or to the direct Anthropic API, changes which agreement, geography, and other terms govern the request. The CLI applies the same feature gating to gateways regardless of which upstream serves a given request, so failover doesn’t send a body field an upstream would reject.
+
+##
+
+
+
+Optional sections
+
+###
+
+
+
+`admin`
+
+Optional. Enables `/v1/organizations/spend_limits`, which mirrors Anthropic’s public Admin API, and per-developer spend enforcement on `/v1/messages`. See [Spend limits](</docs/en/claude-apps-gateway-spend-limits>) for how caps are set and enforced; this section covers the `gateway.yaml` keys that turn the feature on and tune it.
+
+ admin:
+ # Named static API keys for the admin endpoints, sent as x-api-key.
+ # The id appears in the audit log as admin-key:<id> so each key is
+ # attributable. Array for rotation: add the new key, roll clients,
+ # remove the old.
+ write_keys:
+ - { id: terraform, key: "${GATEWAY_ADMIN_WRITE_KEY_TF}" }
+ - { id: ci, key: "${GATEWAY_ADMIN_WRITE_KEY_CI}" }
+ read_keys:
+ - { id: reporting, key: "${GATEWAY_ADMIN_READ_KEY}" }
+ # IdP groups granted full admin via the normal gateway JWT (no API key).
+ admin_groups: [platform-finops]
+ blocked_message: request an increase at https://go.example.com/claude-limits
+
+Field| Required| Description
+---|---|---
+`write_keys`| No| Array of `{id, key}`. An `x-api-key` matching one of these can list, set, and delete spend limits. Key values must be at least 32 characters; `id`s must be unique across `read_keys` and `write_keys`.
+`read_keys`| No| Array of `{id, key}`. Read-only: every `GET` endpoint, including listing caps, fetching one by ID, and reading [`/effective`](</docs/en/claude-apps-gateway-spend-limits#%2Feffective>) and [`/audit`](</docs/en/claude-apps-gateway-spend-limits#%2Faudit>).
+`admin_groups`| No| IdP group names. A gateway JWT whose `groups` claim includes one of these has full admin access, read and write, and audits as `oidc:<sub>`. Use this for human admins; use API keys for machines.
+`blocked_message`| No| Appended verbatim to the `429 billing_error` a blocked developer sees. Write the whole instruction, such as a URL or a Slack channel. Unset, the error is `spend limit reached`.
+`audit_retention_days`| No| Default `365`. Older `admin_audit` rows are swept.
+`spend_retention_months`| No| Default `13`. `spend` counter rows older than this are swept. The default keeps a full year plus the current partial month for year-over-year reporting.
+`identity_retention_days`| No| Default `90`. Last-seen TTL for `principal_emails` rows, which hold each developer’s email, display name, and groups (PII). Deliberately shorter than spend retention so a deprovisioned identity ages out while its anonymous spend counters remain.
+`group_limit_mode`| No| `min` (default) or `max`. When a developer is in several groups with caps, `min` enforces the most restrictive and `max` the least. Used by both enforcement and `/effective`.
+
+###
+
+
+
+`enforcement`
+
+The `enforcement` block controls how spend-limit checks behave when the store is unavailable.
+
+Field| Required| Description
+---|---|---
+`fail_closed_on_error`| No| Default `false`. Spend enforcement fails open on a Postgres outage, so inference stays up. Set `true` to fail closed: over-cap developers are blocked, but so is everyone else if the store is unreachable. Has no effect without an `admin:` block.
+
+###
+
+
+
+`models`
+
+The `models` block is an optional admin-curated model list, served at `/v1/models` and used to translate model IDs per upstream. It is required for non-US Bedrock regions, Bedrock provisioned-throughput ARNs, and Foundry deployment names.
+
+ auto_include_builtin_models: true # false: expose only the list below
+ models:
+ - id: claude-opus-4-8
+ label: Claude Opus 4.8
+ # description: optional text shown in clients that surface it
+ upstream_model:
+ anthropic: claude-opus-4-8
+ bedrock: us.anthropic.claude-opus-4-8 # or an inference-profile ARN
+ foundry: your-opus-deployment-name
+
+###
+
+
+
+`managed`
+
+The `managed` block defines role-based access policies keyed on IdP groups or email domain. Policies are evaluated in order; the first match is selected, then merged onto the `match: {}` catch-all base described below. They are served per-user at `GET /managed/settings` with ETag/304 caching.
+
+ managed:
+ policies:
+ # Specific groups first.
+ - match: { groups: [eng-contractors] }
+ cli:
+ availableModels: [claude-sonnet-4-6]
+ permissions: { deny: ["WebFetch", "WebSearch"] }
+ # Default catch-all last: matches everyone who authenticated.
+ - match: {}
+ cli:
+ availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+
+A `match: {}` catch-all, conventionally listed last, is treated as a base layer. Every other policy inherits any key it doesn’t set from the catch-all, so per-role entries only need to list what differs from the org default. The merge rules depend on the key type:
+
+ * **Allow-lists** : `availableModels` and `permissions.allow`. A specific policy’s list fully replaces the base’s.
+ * **Deny-lists and hook arrays** : `permissions.deny`, `permissions.ask`, `disabledMcpjsonServers`, `deniedMcpServers`, `blockedMarketplaces`, and every `hooks` event-type array. These take the union of base and policy, so an org-wide deny or audit hook can’t be accidentally dropped by a per-role override.
+ * **Record-typed keys** : `env`, `modelOverrides`, and `skillOverrides`. These shallow-merge, so a per-role `env` block overrides keys it sets and inherits the rest from the base.
+
+`availableModels` is also enforced server-side at `/v1/messages`, so a denied model returns `400` regardless of what the client sends.
+
+Matcher| Behavior
+---|---
+`match: {}`| Matches every authenticated user. Start with one of these and add group-scoped policies above it later.
+`match: { groups: [a, b] }`| Matches if the JWT’s `groups` claim contains any of the listed groups. Case-sensitive: groups must match the IdP’s exact casing.
+`match: { email_domain: example.com }`| Matches the part after the last `@` in the JWT’s `email` claim, case-insensitive. Accepts one domain per policy.
+`match: { groups: [a], email_domain: example.com }`| Both conditions must match
+
+An authenticated user who matches no policy gets the gateway’s defaults, which means every model in the catalog and no managed settings. Add a `match: {}` catch-all last if you want a guaranteed default policy.
+
+The gateway keeps no user directory of its own. It authorizes each request from the user’s IdP token, reading group membership from the token’s `groups` claim and evaluating policies against it. There is no roster to enumerate and no accounts to pre-create, and therefore no SCIM endpoint, because there is nothing for SCIM to sync into.Run user and group lifecycle management at the source of truth, which is your IdP’s native SCIM provisioning or a dedicated identity-governance platform. Membership and deprovisioning governed there flow into the gateway automatically through the token. If you want SCIM provisioning of Claude accounts themselves, that is a [Claude for Enterprise](</docs/en/admin-setup>) capability.Two propagation clocks apply:
+
+ * **Policy contents** : editing a policy and redeploying reaches connected clients on their next managed-settings poll, within an hour
+ * **Group membership** : changing a user’s group membership changes which policy matches them. This takes effect on the next session re-mint, meaning the next silent refresh, bounded by `session.ttl_hours`.
+
+####
+
+
+
+What goes in `cli`
+
+Each `cli` value is a complete Claude Code `managed-settings.json` document, the same schema you would deploy via MDM or `/etc/claude-code/managed-settings.json`, expressed here as YAML. The CLI applies the delivered document at the managed tier, above user and project settings. The gateway validates each document against the CLI’s settings schema at boot, so an unrecognized top-level key or a recognized key with a malformed value fails boot with an error naming every offending key. Deliberately open parts of the schema still accept arbitrary values, because newer clients may recognize entries the gateway’s schema doesn’t. These open keys are `env`, `pluginConfigs`, and keys nested under `permissions`. Because validation uses the schema bundled with the gateway’s installed version, putting a top-level settings key introduced by a newer Claude Code release into managed config requires upgrading the gateway first. Smoke-test a new policy on one client before rolling it out. The full key reference is in [Claude Code settings](</docs/en/settings#available-settings>). The keys most operators reach for first:
+
+ managed:
+ policies:
+ - match: {}
+ cli:
+ # Model access (also enforced server-side at /v1/messages)
+ availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+
+ # Permission policy
+ permissions:
+ deny:
+ - "WebFetch"
+ - "Read(./.env)"
+ - "Read(./secrets/**)"
+ disableBypassPermissionsMode: disable # blocks --dangerously-skip-permissions
+ allowManagedPermissionRulesOnly: true # ignore user/project permission rules
+
+ # Environment pushed into the CLI process. DISABLE_UPDATES blocks
+ # background and manual updates; DISABLE_AUTOUPDATER stops only
+ # background updates.
+ env:
+ DISABLE_UPDATES: "1" # pin versions via your own distribution
+
+ # Org-wide hooks. Hook commands run on developer machines, not the
+ # gateway, so the path must exist on every client OS in the policy.
+ hooks:
+ PostToolUse:
+ - matcher: "Edit|Write"
+ hooks:
+ - { type: command, command: /usr/local/bin/audit-edit.sh }
+
+Key| Enforced by| Effect
+---|---|---
+`availableModels`| Gateway + CLI| Model allowlist. Also checked at `/v1/messages`, so a patched client can’t bypass it.
+`permissions.allow` / `.deny`| CLI| Tool and command rules. See [Permissions](</docs/en/permissions>).
+`permissions.disableBypassPermissionsMode`| CLI| Set to `disable` to block [`bypassPermissions`](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>), the mode that auto-approves every tool call, and the `--dangerously-skip-permissions` flag
+`allowManagedPermissionRulesOnly`| CLI| When `true`, user and project permission rules are ignored; only rules from this document apply
+`env`| CLI| Environment variables merged into the CLI process. Use for telemetry, auto-update, and model-name overrides.
+`hooks`| CLI| Org-wide [hooks](</docs/en/hooks>)
+
+Because these settings arrive over the network, the CLI shows each developer a one-time security approval dialog before applying anything that can run a shell command or alter where traffic goes. The dialog covers:
+
+ * `hooks`
+ * `env` variables that aren’t on the CLI’s built-in safe list
+ * shell-execution settings such as `apiKeyHelper` and `statusLine`
+ * managed CLAUDE.md content
+
+The safe list determines which `env` variables apply without approval:
+
+ * **On the safe list** : auto-update and model-name vars
+ * **Not on the safe list** : proxy vars, base-URL vars, and `OTEL_EXPORTER_OTLP_ENDPOINT`
+
+The gateway’s telemetry configuration pushes `OTEL_EXPORTER_OTLP_ENDPOINT`, so setting `telemetry.forward_to` triggers the dialog on each interactive client. Non-interactive runs with the `-p` flag skip the dialog and apply settings without approval. The dialog protects the developer’s machine from a compromised or hostile gateway, not the organization from the developer, so the `-p` skip is intentional rather than a gap. If a developer declines, Claude Code exits rather than applying the policy. Pushing a new hook or non-safe env var to a broad policy therefore means an approval prompt on every matching developer’s next startup. The `cli` key was named `settings` in earlier releases. That spelling is still accepted as an alias, but new deployments should use `cli`.
+
+####
+
+
+
+Precedence with other managed sources
+
+If a device also has a local `managed-settings.json` or MDM-delivered policy, the managed sources don’t merge. The highest-priority source provides all policy settings, ranked in this order with highest priority first:
+
+ 1. The [policy helper](</docs/en/settings#compute-managed-settings-with-a-policy-helper>)
+ 2. Gateway-delivered settings
+ 3. MDM, via the HKLM registry on Windows or a plist on macOS
+ 4. The `managed-settings.json` file
+ 5. The HKCU registry, on Windows only
+
+Embedding hosts can supply policy through the SDK `managedSettings` option. It is ignored by default and applies only when a managed source opts in with [`parentSettingsBehavior: "merge"`](</docs/en/settings#available-settings>), filtered so it can tighten policy but not loosen it. The only exception is the following keys, which are honored when any admin source above the user-writable HKCU tier sets them, regardless of which source provides the rest of the policy:
+
+ * `sandbox.network.allowManagedDomainsOnly` and `sandbox.filesystem.allowManagedReadPathsOnly`: when locked, the corresponding allowlists are unioned across sources
+ * [`allowAllClaudeAiMcps`](</docs/en/settings#available-settings>): allow-only override for the claude.ai MCP server allowlist
+ * `sandbox.bwrapPath` and `sandbox.socatPath`: filesystem paths to the [sandbox](</docs/en/sandboxing>) helper binaries
+
+Every other key, including `allowManagedPermissionRulesOnly` and `disableBypassPermissionsMode`, comes from the highest-priority source only. See [Settings precedence](</docs/en/settings#settings-precedence>) for the same rule on the settings page. Gateway policies apply to every Claude Code invocation on the machine, including non-interactive `claude -p` runs and sessions spawned by the Agent SDK. If the gateway is unreachable at startup, signed-in sessions exit with an error rather than running without their policy.
+
+`mcpServers` inside a policy’s `cli` block is rejected at gateway boot. Per-group MCP distribution is not available; deploy MCP servers via the file-based `managed-mcp.json` on each device or let developers add them locally.
+
+###
+
+
+
+`telemetry`
+
+The CLI sends OpenTelemetry Protocol (OTLP) over HTTP metrics, logs, and, when enabled, traces to the gateway, which relays them verbatim to each configured destination. See [Monitoring usage](</docs/en/monitoring-usage>) for the metrics and events the CLI emits. The CLI stamps each export with the authenticated user’s identity, read from the gateway-issued JWT: the `user.id`, `user.email`, and `user.groups` attributes. Per-developer cost and usage attribution therefore works with no developer-side configuration.
+
+ telemetry:
+ forward_to:
+ - url: https://otel-collector.internal.example.com
+ headers:
+ Authorization: ${OTLP_TOKEN}
+ # Per-signal opt-in. Default: metrics only.
+ metrics: true
+ logs: false
+ traces: false
+ - url: https://api.datadoghq.com/api/v2/otlp
+ headers:
+ DD-API-KEY: ${DD_API_KEY}
+
+Each destination opts into `metrics`, `logs`, and `traces` independently, and the default is metrics only. The signals differ in sensitivity:
+
+ * **Metrics** : aggregate counters such as token counts, request counts, and latency
+ * **Logs and traces** : can carry full bash commands, tool inputs, and file paths, covering anything Claude Code does on a developer’s machine
+
+Enable logs and traces only on destinations with the access controls and retention policy that data warrants.
+
+Telemetry is off in the CLI by default. Configuring `telemetry.forward_to` together with `listen.public_url` turns it on. The gateway pushes five env vars to every connected client through `/managed/settings`:
+
+ * `CLAUDE_CODE_ENABLE_TELEMETRY=1`
+ * `OTEL_METRICS_EXPORTER=otlp`
+ * `OTEL_LOGS_EXPORTER=otlp`
+ * `OTEL_TRACES_EXPORTER=otlp`
+ * `OTEL_EXPORTER_OTLP_ENDPOINT=<public_url>`
+
+The pushed endpoint is built from the public URL, so metrics and logs need no OTEL configuration from developers or policies. The pushed configuration is applied at the managed tier, overriding `OTEL_*` variables a developer sets locally. [Traces](</docs/en/monitoring-usage#traces-beta>) additionally require `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` on each client. The gateway doesn’t push that variable, so set it through a managed policy’s `env` block. It isn’t on the CLI’s safe list, so delivering it through a policy is covered by the same security approval dialog that the pushed OTLP endpoint already triggers. Both protobuf and JSON OTLP encodings are relayed, and any OpenTelemetry-compatible backend works as a destination.
+
+###
+
+
+
+HTTP tuning
+
+Four optional top-level blocks, `access_control`, `limits`, `timeouts`, and `rate_limits`, tune the HTTP surface. The defaults suit most deployments.
+
+Block| Key| Default| Description
+---|---|---|---
+`access_control`| `allow_cidrs` / `deny_cidrs`| empty| Inbound IP allow/deny by client address, after `trusted_proxies` resolution. `deny_cidrs` is checked first; a client it matches is rejected even if `allow_cidrs` also matches. If `allow_cidrs` is non-empty the gateway is default-deny. `/healthz` and `/readyz` are exempt from `allow_cidrs`.
+`limits`| `max_request_bytes`| 32 MiB| Max inbound request body; oversize requests get `413` before the body is buffered. Raise for large file or image requests.
+`limits`| `max_request_header_bytes`| unset| When set, oversize headers return `431`
+`limits`| `max_url_length`| unset| When set, an over-long URL returns `414`
+`timeouts`| `upstream_ttfb_ms`| 120000| Max wait for the upstream’s response headers (time to first byte). The response body then streams with no wall-clock cap. Applies to the direct Anthropic upstream path; Bedrock, Agent Platform, and Foundry are bounded by their provider SDK’s own timeout.
+`rate_limits`| `device_authorization.max` / `.window_seconds`| 30 / 600| Per-IP rate limit on the unauthenticated device-authorization endpoint. Raise for a large org behind a shared egress IP or NAT. These limits apply only to the device-grant sign-in flow, not to `/v1/messages` inference. See [User-code brute-force resistance](</docs/en/claude-apps-gateway-deploy#user-code-brute-force-resistance>).
+`rate_limits`| `device_verify.max` / `.window_seconds`| 10 / 600| Per-IP rate limit on `user_code` submissions at `/device`
+
+##
+
+
+
+Complete example
+
+This full reference config exercises every core section; the HTTP tuning blocks keep their defaults. Copy it, delete what you don’t need, and fill in your values. The config in the [Quickstart](</docs/en/claude-apps-gateway#quickstart>) is a minimal version of this.
+
+gateway.yaml
+
+ # Run with:
+ # claude gateway --config gateway.yaml
+ #
+ # Operational log verbosity is controlled by the CLAUDE_GATEWAY_LOG_LEVEL
+ # environment variable (info | warn | error; default info). It does not
+ # affect audit events, which are always emitted.
+
+ listen:
+ host: 0.0.0.0
+ port: 8080
+ public_url: https://claude-gateway.internal.example.com
+ # Omit the tls block when running behind a TLS-terminating ingress.
+ # tls:
+ # cert: /certs/gateway.crt
+ # key: /certs/gateway.key
+ # trusted_proxies:
+ # - 10.0.0.0/8
+
+ oidc:
+ issuer: https://example.okta.com
+ client_id: 0oa1example2
+ client_secret: ${OIDC_CLIENT_SECRET}
+ allowed_email_domains:
+ - example.com
+ # Required when the issuer is the Okta org server, whose id_tokens
+ # can omit email and groups; the gateway fills them from /userinfo.
+ userinfo_fallback: true
+ # allowed_groups: [claude-code-users]
+ # Okta emits groups only when the `groups` scope is requested and the
+ # app's groups claim filter allows them. The contractors policy below
+ # matches on groups, so the scope is requested here.
+ scopes: [openid, profile, email, offline_access, groups]
+ # extra_auth_params: { access_type: offline, prompt: consent } # Google
+ # groups_claim: groups # Entra app roles: use `roles`
+ # email_claim: email
+
+ session:
+ jwt_secret: ${GATEWAY_JWT_SECRET} # openssl rand -base64 32
+ # ttl_hours: 1
+
+ store:
+ postgres_url: ${GATEWAY_POSTGRES_URL}
+ # max_connections: 5
+
+ # Enables /v1/organizations/spend_limits (mirrors the Anthropic Admin API)
+ # and per-developer spend enforcement on /v1/messages. Omit to disable.
+ # Caps themselves are set via the admin API, not here.
+ # admin:
+ # write_keys:
+ # - { id: terraform, key: "${GATEWAY_ADMIN_WRITE_KEY_TF}" }
+ # read_keys:
+ # - { id: reporting, key: "${GATEWAY_ADMIN_READ_KEY}" }
+ # admin_groups: [platform-finops]
+ # blocked_message: request an increase at https://go.example.com/claude-limits
+ # # audit_retention_days: 365
+ # # spend_retention_months: 13
+ # # identity_retention_days: 90
+ # # group_limit_mode: min
+
+ # enforcement:
+ # fail_closed_on_error: false
+
+ upstreams:
+ - provider: anthropic
+ auth:
+ api_key: ${ANTHROPIC_API_KEY}
+
+ # - provider: bedrock
+ # region: us-east-1
+ # auth: {}
+
+ # - provider: vertex
+ # region: us-east5
+ # project_id: example-prod
+ # auth: {}
+
+ # - provider: foundry
+ # resource: example-foundry
+ # auth: { use_azure_ad: true }
+
+ auto_include_builtin_models: true
+ models:
+ - id: claude-opus-4-8
+ label: Claude Opus 4.8
+ upstream_model:
+ anthropic: claude-opus-4-8
+ # bedrock: us.anthropic.claude-opus-4-8
+ # vertex: claude-opus-4-8
+ # foundry: <your-opus-deployment-name>
+ - id: claude-sonnet-4-6
+ label: Claude Sonnet 4.6
+ upstream_model:
+ anthropic: claude-sonnet-4-6
+ - id: claude-haiku-4-5
+ label: Claude Haiku 4.5
+ upstream_model:
+ anthropic: claude-haiku-4-5
+
+ managed:
+ policies:
+ - match: { groups: [contractors] }
+ cli:
+ availableModels: [claude-haiku-4-5]
+ # Constrain the Default picker option to availableModels instead of
+ # the tier default, so contractors don't get a 400 on the default.
+ enforceAvailableModels: true
+ # allow auto-approves these tools; it does not block the rest.
+ # Add deny rules to restrict tools.
+ permissions: { allow: [Read, Grep] }
+ - match: {}
+ cli:
+ availableModels: [claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5]
+ permissions:
+ allow: [Read, Grep, Bash, Edit]
+ deny: ["WebFetch"]
+ env: { HTTP_PROXY: http://proxy.example.com:8080 }
+
+ telemetry:
+ forward_to:
+ - url: https://otel.internal.example.com:4318
+ headers:
+ Authorization: Bearer ${OTEL_TOKEN}
+
+##
+
+
+
+Client-side managed settings
+
+Everything above configures the gateway server. Pointing developer machines at it is configured separately, on each device, through Claude Code’s [managed settings](</docs/en/settings#settings-files>). The gateway can’t push these keys itself, because they’re what tell the client where the gateway is. For the CLI, set both keys in the per-OS `managed-settings.json`:
+
+ {
+ "forceLoginMethod": "gateway",
+ "forceLoginGatewayUrl": "https://claude-gateway.internal.example.com"
+ }
+
+Deploy that file to each device, typically via your MDM platform. The file path differs by platform:
+
+Platform| Path
+---|---
+macOS| `/Library/Application Support/ClaudeCode/managed-settings.json`, or the `com.anthropic.claudecode` managed preferences domain
+Linux and WSL| `/etc/claude-code/managed-settings.json`
+Windows| `C:\Program Files\ClaudeCode\managed-settings.json`, or Group Policy via the HKLM registry
+
+`forceLoginGatewayUrl`, and the `"gateway"` value of `forceLoginMethod`, are honored only from the admin-controlled managed tier. A developer setting them in their own `~/.claude/settings.json` has no effect.
+
+##
+
+
+
+Related
+
+ * [Claude apps gateway overview](</docs/en/claude-apps-gateway>): quickstart and developer connection
+ * [Deployment guide](</docs/en/claude-apps-gateway-deploy>): IdP setup, container image, Kubernetes and Cloud Run, and operations
+ * [Spend limits](</docs/en/claude-apps-gateway-spend-limits>): per-developer caps and the Admin API