# เอกสารอ้างอิง API: เทมเพลต

เทมเพลต: ทุกการดำเนินการของ API v1 พร้อมสโคปที่ต้องใช้ พารามิเตอร์ ตัวอย่างใน curl, JavaScript และ Python และผลลัพธ์ที่ได้ การยืนยันตัวตน ข้อผิดพลาด การแบ่งหน้า ขีดจำกัด และ idempotency อยู่ใน[ภาพรวมเอกสารอ้างอิง API](/docs/api-reference) ดูเพิ่มเติมที่ [SDK](/docs/sdks) และ[บรรทัดคำสั่ง](/docs/cli)

> ลองใช้กับคีย์ของคุณ: สร้างคีย์ API ในคอนโซล รัน `export APIDLY_API_KEY=...` ในเทอร์มินัล แล้ววางตัวอย่าง curl ด้านล่าง ค่าในตัวอย่างเป็นเพียงภาพประกอบ หน้านี้ไม่มีช่องให้กรอกคีย์

คำอธิบายของการดำเนินการและฟิลด์มาจากนิยามของ API และเป็นภาษาอังกฤษ

| การดำเนินการ | สโคปที่ต้องใช้ | สรุป |
| --- | --- | --- |
| `GET /templates` | `read` | เทมเพลตสาธารณะและเทมเพลตขององค์กรคุณ |
| `POST /templates` | `full` | สร้างเทมเพลตขององค์กร |
| `GET /templates/{id}` | `read` | เทมเพลตหนึ่งรายการ |
| `PATCH /templates/{id}` | `full` | อัปเดตเทมเพลตขององค์กรคุณ |
| `DELETE /templates/{id}` | `full` | ลบเทมเพลต หรือซ่อนเมื่อยังมีเซิร์ฟเวอร์อ้างอิงอยู่ |
| `POST /templates/{id}/share` | `full` | สร้างลิงก์แชร์สำหรับเทมเพลตขององค์กรคุณ |
| `DELETE /templates/{id}/share` | `full` | เพิกถอนลิงก์แชร์ของเทมเพลต |
| `GET /templates/{id}/share` | `full` | ลิงก์แชร์ของเทมเพลต |
| `POST /templates/{id}/duplicate` | `full` | คัดลอกเทมเพลตขององค์กรคุณ |
| `GET /templates/{id}/revisions` | `read` | ประวัติการแก้ไขของเทมเพลต ใหม่สุดก่อน |
| `POST /templates/{id}/revisions/{rev}/restore` | `full` | กู้คืนการแก้ไขเก่าเป็นการแก้ไขใหม่ |
| `GET /templates/{id}/export` | `full` | ส่งออกเทมเพลตเป็นไฟล์ที่พกพาได้ |
| `POST /templates/import` | `full` | สร้างเทมเพลตจากไฟล์ที่ส่งออก |
| `POST /template-shares/{token}/import` | `full` | คัดลอกเทมเพลตที่แชร์มาไปยังองค์กรของคุณ |
| `POST /template-shares/{token}/report` | `servers` | รายงานเทมเพลตที่แชร์ไปยังทีมงานของเรา (สูงสุด 10 ครั้งต่อชั่วโมงต่อองค์กร) |

### GET /templates

เทมเพลตสาธารณะและเทมเพลตขององค์กรคุณ

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.

**สโคปที่ต้องใช้:** `read`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | ไม่ |  |
| `cursor` | query | string | ไม่ |  |
| `q` | query | string | ไม่ |  |
| `category` | query | `base` \| `llm` \| `image` \| `notebook` \| `training` \| `custom` | ไม่ |  |
| `source` | query | `builtin` \| `own` | ไม่ |  |
| `vramGb` | query | integer | ไม่ |  |

**ตัวอย่างคำขอ (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()
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates`, `apidly export`, `apidly plan`, `apidly apply` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
}
```

สถานะข้อผิดพลาด: `401`, `403`, `429`.

### POST /templates

สร้างเทมเพลตขององค์กร

**สโคปที่ต้องใช้:** `full` · **บทบาทของผู้สร้าง:** `admin` · **ลองซ้ำได้อย่างปลอดภัยด้วย:** `Idempotency-Key`

**เนื้อหาคำขอ**

| ชื่อ | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `name` | string | ใช่ |  |
| `summary` | string | ไม่ |  |
| `description` | string | ไม่ |  |
| `image` | string | ใช่ |  |
| `tag` | string | ไม่ |  |
| `launchMode` | `ssh` \| `jupyter` \| `app` | ใช่ |  |
| `env` | object | ไม่ |  |
| `secretEnv` | object | ไม่ |  |
| `ports` | อาร์เรย์ของ object | ไม่ |  |
| `startScript` | string | ไม่ | Shell script run on the server after each start (up to 64 KB). Replaces the deprecated `onStart`. |
| `onStart` | string | ไม่ | Deprecated name of `startScript`, read until 2027-05-31. Send `startScript`. |
| `args` | string | ไม่ |  |
| `appPort` | integer หรือ null | ไม่ |  |
| `defaultDiskGb` | integer | ไม่ |  |
| `minVramGb` | integer | ไม่ |  |
| `constraints` | object | ไม่ |  |
| `recommendedVramGb` | integer หรือ null | ไม่ |  |
| `inference` | object หรือ null | ไม่ |  |
| `registryId` | string หรือ null | ไม่ |  |
| `latestCudaTag` | boolean | ไม่ |  |
| `inheritSecretsFrom` | string | ไม่ |  |

**ตัวอย่างคำขอ (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",
})
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `400`, `401`, `403`, `409`, `429`.

### GET /templates/{id}

เทมเพลตหนึ่งรายการ

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

**สโคปที่ต้องใช้:** `read`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

### PATCH /templates/{id}

อัปเดตเทมเพลตขององค์กรคุณ

**สโคปที่ต้องใช้:** `full` · **บทบาทของผู้สร้าง:** `admin`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**เนื้อหาคำขอ**

| ชื่อ | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `name` | string | ไม่ |  |
| `summary` | string | ไม่ |  |
| `description` | string | ไม่ |  |
| `image` | string | ไม่ |  |
| `tag` | string | ไม่ |  |
| `launchMode` | `ssh` \| `jupyter` \| `app` | ไม่ |  |
| `env` | object | ไม่ |  |
| `secretEnv` | object | ไม่ |  |
| `ports` | อาร์เรย์ของ object | ไม่ |  |
| `startScript` | string | ไม่ | Shell script run on the server after each start (up to 64 KB). Replaces the deprecated `onStart`. |
| `onStart` | string | ไม่ | Deprecated name of `startScript`, read until 2027-05-31. Send `startScript`. |
| `args` | string | ไม่ |  |
| `appPort` | integer หรือ null | ไม่ |  |
| `defaultDiskGb` | integer | ไม่ |  |
| `minVramGb` | integer | ไม่ |  |
| `constraints` | object | ไม่ |  |
| `recommendedVramGb` | integer หรือ null | ไม่ |  |
| `inference` | object หรือ null | ไม่ |  |
| `registryId` | string หรือ null | ไม่ |  |
| `latestCudaTag` | boolean | ไม่ |  |

**ตัวอย่างคำขอ (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",
})
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `400`, `401`, `403`, `404`, `429`.

### DELETE /templates/{id}

ลบเทมเพลต หรือซ่อนเมื่อยังมีเซิร์ฟเวอร์อ้างอิงอยู่

**สโคปที่ต้องใช้:** `full` · **บทบาทของผู้สร้าง:** `admin`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (200)

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

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

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

สร้างลิงก์แชร์สำหรับเทมเพลตขององค์กรคุณ

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.

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**เนื้อหาคำขอ**

| ชื่อ | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `displayName` | string หรือ null | ไม่ |  |
| `includeStartScript` | boolean | ไม่ |  |
| `expiresInDays` | integer หรือ null | ไม่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `400`, `401`, `403`, `404`, `409`, `429`.

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

เพิกถอนลิงก์แชร์ของเทมเพลต

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

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (200)

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

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

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

ลิงก์แชร์ของเทมเพลต

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
    }
  ]
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

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

คัดลอกเทมเพลตขององค์กรคุณ

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `409`, `429`.

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

ประวัติการแก้ไขของเทมเพลต ใหม่สุดก่อน

Secret values are never included.

**สโคปที่ต้องใช้:** `read`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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
      }
    }
  ]
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

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

กู้คืนการแก้ไขเก่าเป็นการแก้ไขใหม่

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

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |
| `rev` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `429`.

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

ส่งออกเทมเพลตเป็นไฟล์ที่พกพาได้

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}`).

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `id` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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
  }
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `409`, `429`.

### POST /templates/import

สร้างเทมเพลตจากไฟล์ที่ส่งออก

`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.

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage` · **ลองซ้ำได้อย่างปลอดภัยด้วย:** `Idempotency-Key`

**เนื้อหาคำขอ**

| ชื่อ | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `json` | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `400`, `401`, `403`, `409`, `429`.

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

คัดลอกเทมเพลตที่แชร์มาไปยังองค์กรของคุณ

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

**สโคปที่ต้องใช้:** `full` · **สิทธิ์:** `templates.manage` · **ลองซ้ำได้อย่างปลอดภัยด้วย:** `Idempotency-Key`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `token` | path | string | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (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"
  }
}
```

สถานะข้อผิดพลาด: `401`, `403`, `404`, `409`, `429`.

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

รายงานเทมเพลตที่แชร์ไปยังทีมงานของเรา (สูงสุด 10 ครั้งต่อชั่วโมงต่อองค์กร)

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.

**สโคปที่ต้องใช้:** `servers` · **ลองซ้ำได้อย่างปลอดภัยด้วย:** `Idempotency-Key`

**พารามิเตอร์**

| ชื่อ | ตำแหน่ง | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `token` | path | string | ใช่ |  |

**เนื้อหาคำขอ**

| ชื่อ | ชนิด | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `details` | string | ไม่ |  |
| `reason` | `malware` \| `illegal` \| `secrets` \| `other` | ใช่ |  |

**ตัวอย่างคำขอ (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")
```

**เครื่องมือบรรทัดคำสั่ง:** `apidly templates` ([เอกสารอ้างอิง CLI](/docs/cli))

**ตัวอย่างผลลัพธ์** (201)

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

สถานะข้อผิดพลาด: `400`, `401`, `403`, `404`, `429`.
