DaytonaDocs

SecretService

Manage project secrets.

SecretService manages project-scoped secrets: named values stored encrypted, attached to sandboxes by name at creation. The sandbox only ever receives an opaque per-sandbox placeholder as an environment variable — the platform's egress proxy substitutes the real value into outbound requests, so the real value never enters the sandbox and is never returned by the API (values are write-only). Obtain the service as daytona.secret. See the secrets guide.

set()

Creates a secret, or updates an existing one's value and metadata (upsert by name).

Python
def set(
    name: str,
    value: str,
    allowed_domains: List[str] | None = None,
    description: str | None = None,
) -> None
ParameterTypeDefaultDescription
namestrSecret name (referenced from secrets=[...] at sandbox creation).
valuestrThe secret value. Write-only — never returned by any API.
allowed_domainsList[str]NoneRestrict substitution to these hosts (exact or *. wildcard). Empty/omitted allows any verified upstream.
descriptionstrNoneHuman-readable description.
Python
daytona.secret.set(
    "OPENAI_API_KEY",
    "sk-...",
    allowed_domains=["api.openai.com"],
    description="OpenAI key for eval runs",
)

get()

Fetches one secret's metadata — name, allowed domains, description, last-update time. Never the value.

Python
def get(name: str) -> Dict[str, Any]

Raises: DaytonaNotFoundError if the secret does not exist.

list()

Lists secret metadata for the project. Never returns values.

Python
def list() -> List[Dict[str, Any]]

Returns: a list of metadata dicts (name, allowed_domains, description, updated_at).

delete()

Deletes a secret. Already-running sandboxes that attached it are unaffected.

Python
def delete(name: str) -> None

Attaching secrets to a sandbox

Pass secret names in secrets at creation. Each becomes an environment variable inside the sandbox whose value is an opaque placeholder; outbound requests to permitted hosts have the placeholder replaced with the real value in transit.

Python
from rlp import CreateSandboxFromImageParams
 
daytona.secret.set("OPENAI_API_KEY", "sk-...", allowed_domains=["api.openai.com"])
 
sandbox = daytona.create(CreateSandboxFromImageParams(
    image="python:3.12-slim",
    secrets=["OPENAI_API_KEY"],
))
# Inside the sandbox, $OPENAI_API_KEY holds an opaque placeholder;
# outbound requests to api.openai.com carry the real key.

See environment and secrets for placeholder semantics and naming rules.

On this page