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

# レガシー Sandbox Snapshot Template

export const SandboxBetaVersionWarning = () => {
  if (typeof document === "undefined") {
    return null;
  } else {
    return <Warning>The following legacy features require the legacy SDK and CLI versions listed in <Link href="/docs/ja/guides/sandbox-legacy-e2b-compatible" target="self">Legacy SDKs & CLI</Link>. Please note that legacy features may be less stable than production releases. If you encounter any issues while using these features, please <Link href="https://meetings-na2.hubspot.com/junyu" target="_blank">contact us</Link>.</Warning>;
  }
};

<Warning>
  このレガシーページは、まだ 1.x または beta SDK ラインを使用しているユーザー向けに保持されています。新しい SDK 2.x 統合では、現在の Sandbox ドキュメントに従ってください。
</Warning>

<SandboxBetaVersionWarning />

## 用語

* **Commit**: コミット操作は、サンドボックスの現在の状態をテンプレートとして保存し、snapshot template タイプの新しいテンプレートを生成します。
* **Origin Sandbox**: コミット対象のサンドボックスインスタンス。
* **Snapshot Template**: コミット操作後に生成されるテンプレート。

## 機能説明

### 実行中のサンドボックスをコミットする

**コミット処理中:**

* コミット中、元サンドボックスは短時間サスペンドされます。
* サスペンド中、サンドボックスインスタンスは利用できません。
* サスペンド時間は、1 回の pause 操作に必要な時間に近いです。

**コミット完了後:**

**元サンドボックス:**

* 既存の pause レコードは、現在のサンドボックス状態に基づいて新しい pause レコードに更新されます。
* 元サンドボックスは引き続き実行されます。
* 新しいテンプレートレコードが生成されます。

### 一時停止中のサンドボックスをコミットする

**コミット処理中:**

* コミット処理によって元サンドボックスが起動されることはありません。
* 元サンドボックスは一時停止状態のままです。

**コミット完了後:**

**元サンドボックス:**

* 既存の pause レコードはクリアされません。
* 新しいテンプレートレコードが生成されます。

## パラメーター説明

| パラメーター       | 型        | 必須  | 説明                      |
| ------------ | -------- | --- | ----------------------- |
| `sandbox_id` | `string` | はい  | コミットするサンドボックスインスタンスの ID |
| `alias`      | `string` | いいえ | 生成されるテンプレートにエイリアスを設定します |

## 戻り値

コミット操作が成功すると、`Template` オブジェクトが返されます。

## コード例

<CodeGroup>
  ```python Python icon="python" theme={"system"}
  from novita_sandbox.core import Sandbox

  # Commit an existing sandbox by ID to create a template snapshot
  # sandbox_id: str - Required. The ID of the sandbox to commit
  # alias: Optional[str] - Optional alias name for the created template
  # Note: Default timeout is 10 minutes for commit operation
  template = Sandbox.commit(
      sandbox_id="existing-sandbox-id",
      alias="my-template-alias"
  )
  print(f"Template ID: {template.template_id}")
  print(f"Build ID: {template.build_id}")
  ```

  ```js TypeScript icon="js" theme={"system"}
  import { Sandbox } from '@novita-sandbox/core'

  // Commit an existing sandbox by ID to create a template snapshot
  // sandboxId: string - Required. The ID of the sandbox to commit
  // opts?: { alias?: string } - Optional commit options
  const template = await Sandbox.commit('existing-sandbox-id', {
    alias: 'my-template-alias'
  })
  console.log(`Template ID: ${template.templateId}`)
  console.log(`Build ID: ${template.buildId}`)
  ```
</CodeGroup>

さらに、Novita Sandbox CLI を使用して、指定したサンドボックスインスタンスをコミットすることもできます。

```bash Bash icon="terminal" theme={"system"}
# Basic commit - creates a template snapshot from a sandbox
novita-sandbox-cli sandbox commit <sandboxID>

# Commit with alias - assign a friendly name to the template
novita-sandbox-cli sandbox commit <sandboxID> --alias my-template-alias

```
