Skip to content
View as Markdown
class FileSystemService()

Sandbox filesystem namespace.

def __init__(impl: AsyncFileSystemService, bridge: SyncBridge) -> None
def chmod(path: str,
*,
mode: Optional[str] = None,
owner: Optional[str] = None,
group: Optional[str] = None) -> None

Set file permissions and ownership.

def delete(path: str, *, recursive: bool = False) -> None

Delete a file or directory.

def download_file(remote_path: str,
local_path: str | os.PathLike[str],
*,
on_progress: TransferProgressCallback | None = None,
cancel: TransferCancelSignal | None = None) -> None
def find(path: str, pattern: str) -> ListResult

Find files under a path.

def list(path: str, *, depth: Optional[int] = None) -> ListResult[FileInfo]

List directory entries as typed FileInfo rows (items, next_cursor).

def mkdir(path: str, *, mode: str = '755') -> None

Create a directory.

def move(source: str, destination: str) -> None

Move or rename files.

def presigned_download_url(path: str, *, expires_in_seconds: int = 3600) -> str

Return a pre-signed download URL for a sandbox file.

def presigned_upload_url(path: str, *, expires_in_seconds: int = 3600) -> str

Return a pre-signed upload URL for a sandbox file.

def read_bytes(path: str) -> bytes

Read a file as bytes.

def read_many(paths: Sequence[str]) -> BulkReadResult

Read multiple files, buffering each returned file in memory before returning.

def read_text(path: str) -> str

Read a UTF-8 text file.

def replace(files: Sequence[str], pattern: str, new_value: str) -> ListResult

Replace text in files.

def search(path: str, pattern: str) -> ListResult[str]

Search file contents.

def stat(path: str) -> FileInfo

Return file metadata.

def upload_file(local_path: str | os.PathLike[str],
remote_path: str,
*,
on_progress: TransferProgressCallback | None = None,
cancel: TransferCancelSignal | None = None,
atomic: bool = False) -> None

Stream a local file into the sandbox without buffering it whole in memory.

def watch_dir(path: str,
on_event: Optional[_WatchCallback] = None,
*,
recursive: bool = False,
on_overflow: Optional[_OverflowCallback] = None,
on_exit: Optional[_ExitCallback] = None) -> WatchHandle
def write_bytes(path: str, content: bytes, *, atomic: bool = False) -> None

Write bytes to a file, optionally via temp-file + rename.

def write_many(files: Mapping[str, bytes], *, atomic: bool = False) -> BulkWriteResult

Write several files in one request, optionally atomically per file.

def write_text(path: str, content: str, *, atomic: bool = False) -> None

Write a UTF-8 text file, optionally via temp-file + rename.

class AsyncFileSystemService()

Sandbox filesystem namespace.

def __init__(transport: AsyncTransport,
*,
file_url_signer: Optional[FileUrlSigner] = None) -> None
async def read_bytes(path: str) -> bytes

Read a file as bytes.

async def read_text(path: str) -> str

Read a UTF-8 text file.

async def write_bytes(path: str, content: bytes, *, atomic: bool = False) -> None

Write bytes to a file, optionally via temp-file + rename.

async def write_text(path: str, content: str, *, atomic: bool = False) -> None

Write a UTF-8 text file, optionally via temp-file + rename.

AsyncFileSystemService.presigned_download_url

Section titled “AsyncFileSystemService.presigned_download_url”
async def presigned_download_url(path: str, *, expires_in_seconds: int = 3600) -> str

Return a pre-signed download URL for a sandbox file.

The signature is minted by the control plane; expires_in_seconds must be between 1 and SIGNED_FILE_MAX_TTL_SECONDS (7 days).

AsyncFileSystemService.presigned_upload_url

Section titled “AsyncFileSystemService.presigned_upload_url”
async def presigned_upload_url(path: str, *, expires_in_seconds: int = 3600) -> str

Return a pre-signed upload URL for a sandbox file.

