# Tài liệu tham chiếu API: Lưu trữ

Lưu trữ: mọi thao tác của API v1 kèm scope cần có, tham số, ví dụ bằng curl, JavaScript và Python, cùng phản hồi. Xác thực, lỗi, phân trang, giới hạn tốc độ và tính idempotent nằm trong [tổng quan tài liệu API](/docs/api-reference); xem thêm [SDK](/docs/sdks) và [dòng lệnh](/docs/cli).

> Thử với khóa của bạn: tạo khóa API trong bảng điều khiển, chạy `export APIDLY_API_KEY=...` trong terminal rồi dán một ví dụ curl bên dưới. Giá trị trong ví dụ chỉ mang tính minh họa. Trang này không có ô nhập khóa.

Mô tả của các thao tác và trường lấy từ định nghĩa API và giữ nguyên tiếng Anh.

| Thao tác | Scope cần có | Tóm tắt |
| --- | --- | --- |
| `GET /volumes` | `read` | Ổ đĩa bền vững |
| `POST /volumes` | `full` | Tạo ổ đĩa |
| `GET /volumes/options` | `read` | Giá ổ đĩa cho một gói GPU |
| `GET /volumes/offers` | `read` | Deprecated alias of GET /volumes/options |
| `GET /volumes/{id}/availability` | `read` | Máy chủ dùng ổ đĩa này có khởi động ngay được không |
| `GET /volumes/{id}` | `read` | Một ổ đĩa |
| `PATCH /volumes/{id}` | `full` | Đổi tên một ổ đĩa |
| `DELETE /volumes/{id}` | `full` | Xóa ổ đĩa (`?confirm=` tên của nó) |
| `GET /transfers` | `read` | Chuyển dữ liệu, mới nhất trước |
| `POST /transfers` | `servers` | Sao chép dữ liệu giữa các máy chủ |
| `GET /transfers/{id}` | `read` | Một lượt chuyển |
| `DELETE /transfers/{id}` | `full` | Hủy một lượt chuyển đang chạy |
| `GET /volumes/fit` | `read` | Các ổ lưu trữ trống mà máy chủ của gói này gắn được |

### GET /volumes

Ổ đĩa bền vững

Mount one by passing `volumeId` (and optionally `volumeMountPath`) when you request a server with `POST /deployments`.

**Scope cần có:** `read` · **Quyền:** `servers.view`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | không |  |
| `cursor` | query | string | không |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes?limit=20" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.list({ limit: 20 });
```

**Python (SDK)**

```python
client.volumes.list()
```

**Công cụ dòng lệnh:** `apidly volumes`, `apidly export`, `apidly plan`, `apidly apply` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "volumes": [
    {
      "id": "example",
      "name": "example",
      "sizeGb": 1,
      "status": "example",
      "instanceId": "id_example",
      "region": "South Korea",
      "regionCode": "KR",
      "planId": "id_example",
      "hourlyPriceMicros": "1000000",
      "hourlyPriceUsd": "1.000000",
      "scheduledDeletionAt": "2026-11-21T10:00:00.000Z",
      "attachable": false,
      "legacy": false,
      "createdAt": "2026-11-21T10:00:00.000Z"
    }
  ],
  "limits": {
    "minGb": 1,
    "maxGb": 1
  },
  "nextCursor": "example"
}
```

Trạng thái lỗi: `401`, `403`, `429`.

### POST /volumes

Tạo ổ đĩa

A volume lives on one machine and only a server on that machine can mount it. Send the `planId` of the GPU plan you will use and the `shownHourlyMicros` from `GET /volumes/options?planId=`: the volume is created on a machine that offers that plan right now, and every server that mounts it runs there. Billed per second from creation until it is deleted; the balance must cover its first day (402). Refused when the price rose (409 `price_changed`), when no machine of the plan has room for the size (409 `no_volume_space`), and without `planId` (400 `volume_plan_required`; `region` alone is no longer accepted).

**Scope cần có:** `full` · **Quyền:** `servers.deploy` · **Có thể thử lại an toàn với:** `Idempotency-Key`

**Nội dung yêu cầu**

