# Tài liệu tham chiếu API: Mẫu

Mẫu: 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 /templates` | `read` | Mẫu công khai và mẫu của tổ chức bạn |
| `POST /templates` | `full` | Tạo mẫu của tổ chức |
| `GET /templates/{id}` | `read` | Một mẫu |
| `PATCH /templates/{id}` | `full` | Cập nhật một mẫu của tổ chức bạn |
| `DELETE /templates/{id}` | `full` | Xóa một mẫu, hoặc ẩn nó khi vẫn còn máy chủ tham chiếu |
| `POST /templates/{id}/share` | `full` | Tạo liên kết chia sẻ cho một mẫu của tổ chức bạn |
| `DELETE /templates/{id}/share` | `full` | Thu hồi các liên kết chia sẻ của một mẫu |
| `GET /templates/{id}/share` | `full` | Liên kết chia sẻ của một mẫu |
| `POST /templates/{id}/duplicate` | `full` | Sao chép một mẫu của tổ chức bạn |
| `GET /templates/{id}/revisions` | `read` | Lịch sử bản sửa đổi của một mẫu, mới nhất trước |
| `POST /templates/{id}/revisions/{rev}/restore` | `full` | Khôi phục một bản sửa đổi cũ thành bản mới |
| `GET /templates/{id}/export` | `full` | Xuất mẫu thành tệp mang theo được |
| `POST /templates/import` | `full` | Tạo mẫu từ tệp đã xuất |
| `POST /template-shares/{token}/import` | `full` | Sao chép mẫu được chia sẻ vào tổ chức của bạn |
| `POST /template-shares/{token}/report` | `servers` | Báo cáo mẫu được chia sẻ cho nhân viên của chúng tôi (tối đa 10 lần mỗi giờ cho mỗi tổ chức) |

### GET /templates

Mẫu công khai và mẫu của tổ chức bạn

Optional filters: `q` (up to 60 characters, case-insensitive, found in the name, slug, summary, image or category), `category`, `source` (`builtin` for the public catalogue, `own` for your organization's templates) and `vramGb` (only templates whose `minVramGb` is at most this, so they run on a GPU with that much memory). Repeat the same filters on every page so the `cursor` stays valid.

**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 |  |
| `q` | query | string | không |  |
| `category` | query | `base` \| `llm` \| `image` \| `notebook` \| `training` \| `custom` | không |  |
| `source` | query | `builtin` \| `own` | không |  |
| `vramGb` | query | integer | không |  |

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

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

**JavaScript (SDK)**

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

**Python (SDK)**

```python
client.templates.list()
```

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

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

```json
{
  "templates": [
    {
      "id": "example",
      "slug": "example",
      "name": "example",
      "summary": "example",
      "category": "example",
      "image": "docker.io/library/ubuntu",
      "tag": "example",
      "launchMode": "ssh",
      "env": {
        "key": "example"
      },
      "ports": [
        {
          "port": null,
          "protocol": null,
          "label": null
        }
      ],
      "startScript": "example",
      "onStart": "example",
      "args": "example",
      "description": "example",
      "secretEnvKeys": [
        "example"
      ],
      "registryId": "id_example",
      "appPort": 1,
      "defaultDiskGb": 1,
      "minVramGb": 1,
      "recommendedVramGb": 1,
      "constraints": {
        "key": null
      },
      "latestCudaTag": false,
      "inference": {
        "api": "http",
        "healthPath": "example",
        "port": 1
      },
      "custom": false,
      "firstBootMinutes": 1,
      "revision": 1,
      "sort": 1,
      "createdAt": "2026-11-21T10:00:00.000Z"
    }
  ],
  "nextCursor": "example"
}
```

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

### POST /templates

Tạo mẫu của tổ chức

**Scope cần có:** `full` · **Vai trò người tạo:** `admin` · **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ó |  |
| `summary` | string | không |  |
| `description` | string | không |  |
| `image` | string | có |  |
| `tag` | string | không |  |
| `launchMode` | `ssh` \| `jupyter` \| `app` | có |  |
| `env` | object | không |  |
| `secretEnv` | object | không |  |
| `ports` | mảng object | không |  |
| `startScript` | string | không | Shell script run on the server after each start (up to 64 KB). Replaces the deprecated `onStart`. |
| `onStart` | string | không | Deprecated name of `startScript`, read until 2027-05-31. Send `startScript`. |
| `args` | string | không |  |
| `appPort` | integer hoặc null | không |  |
| `defaultDiskGb` | integer | không |  |
| `minVramGb` | integer | không |  |
| `constraints` | object | không |  |
| `recommendedVramGb` | integer hoặc null | không |  |
| `inference` | object hoặc null | không |  |
| `registryId` | string hoặc null | không |  |
| `latestCudaTag` | boolean | không |  |
| `inheritSecretsFrom` | string | không |  |

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

```bash
curl -X POST "https://apidly.com/api/v1/templates" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"example","image":"docker.io/library/ubuntu","launchMode":"ssh"}'
```

**JavaScript (SDK)**

```js
await apidly.templates.create({
  name: "example",
  image: "docker.io/library/ubuntu",
  launchMode: "ssh"
});
```

**Python (SDK)**

```python
client.templates.create(body={
    "name": "example",
    "image": "docker.io/library/ubuntu",
    "launchMode": "ssh",
})
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### GET /templates/{id}