The signature is minted by the control plane; expires_in_seconds must be between 1 and SIGNED_FILE_MAX_TTL_SECONDS (7 days).

async def write_many(files: Mapping[str, bytes],
*,
atomic: bool = False) -> BulkWriteResult

Write several files in one request, optionally atomically per file.

async def upload_file(local_path: str | os.PathLike[str],
remote_path: str,
*,
on_progress: TransferProgressCallback | None = None,
cancel: TransferCancelSignal | None = None,
atomic: bool = False) -> None

Stream a local file into the sandbox without buffering it whole in memory.

async def download_file(remote_path: str,
local_path: str | os.PathLike[str],
*,
on_progress: TransferProgressCallback | None = None,
cancel: TransferCancelSignal | None = None) -> None
async def read_many(paths: Sequence[str]) -> BulkReadResult

Read multiple files, buffering each returned file in memory before returning.

Non-200 responses raise the typed SDK error inside the transport; only a 200 multipart body reaches the parser.

async def list(path: str, *, depth: Optional[int] = None) -> ListResult[FileInfo]

List directory entries as typed FileInfo rows (items, next_cursor).

async def stat(path: str) -> FileInfo

Return file metadata.

async def mkdir(path: str, *, mode: str = '755') -> None

Create a directory.

async def delete(path: str, *, recursive: bool = False) -> None

Delete a file or directory.

async def move(source: str, destination: str) -> None

Move or rename files.

async def find(path: str, pattern: str) -> ListResult

Find files under a path.

async def search(path: str, pattern: str) -> ListResult[str]

Search file contents.

async def replace(files: Sequence[str], pattern: str, new_value: str) -> ListResult

Replace text in files.

async def chmod(path: str,
*,
mode: Optional[str] = None,
owner: Optional[str] = None,
group: Optional[str] = None) -> None

Set file permissions and ownership.

async def watch_dir(path: str,
on_event: Optional[_WatchCallback] = None,
*,
recursive: bool = False,
on_overflow: Optional[_OverflowCallback] = None,
on_exit: Optional[_ExitCallback] = None) -> AsyncWatchHandle
class WatchHandle()

A running directory watch.

def __init__(impl: AsyncWatchHandle, bridge: SyncBridge) -> None
def attach_reader(reader: asyncio.Task[None]) -> None
def get_new_events() -> list[FilesystemEvent]
def record_callback_error(error: Exception) -> None
def record_exit(error: Exception | None) -> None
def record_overflow() -> None
def stop() -> None
def wait_for_exit() -> Exception | None
@property
def exit_error() -> Exception | None
@property
def last_callback_error() -> Exception | None
@property
def overflow_count() -> int
class AsyncWatchHandle()

A running directory watch.

Single-task, single-loop: the reader is one asyncio.Task and every method runs on the same loop, so the sync version’s five locks collapse to plain attributes. Only the exit event survives, because wait_for_exit genuinely waits.

def __init__(stream: _LineStream,
events: asyncio.Queue[FilesystemEvent],
on_exit: Optional[_ExitCallback] = None) -> None
@property
def overflow_count() -> int
def attach_reader(reader: asyncio.Task[None]) -> None
@property
def exit_error() -> Exception | None
@property
def last_callback_error() -> Exception | None
def record_callback_error(error: Exception) -> None
async def record_exit(error: Exception | None) -> None
def record_overflow() -> None
async def wait_for_exit() -> Exception | None
def get_new_events() -> list[FilesystemEvent]
async def stop() -> None
class FileInfo(BaseModel)

One filesystem entry as /files and /files/info serialize it.

