---
title: "Guarded egress and secrets"
description: "Keep an environment's internet to an allowlist, and give it API keys it never holds."
---

> Documentation Index
> Fetch the complete documentation index at: https://regent.c4n.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Guarded egress and secrets

A guarded environment is on a host-only network. Its only way out is Regent's proxy on this
Mac, which allows the hosts on its list and refuses the rest.

```sh
regent create sandbox --egress guarded
regent create sandbox --egress guarded --allow 'api.stripe.com,*.example.com'
```

The default list covers what agents and builds usually need: Anthropic and OpenAI APIs,
GitHub, npm, PyPI, Debian, Go modules, uv and mise, and Tailscale.

## Change the list

Changes apply at once, without a restart:

```sh
regent egress ls                          # guarded environments and their hosts
regent egress allow sandbox api.stripe.com
regent egress deny sandbox api.stripe.com
regent egress log sandbox                 # what it connected to, allowed and refused
```

## Secrets

A secret is an API key the environment sees only as a placeholder. The proxy swaps in the real
value on requests to the secret's hosts, so an agent can use the key without being able to
read it.

```sh
regent secret set anthropic --env ANTHROPIC_API_KEY --host api.anthropic.com
regent create sandbox --egress guarded --secret anthropic
```

`secret set` asks for the value and keeps it in the macOS Keychain. `--ref` stores a
reference instead (`op://...`, `keychain:SERVICE/ACCOUNT`, `file:PATH`, `env:NAME`).
`regent secret ls` shows names and hosts, never values.

Source: https://regent.c4n.dev/docs/guides/egress/index.mdx