Một mẫu

`id` is a template id or the slug the catalogue lists (`pytorch`). Built-in templates are shown read-only (`custom: false`).

**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/templates/tpl_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.get("tpl_example");
```

**Python (SDK)**

```python
client.templates.get("tpl_example")
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### PATCH /templates/{id}

Cập nhật một mẫu của tổ chức bạn

**Scope cần có:** `full` · **Vai trò người tạo:** `admin`

**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 | không |  |
| `summary` | string | không |  |
| `description` | string | không |  |
| `image` | string | không |  |
| `tag` | string | không |  |
| `launchMode` | `ssh` \| `jupyter` \| `app` | không |  |
| `env` | object | không |  |
| `secretEnv` | object | không |  |
| `ports` | mảng object | không |  |
| `startScript` | string | không | Shell script run on the server after each start (up to 64 KB). Replaces the deprecated `onStart`. |
| `onStart` | string | không | Deprecated name of `startScript`, read until 2027-05-31. Send `startScript`. |
| `args` | string | không |  |
| `appPort` | integer hoặc null | không |  |
| `defaultDiskGb` | integer | không |  |
| `minVramGb` | integer | không |  |
| `constraints` | object | không |  |
| `recommendedVramGb` | integer hoặc null | không |  |
| `inference` | object hoặc null | không |  |
| `registryId` | string hoặc null | không |  |
| `latestCudaTag` | boolean | không |  |

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

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

**JavaScript (SDK)**

```js
await apidly.templates.update("tpl_example", {
  name: "example",
  summary: "example",
  description: "example"
});
```

**Python (SDK)**

```python
client.templates.update("tpl_example", body={
    "name": "example",
    "summary": "example",
    "description": "example",
})
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### DELETE /templates/{id}

Xóa một mẫu, hoặc ẩn nó khi vẫn còn máy chủ tham chiếu

**Scope cần có:** `full` · **Vai trò người tạo:** `admin`

**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/templates/tpl_example" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.delete("tpl_example");
```

**Python (SDK)**

```python
client.templates.delete("tpl_example")
```

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

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

```json
{
  "deleted": false,
  "hidden": false
}
```

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

### POST /templates/{id}/share

Tạo liên kết chia sẻ cho một mẫu của tổ chức bạn

Anyone with the link sees the template's name, description, image, ports, minimum GPU memory and the NAMES of its plain environment variables, and can copy it into their own organization. Secret values, registry logins and (unless `includeStartScript` is true) the start script are never shared.

