---
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/editing/delete-template

テンプレート：編集

# Delete Template

htmlテンプレートとそのすべてのバージョンを削除します。

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

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

1アカウントにつき1分あたり最大30回。超えるとコマンドは`RATE_LIMITED`を返します。

元に戻せません。キャンペーンや送信済みのメールは内容のコピーを持っているので影響を受けません。

UnlayerとCustomのテンプレートはダッシュボードで削除します。

## 引数

- `template_id` string 必須
htmlテンプレート。
例： `"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"`

## クイックスタート

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/template',
  {
    commands: [
      {
        command: "delete_template",
        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": "delete_template",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 6,
      "data": {
        "template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
        "deleted": true
      }
    }
  ]
}
```

### レスポンスの項目

- `template_id`
削除されたテンプレート。
- `deleted`
常に`true`。

## エラー

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`TEMPLATE_READ_ONLY`
UnlayerまたはCustomのテンプレートです：ダッシュボードのエディターで編集してください。APIで変更できるのはhtmlテンプレートだけです。
- CMD`RATE_LIMITED`
直近1分間にアカウントがこのコマンドを呼びすぎました。1分待ってください。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
