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

# Stream file modification events in a directory

> Streams change events for a directory until the client disconnects.

The body is JSON lines (sent with `Content-Type: text/plain`): one event object per line, e.g. `{"op":"WRITE","name":"main.go","path":"/app/src","error":null}`. `op` is the fsnotify operation (CREATE, WRITE, REMOVE, RENAME or CHMOD, several can be joined with `|`), `name` the base name of the changed entry, `path` the directory containing it, and `error` is always null. A `[keepalive]` line (not JSON) is sent every 30 seconds.
Only the directory's direct entries are watched. To also watch every subdirectory, including ones created later, end the path with `/**`. The stream reports subsequent changes without an initial snapshot. When a new directory is detected, synthetic CREATE events are emitted for entries already present inside it to cover changes before its watch was registered.



## OpenAPI

````yaml /reference/sandbox-api/openapi.json get /watch/filesystem/{path}
openapi: 3.0.0
info:
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  contact: {}
  version: 0.0.1
servers:
  - url: https://{sandbox_host}
    description: >-
      Host from the sandbox's returned url, without the scheme or trailing
      slash.
    variables:
      sandbox_host:
        default: sandbox.example.com
security:
  - BearerAuth: []
paths:
  /watch/filesystem/{path}:
    get:
      tags:
        - filesystem
      summary: Stream file modification events in a directory
      description: >-
        Streams change events for a directory until the client disconnects.


        The body is JSON lines (sent with `Content-Type: text/plain`): one event
        object per line, e.g.
        `{"op":"WRITE","name":"main.go","path":"/app/src","error":null}`. `op`
        is the fsnotify operation (CREATE, WRITE, REMOVE, RENAME or CHMOD,
        several can be joined with `|`), `name` the base name of the changed
        entry, `path` the directory containing it, and `error` is always null. A
        `[keepalive]` line (not JSON) is sent every 30 seconds.

        Only the directory's direct entries are watched. To also watch every
        subdirectory, including ones created later, end the path with `/**`. The
        stream reports subsequent changes without an initial snapshot. When a
        new directory is detected, synthetic CREATE events are emitted for
        entries already present inside it to cover changes before its watch was
        registered.
      parameters:
        - description: >-
            Comma-separated substrings; events whose full path contains one are
            skipped
          name: ignore
          in: query
          schema:
            type: string
        - description: Directory path to watch (append /** to watch subdirectories)
          name: path
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: JSON lines stream of change events
          content:
            text/plain:
              schema:
                type: string
        '400':
          description: Invalid path
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Error message
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Sandbox access token created through POST /v1/token.

````