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

# Watch for file changes via SSE

> Server-sent event stream. Opens with one snapshot event whose data is {files: string[], path} (an ls -R listing of the watched directory), then a change event…

### Path parameters

<ParamField path="id" type="string (uuid)" required>
  Sandbox identifier
</ParamField>

### Query parameters

<ParamField query="path" type="string">
  Directory to watch (default /workspace)
</ParamField>

### Response

Returns `text/event-stream` — Server-sent event stream. Opens with one `snapshot` event whose data is `&#123;files: string[], path&#125;` (an `ls -R` listing of the watched directory), then a `change` event with `&#123;added: string[], removed: string[]&#125;` whenever the listing differs on the 5-second poll, with `: heartbeat` comments every 15s.

### Status codes

| Code  | Meaning                                                                                                                                                                                                                                                                                                                          |
| ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200` | Server-sent event stream. Opens with one `snapshot` event whose data is `&#123;files: string[], path&#125;` (an `ls -R` listing of the watched directory), then a `change` event with `&#123;added: string[], removed: string[]&#125;` whenever the listing differs on the 5-second poll, with `: heartbeat` comments every 15s. |
| `404` | Sandbox not found                                                                                                                                                                                                                                                                                                                |

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.sandbox.stateset.app/api/v1/sandbox/{id}/files/watch' \
    --header "Authorization: Bearer $STATESET_SANDBOX_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  "string"
  ```
</ResponseExample>
