---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/th/api-reference/templates/versions/list-template-versions

เทมเพลต: เวอร์ชัน

# แสดงรายการเวอร์ชันเทมเพลต

เวอร์ชันที่บันทึกของเทมเพลต ล่าสุดก่อน เก็บไว้ 10 เวอร์ชันล่าสุด

POST `https://g.sendcorex.com/v1/template` command: list_template_versions

ต้องมีขอบเขต `template:read` บน API key ของคุณ

เทมเพลต HTML บันทึกเวอร์ชันทุกครั้งที่สร้างและอัปเดต เทมเพลตจากเอดิเตอร์บันทึกเวอร์ชันทุกครั้งที่คุณคลิกบันทึกในแดชบอร์ด (ไม่ใช่การบันทึกอัตโนมัติ)

## อาร์กิวเมนต์

- `template_id` string จำเป็น
เทมเพลต
เช่น `"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"`

## เริ่มต้นอย่างรวดเร็ว

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/template',
  {
    commands: [
      {
        command: "list_template_versions",
        args: {
          template_id: "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## การตอบกลับ

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "list_template_versions",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 4,
      "data": {
        "template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
        "versions": [
          {
            "version_at": "2026-10-21T04:15:40.902Z",
            "html_size": 248,
            "subject": "Welcome to Acme, {{first_name}}"
          },
          {
            "version_at": "2026-10-21T04:09:12.004Z",
            "html_size": 231,
            "subject": "Welcome to Acme"
          },
          {
            "version_at": "2026-10-21T04:02:11.310Z",
            "html_size": 198,
            "subject": null
          }
        ]
      }
    }
  ]
}
```

### ฟิลด์การตอบกลับ

- `template_id`
เทมเพลต
- `versions`
ล่าสุดก่อน ว่างเมื่อยังไม่ได้บันทึกอะไร
- `versions[].version_at`
เวลาที่บันทึกเวอร์ชัน ส่งค่านี้ตามเดิมให้ Restore Template Version
- `versions[].html_size`
ขนาด HTML ของเวอร์ชันนั้น เป็นไบต์
- `versions[].subject`
หัวเรื่องของเวอร์ชันนั้น หรือ `null`

## ข้อผิดพลาด

ข้อผิดพลาดระดับ HTTP ส่งกลับ `type`, `code` และ `message` ข้อผิดพลาดที่มีเครื่องหมาย CMD จะกลับมาในผลลัพธ์ของคำสั่ง พร้อม HTTP 200

- 401`INVALID_API_KEY`
API key ไม่มีอยู่ ถูกเพิกถอน หรือถูกปิดในแดชบอร์ด
- 429`RATE_LIMITED`
เกิน 15 คำขอ/วินาที หรือ 15 คำขอพร้อมกันสำหรับ IP + API key เดียวกัน รอจำนวนวินาทีใน Retry-After
- CMD`MISSING_SCOPE`
API key ไม่มีขอบเขตที่คำสั่งนี้ต้องการ
- CMD`INVALID_ARGS`
อาร์กิวเมนต์ไม่ถูกต้อง: `template_id` รูปแบบผิด ไม่มี `name` หรือ `html` ชื่อยาวเกิน 255 ตัวอักษร `version_at` ที่ไม่ใช่ RFC 3339…
- CMD`TEMPLATE_NOT_FOUND`
เทมเพลตไม่อยู่ในบัญชีของคุณ
- CMD`INTERNAL`
ข้อผิดพลาดของเซิร์ฟเวอร์ รายละเอียดเขียนเฉพาะในล็อกเซิร์ฟเวอร์
