> ## Documentation Index
> Fetch the complete documentation index at: https://microsanbox-staging-appcypher-sdk-runtime-bootstrap.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Secrets

> Python secret substitution and placeholder passthrough

Secrets expose a placeholder to the guest and substitute the real value only for an allowed host and enabled request location. A placeholder in any other location is blocked unless the destination is explicitly allowed to receive it unchanged.

```python theme={null}
from microsandbox import Secret, SecretSubstitution, ViolationAction

secret = Secret.env(
    "GH_TOKEN",
    value=token,
    allow=("github.com", "api.github.com"),
    passthrough=("api.anthropic.com",),
    substitution=SecretSubstitution(headers=False, query=False, body=True),
    require_tls_identity=True,
    violation_action=ViolationAction.BLOCK_AND_TERMINATE,
)

sandbox = await Sandbox.create(
    "worker",
    secrets=[secret],
    secret_violation_action=ViolationAction.BLOCK_AND_LOG,
)
```

`allow` accepts exact hosts and wildcard patterns such as `*.example.com`. Substitution defaults to headers enabled, query disabled, and body disabled. Basic authentication follows the header setting.

Disabling substitution does not make a placeholder inert: the placeholder is still blocked unless the request host matches `passthrough`. `ViolationAction` contains `BLOCK`, `BLOCK_AND_LOG`, and `BLOCK_AND_TERMINATE`; the per-secret action overrides the sandbox-wide action.

See [Secrets](/sandboxes/secrets) for CLI and YAML syntax.
