> ## Documentation Index
> Fetch the complete documentation index at: https://e2b-mintlify-changelog-1774264263.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# WatchDir

> Server-streaming RPC. Use the Connect protocol with streaming support.



## OpenAPI

````yaml /openapi-public.yml post /filesystem.Filesystem/WatchDir
openapi: 3.1.0
info:
  title: E2B API
  version: 0.1.0
  description: >-
    Complete E2B developer API. Platform endpoints are served on api.e2b.app.
    Sandbox endpoints (envd) are served on {port}-{sandboxID}.e2b.app.
servers:
  - url: https://api.e2b.app
    description: E2B Platform API
security: []
tags:
  - name: Sandboxes
  - name: Templates
  - name: Tags
  - name: Envd
  - name: Filesystem
  - name: Process
  - name: Teams
paths:
  /filesystem.Filesystem/WatchDir:
    servers:
      - url: https://{port}-{sandboxID}.e2b.app
        description: Sandbox API (envd) — runs inside each sandbox
        variables:
          port:
            default: '49983'
            description: Port number
          sandboxID:
            default: $SANDBOX_ID
            description: Sandbox identifier
    post:
      tags:
        - Filesystem
      summary: WatchDir
      description: Server-streaming RPC. Use the Connect protocol with streaming support.
      operationId: filesystem.Filesystem.WatchDir
      parameters:
        - name: Connect-Protocol-Version
          in: header
          required: true
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
        - name: Connect-Timeout-Ms
          in: header
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
      requestBody:
        content:
          application/connect+json:
            schema:
              $ref: '#/components/schemas/filesystem.WatchDirRequest'
        required: true
      responses:
        '200':
          description: Stream of WatchDirResponse events
          content:
            application/connect+json:
              schema:
                $ref: '#/components/schemas/filesystem.WatchDirResponse'
        '502':
          description: Sandbox not found
          content:
            application/json:
              schema:
                type: object
                required:
                  - sandboxID
                  - message
                  - code
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: integer
                    description: Error code
                  sandboxID:
                    type: string
                    description: Identifier of the sandbox
      security:
        - SandboxAccessTokenAuth: []
components:
  schemas:
    connect-protocol-version:
      type: number
      title: Connect-Protocol-Version
      description: Define the version of the Connect protocol
      const: 1
    connect-timeout-header:
      type: number
      title: Connect-Timeout-Ms
      description: Define the timeout, in ms
    filesystem.WatchDirRequest:
      type: object
      properties:
        path:
          type: string
          title: path
        recursive:
          type: boolean
          title: recursive
      title: WatchDirRequest
      additionalProperties: false
    filesystem.WatchDirResponse:
      type: object
      oneOf:
        - properties:
            filesystem:
              $ref: '#/components/schemas/filesystem.FilesystemEvent'
              title: filesystem
          title: filesystem
          required:
            - filesystem
        - properties:
            keepalive:
              $ref: '#/components/schemas/filesystem.WatchDirResponse.KeepAlive'
              title: keepalive
          title: keepalive
          required:
            - keepalive
        - properties:
            start:
              $ref: '#/components/schemas/filesystem.WatchDirResponse.StartEvent'
              title: start
          title: start
          required:
            - start
      title: WatchDirResponse
      additionalProperties: false
    filesystem.FilesystemEvent:
      type: object
      properties:
        name:
          type: string
          title: name
        type:
          $ref: '#/components/schemas/filesystem.EventType'
          title: type
      title: FilesystemEvent
      additionalProperties: false
    filesystem.WatchDirResponse.KeepAlive:
      type: object
      title: KeepAlive
      additionalProperties: false
    filesystem.WatchDirResponse.StartEvent:
      type: object
      title: StartEvent
      additionalProperties: false
    filesystem.EventType:
      type: string
      title: EventType
      enum:
        - EVENT_TYPE_UNSPECIFIED
        - EVENT_TYPE_CREATE
        - EVENT_TYPE_WRITE
        - EVENT_TYPE_REMOVE
        - EVENT_TYPE_RENAME
        - EVENT_TYPE_CHMOD
  securitySchemes:
    SandboxAccessTokenAuth:
      type: apiKey
      in: header
      name: X-Access-Token
      description: >-
        Sandbox access token (`envdAccessToken`) for authenticating requests to
        a running sandbox. Returned by: [POST
        /sandboxes](/docs/api-reference/sandboxes/create-a-sandbox) (on create),
        [POST
        /sandboxes/{sandboxID}/connect](/docs/api-reference/sandboxes/connect-to-a-sandbox)
        (on connect), [POST
        /sandboxes/{sandboxID}/resume](/docs/api-reference/sandboxes/resume-a-sandbox)
        (on resume), and [GET
        /sandboxes/{sandboxID}](/docs/api-reference/sandboxes/get-a-sandbox)
        (for running or paused sandboxes).

````