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

テンプレート：バージョン

# テンプレートバージョンの一覧

テンプレートの保存済みバージョンを新しい順に返します。直近10件が保存されます。

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

API keyに`template:read`スコープが必要です。

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`
同じIP + API keyで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD`MISSING_SCOPE`
API keyにこのコマンドに必要なスコープがありません。
- CMD`INVALID_ARGS`
引数が無効です：形式が正しくない`template_id`、`name`や`html`がない、255文字を超える名前、RFC 3339でない`version_at`…
- CMD`TEMPLATE_NOT_FOUND`
テンプレートがアカウントにありません。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