| Tên | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- |
| `name` | string | có |  |
| `sizeGb` | integer | có |  |
| `planId` | string | không |  |
| `region` | string | không |  |
| `shownHourlyMicros` | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl -X POST "https://apidly.com/api/v1/volumes" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"example","sizeGb":10,"shownHourlyMicros":"example"}'
```

**JavaScript (SDK)**

```js
await apidly.volumes.create({
  name: "example",
  sizeGb: 10,
  shownHourlyMicros: "example"
});
```

**Python (SDK)**

```python
client.volumes.create(name="example", size_gb=10)
```

**Công cụ dòng lệnh:** `apidly volumes`, `apidly apply` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (201)

```json
{
  "volume": {
    "id": "example",
    "name": "example",
    "sizeGb": 1,
    "status": "example",
    "instanceId": "id_example",
    "region": "South Korea",
    "regionCode": "KR",
    "planId": "id_example",
    "hourlyPriceMicros": "1000000",
    "hourlyPriceUsd": "1.000000",
    "scheduledDeletionAt": "2026-11-21T10:00:00.000Z",
    "attachable": false,
    "legacy": false,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `400`, `401`, `402`, `403`, `409`, `429`.

### GET /volumes/options

Giá ổ đĩa cho một gói GPU

With `planId`: `option` is the price of a volume of `sizeGb` on a machine that has that plan now (`offer` is its deprecated name, same object) (409 `no_volume_space` when none has room). `perGbMonthMicros` is our price per GB per 30-day month. Without `planId`: storage prices by region only, kept for older clients (a volume cannot be created from them).

**Scope cần có:** `read`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `sizeGb` | query | integer | có |  |
| `planId` | query | string | không |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes/options?sizeGb=10" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.options(10);
```

**Python (SDK)**

```python
client.volumes.options(size_gb="example")
```

**Công cụ dòng lệnh:** `apidly volumes`, `apidly plan`, `apidly apply` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "sizeGb": 1,
  "option": {
    "planId": "id_example",
    "region": "example",
    "hourlyMicros": "1000000",
    "hourlyUsd": "1.000000",
    "monthlyMicros": "1000000",
    "monthlyUsd": "1.000000",
    "perGbMonthMicros": "1000000",
    "perGbMonthUsd": "1.000000",
    "maxSizeGb": 1
  },
  "offer": {
    "planId": "id_example",
    "region": "example",
    "hourlyMicros": "1000000",
    "hourlyUsd": "1.000000",
    "monthlyMicros": "1000000",
    "monthlyUsd": "1.000000",
    "perGbMonthMicros": "1000000",
    "perGbMonthUsd": "1.000000",
    "maxSizeGb": 1
  },
  "regions": [
    {
      "region": "example",
      "hourlyMicros": "1000000",
      "hourlyUsd": "1.000000",
      "monthlyMicros": "1000000",
      "monthlyUsd": "1.000000",
      "maxSizeGb": 1
    }
  ]
}
```

Trạng thái lỗi: `400`, `401`, `403`, `404`, `409`, `429`.

### GET /volumes/offers

Deprecated alias of GET /volumes/options

Same query and answer as `GET /volumes/options`; answered until 2027-05-31. Use `GET /volumes/options`.

**Scope cần có:** `read`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `sizeGb` | query | integer | có |  |
| `planId` | query | string | không |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes/offers?sizeGb=10" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.offers(10);
```

**Python (SDK)**

```python
client.volumes.offers(size_gb="example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "sizeGb": 1,
  "option": {
    "planId": "id_example",
    "region": "example",
    "hourlyMicros": "1000000",
    "hourlyUsd": "1.000000",
    "monthlyMicros": "1000000",
    "monthlyUsd": "1.000000",
    "perGbMonthMicros": "1000000",
    "perGbMonthUsd": "1.000000",
    "maxSizeGb": 1
  },
  "offer": {
    "planId": "id_example",
    "region": "example",
    "hourlyMicros": "1000000",
    "hourlyUsd": "1.000000",
    "monthlyMicros": "1000000",
    "monthlyUsd": "1.000000",
    "perGbMonthMicros": "1000000",
    "perGbMonthUsd": "1.000000",
    "maxSizeGb": 1
  },
  "regions": [
    {
      "region": "example",
      "hourlyMicros": "1000000",
      "hourlyUsd": "1.000000",
      "monthlyMicros": "1000000",
      "monthlyUsd": "1.000000",
      "maxSizeGb": 1
    }
  ]
}
```

Trạng thái lỗi: `400`, `401`, `403`, `404`, `409`, `429`.

### GET /volumes/{id}/availability

Máy chủ dùng ổ đĩa này có khởi động ngay được không

A volume is tied to one machine. `state`: `available_now` (the `plans` listed can start there now), `busy` (its GPU is rented by someone else; try again later), `no_fit` (an older volume placed by region only, where none of the plans checked can run: delete it to stop its charge), `in_use` (mounted by a server), `legacy` (no storage behind it), `unknown` (the host could not be asked).

**Scope cần có:** `read` · **Quyền:** `servers.view`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes/volume_example/availability" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.availability("volume_example");
```

**Python (SDK)**

```python
client.volumes.availability("volume_example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "availability": {
    "volumeId": "id_example",
    "state": "available_now",
    "plans": [
      {
        "id": "example",
        "slug": "example",
        "name": "example",
        "gpuModel": "example",
        "gpuCount": 1,
        "hourlyPriceMicros": "1000000",
        "hourlyPriceUsd": "1.000000"
      }
    ],
    "checkedAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `401`, `403`, `404`, `429`.

### GET /volumes/{id}

Một ổ đĩa

**Scope cần có:** `read` · **Quyền:** `servers.view`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes/volume_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.get("volume_example");
```

**Python (SDK)**

```python
client.volumes.get("volume_example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "volume": {
    "id": "example",
    "name": "example",
    "sizeGb": 1,
    "status": "example",
    "instanceId": "id_example",
    "region": "South Korea",
    "regionCode": "KR",
    "planId": "id_example",
    "hourlyPriceMicros": "1000000",
    "hourlyPriceUsd": "1.000000",
    "scheduledDeletionAt": "2026-11-21T10:00:00.000Z",
    "attachable": false,
    "legacy": false,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `401`, `403`, `404`, `429`.

### PATCH /volumes/{id}

Đổi tên một ổ đĩa

Changes the volume's name only. Nothing changes on the host and a mounted volume keeps working; deleting it then asks for the new name.

**Scope cần có:** `full` · **Quyền:** `storage.manage`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |

**Nội dung yêu cầu**

| Tên | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- |
| `name` | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl -X PATCH "https://apidly.com/api/v1/volumes/volume_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"example"}'
```

**JavaScript (SDK)**

```js
await apidly.volumes.rename("volume_example", "example");
```

**Python (SDK)**

```python
client.volumes.rename("volume_example", name="example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "volume": {
    "id": "example",
    "name": "example",
    "sizeGb": 1,
    "status": "example",
    "instanceId": "id_example",
    "region": "South Korea",
    "regionCode": "KR",
    "planId": "id_example",
    "hourlyPriceMicros": "1000000",
    "hourlyPriceUsd": "1.000000",
    "scheduledDeletionAt": "2026-11-21T10:00:00.000Z",
    "attachable": false,
    "legacy": false,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `400`, `401`, `403`, `404`, `429`.

### DELETE /volumes/{id}

Xóa ổ đĩa (`?confirm=` tên của nó)

The data is deleted for good.

**Scope cần có:** `full` · **Quyền:** `storage.manage`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |
| `confirm` | query | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl -X DELETE "https://apidly.com/api/v1/volumes/volume_example?confirm=example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.delete("volume_example", "example");
```

**Python (SDK)**

```python
client.volumes.delete("volume_example", confirm="example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "key": null
}
```

Trạng thái lỗi: `400`, `401`, `403`, `404`, `409`, `429`.

### GET /transfers

Chuyển dữ liệu, mới nhất trước

**Scope cần có:** `read`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | không |  |
| `cursor` | query | string | không |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/transfers?limit=20" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.transfers.list({ limit: 20 });
```

**Python (SDK)**

```python
client.transfers.list()
```

**Công cụ dòng lệnh:** `apidly transfers` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "transfers": [
    {
      "id": "example",
      "kind": "copy",
      "status": "running",
      "srcInstanceId": "id_example",
      "dstInstanceId": "id_example",
      "srcPath": "example",
      "dstPath": "example",
      "connectionId": "id_example",
      "scheduled": false,
      "percent": 1,
      "phase": "copying",
      "reason": "example",
      "message": "example",
      "createdAt": "2026-11-21T10:00:00.000Z",
      "finishedAt": "2026-11-21T10:00:00.000Z"
    }
  ],
  "nextCursor": "example"
}
```

Trạng thái lỗi: `401`, `403`, `429`.

### POST /transfers

Sao chép dữ liệu giữa các máy chủ

Both servers must be running. Other transfer kinds answer 404 `feature_unavailable` while they are not available on your account.

**Scope cần có:** `servers` · **Có thể thử lại an toàn với:** `Idempotency-Key`

**Ví dụ yêu cầu (curl)**

```bash
curl -X POST "https://apidly.com/api/v1/transfers" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"kind":"copy","srcInstanceId":"id_example","dstInstanceId":"id_example","srcPath":"example","dstPath":"example"}'
```

**JavaScript (SDK)**

```js
await apidly.transfers.start({
  kind: "copy",
  srcInstanceId: "id_example",
  dstInstanceId: "id_example",
  srcPath: "example",
  dstPath: "example"
});
```

**Python (SDK)**

```python
client.transfers.start(body={
    "kind": "copy",
    "srcInstanceId": "id_example",
    "dstInstanceId": "id_example",
    "srcPath": "example",
    "dstPath": "example",
})
```

**Công cụ dòng lệnh:** `apidly transfers` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (201)

```json
{
  "transfer": {
    "id": "example",
    "kind": "copy",
    "status": "running",
    "srcInstanceId": "id_example",
    "dstInstanceId": "id_example",
    "srcPath": "example",
    "dstPath": "example",
    "connectionId": "id_example",
    "scheduled": false,
    "percent": 1,
    "phase": "copying",
    "reason": "example",
    "message": "example",
    "createdAt": "2026-11-21T10:00:00.000Z",
    "finishedAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `400`, `401`, `403`, `404`, `409`, `429`.

### GET /transfers/{id}

Một lượt chuyển

**Scope cần có:** `read`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/transfers/transfer_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.transfers.get("transfer_example");
```

**Python (SDK)**

```python
client.transfers.get("transfer_example")
```

**Công cụ dòng lệnh:** `apidly transfers` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "transfer": {
    "id": "example",
    "kind": "copy",
    "status": "running",
    "srcInstanceId": "id_example",
    "dstInstanceId": "id_example",
    "srcPath": "example",
    "dstPath": "example",
    "connectionId": "id_example",
    "scheduled": false,
    "percent": 1,
    "phase": "copying",
    "reason": "example",
    "message": "example",
    "createdAt": "2026-11-21T10:00:00.000Z",
    "finishedAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `401`, `403`, `404`, `429`.

### DELETE /transfers/{id}

Hủy một lượt chuyển đang chạy

**Scope cần có:** `full`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | path | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl -X DELETE "https://apidly.com/api/v1/transfers/transfer_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.transfers.cancel("transfer_example");
```

**Python (SDK)**

```python
client.transfers.cancel("transfer_example")
```

**Công cụ dòng lệnh:** `apidly transfers` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "transfer": {
    "id": "example",
    "kind": "copy",
    "status": "running",
    "srcInstanceId": "id_example",
    "dstInstanceId": "id_example",
    "srcPath": "example",
    "dstPath": "example",
    "connectionId": "id_example",
    "scheduled": false,
    "percent": 1,
    "phase": "copying",
    "reason": "example",
    "message": "example",
    "createdAt": "2026-11-21T10:00:00.000Z",
    "finishedAt": "2026-11-21T10:00:00.000Z"
  }
}
```

Trạng thái lỗi: `401`, `403`, `404`, `409`, `429`.

### GET /volumes/fit

Các ổ lưu trữ trống mà máy chủ của gói này gắn được

A volume lives on one machine, so a server that mounts it must run there. `fits` lists the ids of the organization's free volumes whose machine can host the plan now (a volume whose fit cannot be told right now counts as fitting); `checked` is how many were looked at (at most 20).

**Scope cần có:** `read` · **Quyền:** `servers.view`

**Tham số**

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `plan` | query | string | có |  |

**Ví dụ yêu cầu (curl)**

```bash
curl "https://apidly.com/api/v1/volumes/fit?plan=example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.volumes.fit("example");
```

**Python (SDK)**

```python
client.volumes.fit(plan="example")
```

**Công cụ dòng lệnh:** `apidly volumes` ([Tài liệu CLI](/docs/cli))

**Ví dụ phản hồi** (200)

```json
{
  "fits": [
    "example"
  ],
  "checked": 1
}
```

Trạng thái lỗi: `400`, `401`, `403`, `429`.
