> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.xapi.to/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.xapi.to/_mcp/server.

# 列出可用规格

GET https://sandbox.xapi.to/v1/offerings

返回当前供应商声明的资源、能力、生命周期与估算价格。该接口不创建资源。

Reference: https://docs.xapi.to/sandbox/api-reference/discovery/list-offerings

## Servers

- `https://sandbox.xapi.to` (Production, default)
- `https://sandbox.test.xapi.to` (Test)

## Response

### 200

可用规格列表

- `list of Offering`

## Types

### Offering

可创建 Sandbox 的实时规格、能力、生命周期和计费声明。

- `id` (string, required) — offering 的稳定 UUID；可用于 selection.offeringId 固定选型。
- `name` (string, required) — 面向用户展示的规格名称。
- `resources` (ResourceSnapshot, required) — 该规格默认分配和计费使用的资源快照。
- `capabilities` (SandboxCapabilities, required) — 可用的标准能力、扩展 ID 和暂停语义。
- `description` (string, optional, nullable) — 规格用途和供应商适配说明。
- `region` (string, optional, nullable) — 默认/固定区域；null 表示区域由供应商自动选择或未固定。
- `lifecycle` (OfferingLifecycle, optional) — 规范化生命周期声明。
- `billing` (OfferingBilling, optional) — 按状态计算的预估小时费用摘要。
- `rateCard` (RateCard, optional) — 用于实际预留和结算的费率规则。
- `rateCardVersion` (integer, optional) — 数据库中的 offering 费率修订号；变更后旧 quote 可能失效。
- `rollingWindowSeconds` (integer, optional) — 每次预留的滚动用量窗口长度（秒）；不是实例最大运行时间。
- `shutdownGraceSeconds` (integer, optional) — 为安全销毁预留的关机宽限时长（秒）。
- `retentionWindowSeconds` (integer, optional) — 终态数据/供应商资源的声明保留窗口（秒）；不等于文件永久保留承诺。
- `provider` (ProviderSummary, optional) — 提供该规格的服务商展示信息。

### ResourceSnapshot

实例实际分配或 offering 声明的资源快照；供应商可以附加扩展资源字段。

- `cpu` (double, optional) — vCPU 数量。
- `memoryGiB` (double, optional) — 内存容量，单位 GiB。
- `volumeGiB` (double, optional) — 工作卷/持久卷容量，单位 GiB。
- `snapshotGiB` (double, optional) — 快照存储容量或计费基数，单位 GiB。
- `gpu` (list of ResourceSnapshotGpuItems, optional) — 分配的 GPU 型号与数量；CPU-only offering 通常省略。
- `environment` (map from string to any, optional) — 供应商返回的运行环境快照，例如镜像、语言或框架信息。

### SandboxCapabilities

offering 对标准 Sandbox 能力和供应商扩展的声明；调用能力接口前应检查对应布尔值。

- `exec` (boolean, optional) — 是否支持执行 Shell 命令。
- `backgroundExec` (boolean, optional) — 是否支持 background=true，在 HTTP 响应后继续保留供应商托管的后台命令会话；启动 Web 服务前应检查此字段。
- `files` (boolean, optional) — 是否支持文件读取、写入和目录枚举。
- `terminal` (boolean, optional) — 是否支持交互式终端能力；REST command 接口仍以 exec 为准。
- `ports` (boolean, optional) — 是否支持把实例内监听端口映射为外部访问地址。
- `snapshot` (boolean, optional) — 是否支持快照相关能力；具体调用方式可能由扩展提供。
- `fork` (boolean, optional) — 是否支持从现有实例/快照派生新实例。
- `gpu` (boolean, optional) — 是否提供 GPU 资源；仍需核对 resources.gpu 和具体扩展。
- `extensionIds` (list of string, optional) — 允许调用的供应商扩展 ID 白名单；不要调用列表之外的扩展。
- `suspension` (SuspensionCapabilities, optional) — 规范化后的暂停、恢复和自动唤醒能力。

### OfferingLifecycle

offering 的生命周期能力与状态保留语义。

- `suspension` (SuspensionCapabilities, optional) — 暂停状态支持、恢复方式、保留内容和暂停时预估费用。

### OfferingBilling

根据当前 rate card 和资源计算出的各状态预估费用摘要；最终费用以实例 totalCost 为准。

- `currency` (enum, optional) — 所有价格和费用字段使用的货币。
  - Allowed values: `USD`
- `estimatedHourlyUsdByState` (map from string to string, optional) — 按 PROVISIONING、RUNNING、SUSPENDED 等状态给出的每小时预估费用，值为 USD 十进制字符串。
- `computeDefaultState` (enum, optional) — 默认产生计算资源费用的状态。
  - Allowed values: `RUNNING`
- `storageContinuesWhileSuspended` (boolean, optional) — 暂停时是否仍存在卷/快照等存储费用；false 不代表所有其他费用必然为零。

### RateCard

