> ## Documentation Index
> Fetch the complete documentation index at: https://docs.buntime.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# List Files

> List all files in a session

## Request

<ParamField query="sessionId" type="string" required>
  Session ID to list files from
</ParamField>

<ParamField query="path" type="string" optional>
  Directory path to list (default: /workspace root)
</ParamField>

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

## Response

<ResponseField name="files" type="array">
  Array of file objects

  <Expandable title="file object">
    <ResponseField name="path" type="string">
      File path relative to /workspace
    </ResponseField>

    <ResponseField name="size" type="integer">
      File size in bytes
    </ResponseField>

    <ResponseField name="modified" type="string">
      ISO 8601 timestamp of last modification
    </ResponseField>

    <ResponseField name="type" type="string">
      "file" or "directory"
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.buntime.sh/files/list?sessionId=ses_abc123" \
    -H "Authorization: Bearer $BUNTIME_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  const files = await client.files.list({
    sessionId: 'ses_abc123'
  });

  files.forEach(file => {
    console.log(file.path, file.size);
  });
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "files": [
      {
        "path": "hello.ts",
        "size": 29,
        "modified": "2024-01-19T10:30:00Z",
        "type": "file"
      },
      {
        "path": "data.json",
        "size": 156,
        "modified": "2024-01-19T10:31:00Z",
        "type": "file"
      }
    ]
  }
  ```
</ResponseExample>
