---
title: "Read a file or list a directory"
method: GET
path: "/sandboxes/{id}/files"
tags: ["Files"]
---

# Read a file or list a directory

`GET /sandboxes/{id}/files`

## Request

- Base URL: `https://sandbox-as-a-service.com/v1`
- URL: `https://sandbox-as-a-service.com/v1/sandboxes/{id}/files`
- Auth: HTTP bearer

With `path` pointing at a file, returns its contents. With no `path`, or with `list=true`, returns a directory listing. Use `encoding=base64` to read binary files.

## Query parameters

- `path` string
- `encoding` 'utf8' | 'base64'
- `list` boolean

## Response `200`

The file contents, or a directory listing.

- union
  - object
    - `object` 'file'
    - `path` string
    - `bytes` integer
    - `encoding` string
    - `content` string
  - object
    - `object` 'list'
    - `path` string
    - `entries` object[]
      - `name` string
      - `type` 'file' | 'dir' | 'symlink'
      - `size_bytes` integer, nullable
    - `truncated` boolean: True when the tree was larger than 2000 entries or 12 levels and the listing was cut short. Never treat a truncated listing as a complete one.

## Other responses

- `404`: No such file, or no sandbox with that id.
- `409`: Sandbox is not running.
- `413`: File exceeds the read limit.

---

[API](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api.md) · [All operations](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/revisions/4f1ea2cf8333?raw)