Attributes:

  • group StrictStr = Field(description=‘Numeric group id rendered as a string.’)
  • is_dir StrictBool = Field(description=‘Whether the entry is a directory.’, alias=‘isDir’)
  • mod_time StrictStr = Field(description=‘Deprecated but load-bearing: Go time.String() layout for the last modification time.’, alias=‘modTime’)
  • mode StrictStr = Field(description=‘Go os.FileMode.String() layout (-rw-r--r--, drwxr-xr-x, …).’)
  • modified_at StrictStr = Field(description=‘RFC 3339 UTC timestamp for the last modification time.’, alias=‘modifiedAt’)
  • name StrictStr = Field(description=‘Base name of the entry.’)
  • owner StrictStr = Field(description=‘Numeric owner id rendered as a string.’)
  • path StrictStr = Field(description=“Absolute path to the entry, rendered in the guest’s path syntax.”)
  • permissions StrictStr = Field(description=‘Four-digit octal permissions (0644, 0755, …).’)
  • size Annotated[int, Field(strict=True, ge=0)] = Field(description=‘Entry size in bytes.’)
  • additional_properties Dict[str, Any] = {}
model_config = ConfigDict(populate_by_name=True, validate_assignment=True, protected_namespaces=())
def to_str() -> str

Returns the string representation of the model using alias

def to_json() -> str

Returns the JSON representation of the model using alias

@classmethod
def from_json(json_str: str) -> Optional[Self]

Create an instance of FileInfo from a JSON string

def to_dict() -> Dict[str, Any]

Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic’s self.model_dump(by_alias=True):

  • None is only added to the output dict for nullable fields that were set at model initialization. Other fields with value None are ignored.
  • Fields in self.additional_properties are added to the output dict.
@classmethod
def from_dict(obj: Optional[Dict[str, Any]]) -> Optional[Self]

Create an instance of FileInfo from a dict

class TransferCancelSignal(Protocol)

A cancellation signal for file transfers.

asyncio.Event and threading.Event both satisfy this protocol.

def is_set() -> bool
class FilesystemEventType(str, Enum)

Attributes:

  • CREATE ‘create’
  • WRITE ‘write’
  • REMOVE ‘remove’
  • RENAME ‘rename’
  • CHMOD ‘chmod’
@dataclass(frozen=True)
class SearchResult(Generic[T])

One page of GET /sandboxes/search (Daytona.search()).

total is exact when total_relation == "eq" and a lower bound when it is "gte" (the index caps exact counting at 10 000).

Attributes:

  • items List[T]
  • next_cursor Optional[str] = None
  • total int = 0
  • total_relation SearchTotalRelation = ‘eq’
  • raw_total_relation str = ‘eq’
@dataclass(frozen=True, slots=True)
class FilesystemEvent()

Attributes:

  • type FilesystemEventType
  • name str
  • is_dir bool
  • timestamp int
@dataclass(frozen=True)
class BulkWriteFile()

Attributes:

  • path str
  • bytes int
@dataclass(frozen=True)
class BulkWriteResult()

Attributes:

  • files List[BulkWriteFile]
  • errors List[str] = field(default_factory=list)
@dataclass(frozen=True)
class BulkReadError()

Attributes:

  • path str
  • message str
  • code Optional[str] = None
  • source Optional[str] = None
@dataclass(frozen=True)
class BulkReadResult()

Attributes:

  • files Dict[str, bytes]
  • errors List[BulkReadError] = field(default_factory=list)
@dataclass(frozen=True, kw_only=True)
class SearchSandboxesQuery(SandboxSearchFilters)

Every Daytona.search() parameter (GET /sandboxes/search); keyword-only.

Attributes:

  • name_prefix Optional[str] = None
  • id_prefix Optional[str] = None
  • cursor Optional[str] = None
  • limit Optional[int] = None
SIGNED_FILE_MAX_TTL_SECONDS = 604800
TransferProgressCallback = Callable[[int, Optional[int]], None]
SearchTotalRelation = Literal['eq', 'gte', 'unknown']
SearchSort = Literal['created_at', 'updated_at', 'last_activity_at', 'name', 'vcpus', 'memory_mib', 'disk_mib']
SearchOrder = Literal['asc', 'desc']
SearchTimestamp = Union[str, datetime]

An RFC 3339 string, or a datetime (naive values are taken as UTC).