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

# An agent that uses your API tokens without seeing them

> Credential vault plus an egress allowlist: the token is added on the way out, and only the hosts you name are reachable.

**You want** an agent to call GitHub, OpenAI or your own API with a real token, while the code it runs can never read the token, copy it, or send anything to a host you did not choose.

**Pieces.**

* The [credential vault](/docs/concepts/networking.md#credentials-without-exposing-them) stores the token. The egress proxy adds it as a header to HTTPS requests for one named host. It never enters the sandbox: not its environment, not its disk.
* An [egress policy](/docs/concepts/networking.md#egress) turns public internet off and allows only the hosts the agent needs.

**1. Store the token once**

On the dashboard's **Credential vault** page, or from the CLI. Name every host the secret may ever be sent to; a rule aimed anywhere else is refused with `403`.

```bash store_token.sh
# The value comes from a file or a pipe, never an argument.
anona-compute vault create github_token --host api.github.com --value-file token.txt
```

**2. Create the sandbox locked to that host**

```python locked_sandbox.py
from anona_compute import Sandbox

sbx = Sandbox.create(
    "base",
    timeout=600,
    network={
        "deny_out": ["0.0.0.0/0"],          # no public internet ...
        "allow_out": ["api.github.com"],     # ... except this host
        "rules": {
            "api.github.com": [
                {"transform": {"headers": {"Authorization": "Bearer ${vault.github_token}"}}}
            ]
        },
    },
)
try:
    # The agent's code has no token to leak.
    print(sbx.commands.run("env | grep -ci token || true").stdout.strip(), "token variables")
finally:
    sbx.kill()
```

Inside, `curl https://api.github.com/user` arrives authenticated, and `curl https://example.com` does not connect.

**3. Give the agent a key that cannot widen this**

Run the agent with an [API key](/docs/guides/ci.md#create-a-key-for-ci) that has no `vault:bind` scope (no preset has it). It can still create sandboxes under rules you saved in the team egress settings, but any new rule it writes is refused with `403`, so it cannot aim your token at a host of its choosing.

**4. Rotate or revoke**

`anona-compute vault rotate github_token --value-file new-token.txt` reaches running sandboxes within a minute. Ending a sandbox revokes its own bindings.

**Every sandbox the same way.** Put the allowlist and the rule in the team egress settings (dashboard **Network** page) instead of each create request, and every new sandbox gets them.

**Audit.** For each request a rule matches, the proxy records time, method, host, path, status and size, and the names of the headers it added. Never bodies, never the value.

> [!NOTE]
>
> The proxy terminates TLS for hosts with a rule, using a certificate authority that is already in the sandbox's system bundle. Clients with their own trust store (a Java keystore, certifi passed explicitly, a pinned certificate) need pointing at `/etc/ssl/certs/ca-certificates.crt`. See [How it works](/docs/concepts/networking.md#how-it-works).

**Runnable example:** [`examples/python/vault_locked_sandbox.py`](https://github.com/anonalabs/anona-compute-sdk/blob/main/examples/python/vault_locked_sandbox.py) in the public SDK repository. It prints what happens at each step.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.