> ## Content Index
> Fetch the complete content index at: https://claudefox.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Claude Code cloud sessions can hold API keys Claude never sees
- URL: https://claudefox.com/claude-code-cloud-sessions-can-hold-api-keys-claude-never-sees/
- Published: 2026-11-07T08:55:00.000Z
- Updated: 2026-11-20T02:54:15.000Z
- Description: Claude Code cloud environments can store network secrets: API keys that Anthropic's agent proxy attaches to requests outside the session's VM, so Claude can call an API without ever reading the key. How to add one, and its limits.
- Author: hupicake
- Tags: Tools

*Updated November 20, 2026: Expanded with setup steps, which requests never get a secret, plan and role requirements, and how setup scripts are cached.*

Claude Code's cloud sessions, the ones you start at claude.ai/code, in the desktop or mobile app, or from the CLI, run in a cloud environment that you can configure. One option in that configuration solves an old problem with coding agents: how to let the agent call a real API without handing it the key. Anthropic calls these network secrets.

## How network secrets work

A network secret is an API key or token stored on a cloud environment, together with the hosts it belongs to. When a command in the session sends a request to one of those hosts, Anthropic's agent proxy adds the key after the request has left the session's virtual machine. The key stays outside the VM, so it does not show up in the session's environment variables or in any file, and Claude never sees it. The API simply answers as if the key had been in the request. Claude can still make calls with the key and read the responses, which is the point, so "never sees" is not the same as "cannot misuse". The API must accept connections from the internet, because the requests leave from Anthropic's network.

This is different from the environment's ordinary environment variables. The docs are blunt about those: anyone who uses the environment can read the values, and in an Anthropic-hosted environment you should use a network secret instead. Our advice follows from that: don't paste the real key into the chat, a prompt, the setup script or the repository.

## How to add a secret

- Open the environment for editing at claude.ai/code (the environment selector under the message box) and select the Network secrets row. In a shared Team or Enterprise environment that row only exists for Owners; other members need to ask an Owner to add the secret.
- Choose Add secret. Keep the default type, Bearer, for a key sent in a request header.
- Under Allowed websites, list the API's hosts, such as api.example.com. A leading \*. matches every subdomain.
- Under Custom headers, the row starts as Authorization with a Bearer prefix; paste the key as the value. For a header like X-Api-Key that takes the bare key, rename the header and clear the prefix.
- Select Add. The secret is saved right away, and you cannot view the value again.

To check it, start a session in that environment and ask Claude to call the API, for example with curl, without putting the key in the command; the proxy supplies it. If the list marks a secret Not sent, the note under it explains why. One trap: two secrets whose hosts overlap without matching exactly get no marker, and the proxy sends only one of them. To change a secret's hosts or value, delete it and add it again. On Team and Enterprise plans, members without an organization admin role get a shorter form that takes one secret for one exact host, with no wildcards; its type is Token or Username and password, and for a header other than Authorization, such as X-Api-Key, you change the Header field to that name.

## Requests that never get the secret

The proxy will not attach a secret to some traffic, whatever hosts you list:

- GitHub, which goes through Claude Code's own GitHub proxy instead.
- The Anthropic API (api.anthropic.com) and the public package registries: registry.npmjs.org, jsr.io, npm.jsr.io, pypi.org, files.pythonhosted.org, index.crates.io and proxy.golang.org.
- Requests made by the environment's setup script, because Claude Code connects to the proxy only after the script has run.
- Claude Code's own telemetry export.

Hosts you list on a secret are also reachable even if the environment's network access level would otherwise block them, except for the hosts above that never get the secret. A secret applies in every session in that environment, whoever starts it, until you delete it.

## Requirements and limits

Network secrets are available on Pro, Max, Ultra and Team plans, and for Enterprise users with premium seats or Chat + Claude Code seats, only in Anthropic-hosted environments; self-hosted environments do not have them. If custom roles govern your access, you also need a role with the cloud sessions permission. Organizations that use customer-managed encryption keys cannot save them. Recent Claude Code releases changed the feature: 2.1.316 let Enterprise members add and delete secrets on their own environments rather than only viewing them, 2.1.317 stopped a new secret from silently replacing an existing one for the same host, and 2.1.323 made the message shown when some secrets can't be added to a new environment list each host and the reason.

## Getting the rest of a repo ready

Secrets sit alongside the environment's other settings. A setup script is a Bash script that runs as root on Ubuntu 24.04 before Claude Code starts, for installing tools that are not pre-installed. It must exit zero, it runs before the environment's variables are set, and package installs need network access to the registries. If it finishes within roughly five minutes, Anthropic snapshots the filesystem and later sessions start from that snapshot, so dependencies are already on disk. The cache keeps files, not running processes, and it is rebuilt when you change the script or allowed hosts, or after about seven days. For project setup that should run both locally and in the cloud, such as npm install, the docs recommend a SessionStart hook instead.

## Our take

In our view this is a sound design for agent credentials: the proxy adds the key after the request leaves the VM, only for the hosts you name, instead of leaving it in a file the agent can print. It does not make every key safe to share. Our advice: an agent can still make any call the key allows to those hosts, so use test or narrowly scoped keys wherever you can.

Source: [Configure cloud environments (Claude Code Docs)](https://code.claude.com/docs/en/cloud-environments?ref=claudefox.com), [Use Claude Code in the cloud (Claude Code Docs)](https://code.claude.com/docs/en/claude-code-on-the-web?ref=claudefox.com), [Claude Code changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md?ref=claudefox.com)

This story first appeared in the [claudefox daily briefing for November 7, 2026](https://claudefox.com/daily-2026-11-07/).