**Scope cần có:** `full` · **Quyền:** `templates.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ả |
| --- | --- | --- | --- |
| `displayName` | string hoặc null | không |  |
| `includeStartScript` | boolean | không |  |
| `expiresInDays` | integer hoặc null | không |  |

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

```bash
curl -X POST "https://apidly.com/api/v1/templates/tpl_example/share" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"displayName":"example","includeStartScript":false,"expiresInDays":null}'
```

**JavaScript (SDK)**

```js
await apidly.templates.share("tpl_example");
```

**Python (SDK)**

```python
client.templates.share("tpl_example")
```

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

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

```json
{
  "share": {
    "id": "example",
    "templateId": "id_example",
    "token": "example",
    "displayName": "example",
    "includeStartScript": false,
    "expiresAt": "2026-11-21T10:00:00.000Z",
    "status": "active",
    "viewCount": 1,
    "importCount": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### DELETE /templates/{id}/share

Thu hồi các liên kết chia sẻ của một mẫu

Revokes one link with `?shareId=`, or every active link of the template when omitted.

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

**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/templates/tpl_example/share" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.unshare("tpl_example");
```

**Python (SDK)**

```python
client.templates.unshare("tpl_example")
```

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

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

```json
{
  "revoked": 1
}
```

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

### GET /templates/{id}/share

Liên kết chia sẻ của một mẫu

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

**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/templates/tpl_example/share" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.listShares("tpl_example");
```

**Python (SDK)**

```python
client.templates.list_shares("tpl_example")
```

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

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

```json
{
  "shares": [
    {
      "id": "example",
      "templateId": "id_example",
      "token": "example",
      "displayName": "example",
      "includeStartScript": false,
      "expiresAt": "2026-11-21T10:00:00.000Z",
      "status": "active",
      "viewCount": 1,
      "importCount": 1,
      "createdAt": "2026-11-21T10:00:00.000Z"
    }
  ]
}
```

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

### POST /templates/{id}/duplicate

Sao chép một mẫu của tổ chức bạn

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

**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 POST "https://apidly.com/api/v1/templates/tpl_example/duplicate" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.duplicate("tpl_example");
```

**Python (SDK)**

```python
client.templates.duplicate("tpl_example")
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### GET /templates/{id}/revisions

Lịch sử bản sửa đổi của một mẫu, mới nhất trước

Secret values are never included.

**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/templates/tpl_example/revisions" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.listRevisions("tpl_example");
```

**Python (SDK)**

```python
client.templates.list_revisions("tpl_example")
```

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

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

```json
{
  "revisions": [
    {
      "rev": 1,
      "kind": "example",
      "restoredFrom": 1,
      "createdAt": "2026-11-21T10:00:00.000Z",
      "createdByName": "example",
      "current": false,
      "servers": 1,
      "snapshot": {
        "key": null
      }
    }
  ]
}
```

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

### POST /templates/{id}/revisions/{rev}/restore

Khôi phục một bản sửa đổi cũ thành bản mới

History is never rewritten: the restored copy becomes the newest revision.

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

**Tham số**

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

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

```bash
curl -X POST "https://apidly.com/api/v1/templates/tpl_example/revisions/1/restore" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.restoreRevision("tpl_example", "1");
```

**Python (SDK)**

```python
client.templates.restore_revision("tpl_example", "1")
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  },
  "revision": 1
}
```

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

### GET /templates/{id}/export

Xuất mẫu thành tệp mang theo được

The file the console downloads. Secret variables appear as names in `secretEnvNames`, never with values; the registry login is never included. Send its text to `POST /templates/import` to copy it into an organization. Only your organization's own templates can be exported: a built-in template answers 409 `invalid_state` (read it with `GET /templates/{id}`).

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

**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/templates/tpl_example/export" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

**JavaScript (SDK)**

```js
await apidly.templates.export("tpl_example");
```

**Python (SDK)**

```python
client.templates.export("tpl_example")
```

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

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

```json
{
  "format": "apidly-template",
  "version": 1,
  "template": {
    "name": "example",
    "summary": "example",
    "description": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "secretEnvNames": [
      "example"
    ],
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "appPort": 1,
    "inference": {
      "key": null
    },
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "defaultDiskGb": 1,
    "minVramGb": 1
  }
}
```

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

### POST /templates/import

Tạo mẫu từ tệp đã xuất

`json` is the text of a file from `GET /templates/{id}/export` (or the console's Export). Secret variables arrive blank and the registry unset. 400 `invalid_file` when it is not such a file.

**Scope cần có:** `full` · **Quyền:** `templates.manage` · **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ả |
| --- | --- | --- | --- |
| `json` | string | có |  |

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

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

**JavaScript (SDK)**

```js
await apidly.templates.import("example");
```

**Python (SDK)**

```python
client.templates.import_file(file="example")
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### POST /template-shares/{token}/import

Sao chép mẫu được chia sẻ vào tổ chức của bạn

`token` is the 32-character token of a share link (`/t/{token}`). 404 when the link is revoked, expired or unknown.

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

**Tham số**

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

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

```bash
curl -X POST "https://apidly.com/api/v1/template-shares/templateshare_example/import" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

**JavaScript (SDK)**

```js
await apidly.templates.importShared("templateshare_example");
```

**Python (SDK)**

```python
client.templates.import_shared("templateshare_example")
```

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

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

```json
{
  "template": {
    "id": "example",
    "slug": "example",
    "name": "example",
    "summary": "example",
    "category": "example",
    "image": "docker.io/library/ubuntu",
    "tag": "example",
    "launchMode": "ssh",
    "env": {
      "key": "example"
    },
    "ports": [
      {
        "port": 1,
        "protocol": "tcp",
        "label": "example"
      }
    ],
    "startScript": "example",
    "onStart": "example",
    "args": "example",
    "description": "example",
    "secretEnvKeys": [
      "example"
    ],
    "registryId": "id_example",
    "appPort": 1,
    "defaultDiskGb": 1,
    "minVramGb": 1,
    "recommendedVramGb": 1,
    "constraints": {
      "key": null
    },
    "latestCudaTag": false,
    "inference": {
      "api": "http",
      "healthPath": "example",
      "port": 1
    },
    "custom": false,
    "firstBootMinutes": 1,
    "revision": 1,
    "sort": 1,
    "createdAt": "2026-11-21T10:00:00.000Z"
  }
}
```

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

### POST /template-shares/{token}/report

Báo cáo mẫu được chia sẻ cho nhân viên của chúng tôi (tối đa 10 lần mỗi giờ cho mỗi tổ chức)

Opens a support ticket for staff with the reason (`malware`, `illegal`, `secrets`, `other`) and your details. Five reports an hour per key and ten an hour per organization, across all its keys.

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

**Tham số**

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

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

| Tên | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- |
| `details` | string | không |  |
| `reason` | `malware` \| `illegal` \| `secrets` \| `other` | có |  |

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

```bash
curl -X POST "https://apidly.com/api/v1/template-shares/templateshare_example/report" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"reason":"malware"}'
```

**JavaScript (SDK)**

```js
await apidly.templates.reportShared("templateshare_example", {
  reason: "malware"
});
```

**Python (SDK)**

```python
client.templates.report_shared("templateshare_example", reason="malware")
```

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

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

```json
{
  "ticketId": "id_example"
}
```

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