AsyncSecret | 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:

AsyncSecretService

class AsyncSecretService()

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.

AsyncSecretService.list

@with_instrumentation()

async 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:

async with AsyncDaytona() as daytona:
    cursor = None
    while True:
        page = await 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

AsyncSecretService.get

@with_instrumentation()

async def get(secret_id: str) -> Secret

Get a Secret by its ID.

Arguments:

Returns:

Raises:

Example:

async with AsyncDaytona() as daytona:
    secret = await daytona.secret.get("secret-id")
    print(f"{secret.name} can be used on {', '.join(secret.hosts)}")

AsyncSecretService.create

@with_instrumentation()

async def create(params: CreateSecretParams) -> Secret

Create a new Secret.

Arguments:

Returns:

Raises:

Example:

async with AsyncDaytona() as daytona:
    secret = await daytona.secret.create(
        CreateSecretParams(
            name="anthropic-prod",
            value="sk-ant-...",
            hosts=["api.anthropic.com"],
        )
    )
    print(f"Created secret {secret.name} with placeholder {secret.placeholder}")

AsyncSecretService.update

@with_instrumentation()

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

Update an existing Secret. Omitted fields are left unchanged.

Arguments:

Returns:

Raises:

Example:

async with AsyncDaytona() as daytona:
    secret = await daytona.secret.update(
        "secret-id",
        UpdateSecretParams(
            value="sk-ant-new-value",
            hosts=["api.anthropic.com", "*.anthropic.com"],
        ),
    )

AsyncSecretService.delete

@with_instrumentation()

async def delete(secret_id: str) -> None

Delete a Secret.

Arguments:

Raises:

Example:

async with AsyncDaytona() as daytona:
    await 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: