Secret | Daytona

Secret

class Secret(SecretDto)

Represents an organization-scoped Daytona Secret.

The plaintext value is write-only and is never returned by the API. When a Secret is referenced from a Sandbox, the injected environment variable holds the opaque placeholder token, not the real value. The real value is substituted transparently on outbound requests to the Secret’s allowed hosts.

Attributes:

SecretService

class SecretService()

Service for managing organization-scoped Daytona Secrets.

Can be used to create, list, get, update and delete Secrets. Secrets can be mounted into Sandboxes as environment variables by referencing them via the secrets field on the create-sandbox parameters. The Sandbox only ever sees the Secret’s opaque placeholder; the real value is substituted at the network egress layer for the Secret’s allowed hosts.

SecretService.list

@with_instrumentation()

def list(cursor: str | None = None,
         limit: int | None = None,
         name: str | None = None,
         sort: str | None = None,
         order: str | None = None) -> ListSecretsResponse

List Secrets in the organization using cursor-based pagination.

Arguments:

Returns:

Example:

daytona = Daytona()

cursor = None

while True:
    page = daytona.secret.list(cursor=cursor, limit=50)
    print(f"Fetched {len(page.items)} of {page.total} secrets")
    for secret in page.items:
        print(f"{secret.name} ({secret.id})")
    if page.next_cursor is None:
        break
    cursor = page.next_cursor

SecretService.get

@with_instrumentation()

def get(secret_id: str) -> Secret

Get a Secret by its ID.

Arguments:

Returns:

Raises:

Example:

daytona = Daytona()

secret = daytona.secret.get("secret-id")

print(f"{secret.name} can be used on {', '.join(secret.hosts)}")

SecretService.create

@with_instrumentation()

def create(params: CreateSecretParams) -> Secret

Create a new Secret.

Arguments:

Returns:

Raises:

Example:

daytona = Daytona()

secret = daytona.secret.create(
    CreateSecretParams(
        name="anthropic-prod",
        value="sk-ant-...",
        hosts=["api.anthropic.com"],
    )
)

print(f"Created secret {secret.name} with placeholder {secret.placeholder}")

SecretService.update

@with_instrumentation()

def update(secret_id: str, params: UpdateSecretParams) -> Secret

Update an existing Secret. Omitted fields are left unchanged.

Arguments:

Returns:

Raises:

Example:

daytona = Daytona()

secret = daytona.secret.update(
    "secret-id",
    UpdateSecretParams(
        value="sk-ant-new-value",
        hosts=["api.anthropic.com", "*.anthropic.com"],
    ),
)

SecretService.delete

@with_instrumentation()

def delete(secret_id: str) -> None

Delete a Secret.

Arguments:

Raises:

Example:

daytona = Daytona()

daytona.secret.delete("secret-id")

print("Secret deleted")

ListSecretsResponse

class ListSecretsResponse(ListSecretsResponseDto)

Represents a paginated list of Daytona Secrets.

Attributes:

CreateSecretParams

class CreateSecretParams(BaseModel)

Parameters for creating a new Secret.

Attributes:

UpdateSecretParams

class UpdateSecretParams(BaseModel)

Parameters for updating an existing Secret. Omitted fields are left unchanged.

Attributes: