Skip to main content
You can watch a directory in the sandbox for filesystem events (file created, written, removed, renamed, or permission changed). The JS/TS SDK and the Python async SDK use a callback model, while the Python sync SDK uses a polling model - both return a WatchHandle that you stop with stop().

Event object & event types

Each filesystem event is a FilesystemEvent with two fields: The type is one of the FilesystemEventType values:

Watch a directory (JavaScript / TypeScript)

watchDir(path, onEvent, opts?) starts watching and invokes onEvent for each event. It returns a WatchHandle; call stop() to stop watching.
JavaScript & TypeScript

Watch a directory (Python)

The Python sync SDK uses a polling model: watch_dir(path, recursive=False) returns a WatchHandle, and you call get_new_events() to pull the events that occurred since the last call. Stop with stop().
Python
The Python async SDK uses a callback model instead: pass an on_event callback to watch_dir, which returns an AsyncWatchHandle. Stop with await handle.stop().
Python
Note: Recursive watching (recursive=True) requires an up-to-date template. If the template is too old, the SDK raises a template error asking you to rebuild it with novita-sandbox-cli template build.
Last modified on August 5, 2026