Files
e2b-dev--e2b/packages/cli/tests
devin-ai-integration[bot] 8787dfec9b feat(sdk,cli): add sandbox list sorting and filters (#1735)
## Summary

SDK follow-up to the merged API change (e2b-dev/belt#1713) that added
`order`, `startedAfter`, and `template` to `GET /v2/sandboxes`; the
earlier SDK PR for this was closed unfinished. The generated API clients
already had the parameters — this wires them through the public
`Sandbox.list` surface in JS and both Python SDKs (sync + async), plus
the `e2b sandbox list` CLI command, so ordering and filtering happen
server-side across the whole paginated dataset instead of per loaded
page.

New options (mirrored across all three SDK surfaces):
- `order: 'asc' | 'desc'` (default `'desc'`, newest first) — sorts by
sandbox start time; exposed as `SandboxListOrder`
- `query.startedAfter` / `SandboxQuery.started_after` — inclusive lower
bound on start time
- `query.template` / `SandboxQuery.template` — exact template ID or
alias (unknown template ⇒ empty list)

### Usage

JavaScript:
```ts
const paginator = Sandbox.list({
  query: {
    metadata: { env: 'ci' },
    startedAfter: new Date(Date.now() - 60 * 60 * 1000),
    template: 'base',
  },
  order: 'asc',
})
const sandboxes = await paginator.nextItems()
```

Python (sync; async is identical with `AsyncSandbox` / `await`):
```python
paginator = Sandbox.list(
    query=SandboxQuery(
        metadata={"env": "ci"},
        started_after=datetime.now(timezone.utc) - timedelta(hours=1),
        template="base",
    ),
    order="asc",
)
sandboxes = paginator.next_items()
```

CLI:
```sh
e2b sandbox list --template base --started-after 2025-01-01T00:00:00Z --order desc
```
The CLI table respects `--order` when rendering (previously it always
re-sorted ascending by start time; that remains the default).

Includes integration tests for order, `startedAfter`, and template
filtering in JS and both Python test suites, a unit test for CLI table
ordering, plus a minor changeset for `e2b`, `@e2b/python-sdk`, and
`@e2b/cli`.

Link to Devin session:
https://app.devin.ai/sessions/44dcb4b0ca9143b8b023ef6fb8554c72
Requested by: @mishushakov

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: mish@e2b.dev <mish@e2b.dev>
2026-08-21 14:19:41 +02:00
..