# Snapshots

> The SDK methods that save a stopped sandbox's files as a snapshot and manage snapshots, in TypeScript and Python.

Source: https://useshards.com/docs/reference/sdks/snapshots/

## shard.snapshots.create

Save a stopped sandbox's files as a snapshot.

**TypeScript**

```ts
shard.snapshots.create(sandbox: SandboxRef, options?: { name?: string }): Promise<Snapshot>
```

**Python**

```python
shard.snapshots.create(sandbox, *, name=None) -> Snapshot
```

**Examples**

**TypeScript**

```ts
await web.stop();
const base = await shard.snapshots.create(web, { name: "web-base" });
const copy = await shard.create({ snapshot: "web-base", name: "web-2" });
```

**Python**

```python
web.stop()
base = shard.snapshots.create(web, name="web-base")
copy = shard.create(snapshot="web-base", name="web-2")
```

**Arguments**

| Argument | Description |
| --- | --- |
| `sandbox` | source sandbox, as a `Sandbox` or its ID, ID prefix or name |

**Options**

| TypeScript | Python | Description |
| --- | --- | --- |
| `name` | `name` | snapshot name to use instead of its ID |

Stop the sandbox first. Snapshots contain files, not memory or process state. They remain available after the source sandbox is removed. A provider without snapshots raises `UnsupportedError`.

To start a sandbox from one, pass `snapshot` to [`shard.create`](https://useshards.com/docs/reference/sdks/sandboxes/#shardcreate). The rules for that create are in the [CLI reference](https://useshards.com/docs/reference/cli/snapshots/#create-a-sandbox-from-a-snapshot).

## shard.snapshots.list

List snapshots.

**TypeScript**

```ts
shard.snapshots.list(): Promise<Snapshot[]>
```

**Python**

```python
shard.snapshots.list() -> list[Snapshot]
```

**Examples**

**TypeScript**

```ts
for (const snapshot of await shard.snapshots.list()) console.log(snapshot.name, snapshot.image, snapshot.size);
```

**Python**

```python
for snapshot in shard.snapshots.list():
    print(snapshot.name, snapshot.image, snapshot.size)
```

## shard.snapshots.inspect

Return one snapshot.

**TypeScript**

```ts
shard.snapshots.inspect(ref: string): Promise<Snapshot>
```

**Python**

```python
shard.snapshots.inspect(ref) -> Snapshot
```

**Examples**

**TypeScript**

```ts
const base = await shard.snapshots.inspect("web-base");
```

**Python**

```python
base = shard.snapshots.inspect("web-base")
```

**Arguments**

| Argument | Description |
| --- | --- |
| `ref` | snapshot ID or name |

A `Snapshot` holds `id`, `name`, the source sandbox's ID and name, `image`, `digest`, `provider`, the disk and memory bounds the source ran under, `size`, the bytes it takes on the host, and the creation time.

## shard.snapshots.remove

Delete a snapshot and its files.

**TypeScript**

```ts
shard.snapshots.remove(ref: string): Promise<void>
```

**Python**

```python
shard.snapshots.remove(ref) -> None
```

**Examples**

**TypeScript**

```ts
await shard.snapshots.remove("web-base");
```

**Python**

```python
shard.snapshots.remove("web-base")
```

**Arguments**

| Argument | Description |
| --- | --- |
| `ref` | snapshot ID or name |

Sandboxes created from the snapshot keep their own files.
