---
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/vi/api-reference/templates/versions/list-template-versions

Mẫu: Phiên bản

# Liệt kê phiên bản mẫu

Các phiên bản đã lưu của một mẫu, mới nhất trước. Giữ 10 phiên bản gần nhất.

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

Cần phạm vi `template:read` trên API key của bạn.

Mẫu HTML lưu một phiên bản mỗi lần tạo và cập nhật. Mẫu trình soạn thảo lưu một phiên bản mỗi lần bạn bấm Lưu trong dashboard (không tính lưu tự động).

## Tham số

- `template_id` string bắt buộc
Mẫu.
ví dụ `"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"`

## Bắt đầu nhanh

```
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);
```

## Phản hồi

```
{
  "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
          }
        ]
      }
    }
  ]
}
```

### Trường phản hồi

- `template_id`
Mẫu.
- `versions`
Mới nhất trước. Rỗng khi chưa lưu gì.
- `versions[].version_at`
Thời điểm phiên bản được lưu. Truyền nguyên vẹn cho Restore Template Version.
- `versions[].html_size`
Kích thước HTML của phiên bản đó, tính bằng byte.
- `versions[].subject`
Tiêu đề của phiên bản đó, hoặc `null`.

## Lỗi

Lỗi ở mức HTTP trả về `type`, `code` và `message`. Lỗi đánh dấu CMD được trả về trong kết quả lệnh, với HTTP 200.

- 401`INVALID_API_KEY`
API key không tồn tại, đã bị thu hồi hoặc bị tắt trong dashboard.
- 429`RATE_LIMITED`
Hơn 15 yêu cầu/giây hoặc 15 yêu cầu đồng thời cho cùng IP + API key. Chờ số giây trong Retry-After.
- CMD`MISSING_SCOPE`
API key không có phạm vi lệnh này cần.
- CMD`INVALID_ARGS`
Một đối số không hợp lệ: `template_id` sai định dạng, thiếu `name` hoặc `html`, tên dài hơn 255 ký tự, `version_at` không đúng RFC 3339…
- CMD`TEMPLATE_NOT_FOUND`
Mẫu không có trong tài khoản của bạn.
- CMD`INTERNAL`
Lỗi máy chủ. Chi tiết chỉ được ghi vào log máy chủ.