服务端用于预留和结算费用的费率快照。

- `version` (enum, required) — rate card 数据格式版本。
  - Allowed values: `1`, `2`
- `currency` (enum, required) — 费率货币。
  - Allowed values: `USD`
- `components` (list of RateCardComponent, required) — 组成总费用的计费规则列表。

### ProviderSummary

实际提供该 offering 的 Sandbox 服务商展示信息。

- `name` (string, optional) — 服务商名称。
- `logoUrl` (string, optional, nullable) — 服务商 Logo URL；未配置时为 null。

### ResourceSnapshotGpuItems

- `model` (string, optional) — GPU 型号。
- `count` (integer, optional) — 该型号 GPU 数量。

### SuspensionCapabilities

offering 的暂停、恢复和访问时唤醒语义；不要从 supported 推断文件、内存和进程都保留。

- `supported` (boolean, required) — 是否支持显式 suspend 操作。
- `preservesFilesystem` (boolean, optional) — 暂停后恢复时工作区文件是否保留。
- `preservesMemory` (boolean, optional) — 暂停后恢复时内存内容是否保留。
- `preservesProcesses` (boolean, optional) — 暂停后恢复时原进程是否继续存在。
- `capacityReserved` (boolean, optional) — 暂停期间供应商是否仍为该实例保留计算容量；可能影响费用和恢复速度。
- `resumeSupported` (boolean, optional) — 暂停后是否支持显式 resume。
- `resumeOnAccessSupported` (boolean, optional) — 是否支持访问 exec/files/ports 时自动恢复。
- `resumeOnAccessMode` (enum, optional) — NATIVE=供应商原生唤醒；ADAPTER=xAPI 适配器先恢复再执行；UNSUPPORTED=不可用。
  - Allowed values: `NATIVE`, `ADAPTER`, `UNSUPPORTED`
- `wakeOperations` (list of string, optional) — 可以触发访问时唤醒的操作名，例如 exec、files.read、ports.connect。
- `estimatedHourlyUsd` (string, optional) — 实例处于 SUSPENDED 时的预估小时费用，USD 十进制字符串。

### RateCardComponent

一条计费规则；具体计费基数由 kind 决定。

- `kind` (enum, required) — STATE_TIME=按实例状态时长；RESOURCE_TIME=按资源数量和时长；OPERATION=按调用次数。
  - Allowed values: `STATE_TIME`, `RESOURCE_TIME`, `OPERATION`
- `unit` (enum, required) — 计费单位；时长规则为 SECOND，调用规则为 COUNT。
  - Allowed values: `SECOND`, `COUNT`
- `priceUsd` (string, required) — 每单位价格，USD 十进制字符串。
- `state` (enum, optional) — 该规则适用的实例状态；OPERATION 规则通常省略。
  - Allowed values: `PROVISIONING`, `RUNNING`, `SUSPENDED`, `TERMINATED`, `FAILED`, `UNKNOWN`
- `category` (enum, optional) — 费用分类，用于账单归类。
  - Allowed values: `COMPUTE`, `CAPACITY_RESERVATION`, `STORAGE`, `OTHER`
- `resource` (enum, optional) — RESOURCE_TIME 规则计费的资源类型。
  - Allowed values: `CPU`, `MEMORY_GIB`, `VOLUME_GIB`, `SNAPSHOT_GIB`, `GPU`
- `resourceKey` (string, optional) — 细分资源键，例如具体 GPU 型号；普通 CPU/内存规则通常省略。
- `operation` (string, optional) — OPERATION 规则计费的操作名。

## Examples

**Response**

```json
[
  {
    "id": "11111111-1111-4111-8111-111111111111",
    "name": "General purpose Sandbox",
    "resources": {
      "cpu": 1,
      "memoryGiB": 1,
      "volumeGiB": 3,
      "snapshotGiB": 0
    },
    "capabilities": {
      "exec": true,
      "files": true,
      "ports": true,
      "snapshot": true
    },
    "description": "Isolated CPU Sandbox with shell, files and ports",
    "region": null,
    "lifecycle": {
      "suspension": {
        "supported": true,
        "preservesFilesystem": true
      }
    },
    "billing": {
      "currency": "USD",
      "estimatedHourlyUsdByState": {
        "RUNNING": "0.07693488"
      }
    },
    "rollingWindowSeconds": 300,
    "shutdownGraceSeconds": 30,
    "retentionWindowSeconds": 600,
    "provider": {
      "name": "Example Sandbox Provider",
      "logoUrl": null
    }
  }
]
```

**SDK Code**

```python
import requests

url = "https://sandbox.xapi.to/v1/offerings"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://sandbox.xapi.to/v1/offerings';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox.xapi.to/v1/offerings"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox.xapi.to/v1/offerings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://sandbox.xapi.to/v1/offerings")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://sandbox.xapi.to/v1/offerings');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://sandbox.xapi.to/v1/offerings");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.xapi.to/v1/offerings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```