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

# Activate and Deactivate

> Allow or block new sandboxes from a snapshot without deleting it

Deactivate a snapshot when you want to keep it but stop new creates. Activate it again when you are ready to use it.

Sandboxes that already started from the snapshot keep running.

## Deactivate

`POST /v1/agents/snapshots/{id}/deactivate`

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from gravixlayer import GravixLayer

  client = GravixLayer()  # defaults to cloud="aws", region="us-east-1"

  snap = client.snapshots.deactivate("after-warmup")
  print(snap.state, snap.is_active)  # inactive, False
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { GravixLayer } from 'gravixlayer';

  const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"

  const snap = await client.snapshots.deactivate("after-warmup");
  console.log(snap.state, snap.isActive); // inactive, false
  ```

  ```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark"}}
  gravixlayer snapshot deactivate after-warmup
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  # Requires: GRAVIXLAYER_API_KEY
  API="https://api.gravixlayer.ai/v1"

  curl -sS -X POST "$API/agents/snapshots/after-warmup/deactivate" \
    -H "Authorization: Bearer $GRAVIXLAYER_API_KEY"
  ```
</CodeGroup>

Creating a sandbox from an inactive snapshot fails.

## Activate

`POST /v1/agents/snapshots/{id}/activate`

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from gravixlayer import GravixLayer

  client = GravixLayer()  # defaults to cloud="aws", region="us-east-1"

  snap = client.snapshots.activate("after-warmup")
  print(snap.state, snap.is_active)  # active, True

  sandbox = client.runtime.create(snapshot="after-warmup")
  sandbox.kill()
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { GravixLayer } from 'gravixlayer';

  const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"

  const snap = await client.snapshots.activate("after-warmup");
  console.log(snap.state, snap.isActive); // active, true

  const sandbox = await client.runtime.create({ snapshot: 'after-warmup' }); // defaults to template="base-small"
  await sandbox.kill();
  ```

  ```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark"}}
  gravixlayer snapshot activate after-warmup
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  # Requires: GRAVIXLAYER_API_KEY
  API="https://api.gravixlayer.ai/v1"

  curl -sS -X POST "$API/agents/snapshots/after-warmup/activate" \
    -H "Authorization: Bearer $GRAVIXLAYER_API_KEY"
  ```
</CodeGroup>

You can pass the snapshot ID or name on both routes.
