Transactional Templates APIを使用することでトランザクションメールのテンプレートの作成および管理をプログラムから行うことができます。
各アカウントは300テンプレートまで登録することができます。
 
Transactional Templateで作成されたテンプレートはアカウント固有のものです。親アカウントで作成したテンプレートにサブユーザがアクセスすることはできません。
 
SMTP APIではDynamic Templateは使用できないため、Legacy Templateを使用してください。
 
 
 POST 
テンプレートを作成します。
  
    
      Body引数 
      必須 
      条件 
      説明 
     
    
  
  name 
  Yes 
  100文字以下の文字列 
  新しく作成するテンプレートの名前 
 
  
  generation 
  No 
  legacy、dynamicのいずれか 
  テンプレートの種類  Default:legacy Dynamic Template を使用する場合は 必ずdynamicを指定してください 
 
   
  Request 
      
     
     
    
    
 1 
POST  https://api.sendgrid.com/v3/templates  HTTP / 1.1 
  
  
        Request Body    
     
     
    
    
 1 
2 
3 
4 
{ 
  "name" :  "example_name" , 
   "generation" :  "dynamic" 
 } 
  
    
  Response 
      
     
     
    
    
 1 
2 
3 
4 
5 
6 
7 
8 
9 
HTTP / 1.1  201  OK 
 { 
  "id" :  "733ba07f-ead1-41fc-933a-3976baa23716" , 
   "name" :  "example_name" , 
   "generation" :  "dynamic" , 
   "updated_at" :  "2021-04-28 13:12:46" , 
   "versions" :  [] 
 } 
  
 
 
 
 GET 
全テンプレートを取得します。
  
    
      URI引数 
      必須 
      条件 
      説明 
     
    
  
  generations 
  No 
  legacy、dynamic、legacy,dynamicのいずれか 
  取得したいテンプレートの種類  Default:legacy 
 
  
  page_size 
  Yes 
  number 
  一度に取得するテンプレート数 (1〜200の間の数) 
 
  
  page_token 
  No 
  string 
  取得したいページのトークン (前後のページのトークンはレスポンスのmetadataオブジェクト内に記載されます) 
 
   
  Request 
      
     
     
    
    
 1 
GET  https://api.sendgrid.com/v3/templates?generations=dynamic&page_size=1  HTTP / 1.1 
  
  
  
  Response 
      
     
     
    
    
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
{ 
  "result" :  [ 
     { 
       "id" :  "e8ac01d5-a07a-4a71-b14c-4721136fe6aa" , 
       "name" :  "example template name" , 
       "generation" :  "dynamic" , 
       "updated_at" :  "2021-04-28 13:12:46" , 
       "versions" :  [ 
         { 
           "id" :  "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f" , 
           "template_id" :  "9c59c1fb-931a-40fc-a658-50f871f3e41c" , 
           "active" :  1 , 
           "name" :  "example version name" , 
           "updated_at" :  "2014-03-19 18:56:33" , 
           "editor" :  "design" 
         } 
       ] 
     } 
   ], 
     "_metadata" : { 
   "self" : "https://api.sendgrid.com/v3/templates" , 
      "count" :  1 
   } 
 } 
  
 
 
 
 GET 
指定したテンプレートを取得します。
  Request 
      
     
     
    
    
 1 
GET  https://api.sendgrid.com/v3/templates/:template_id  HTTP / 1.1 
  
  
  
  Response 
      
     
     
    
    
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
{ 
  "id" :  "e8ac01d5-a07a-4a71-b14c-4721136fe6aa" , 
   "name" :  "example template name" , 
   "generation" :  "dynamic" , 
   "updated_at" :  "2021-04-28 13:12:46" , 
   "versions" :  [ 
     { 
       "id" :  "de37d11b-082a-42c0-9884-c0c143015a47" , 
       "user_id" :  1234 , 
       "template_id" :  "d51480ba-ca3f-465c-bc3e-ceb71d73c38d" , 
       "active" :  1 , 
       "name" :  "example version" , 
       "html_content" :  "<%body%><strong>Click to Reset</strong>" , 
       "plain_content" :  "Click to Reset<%body%>" , 
       "editor" :  "code" , 
       "subject" :  "<%subject%>" , 
       "updated_at" :  "2014-05-22 20:05:21" 
     } 
   ] 
 } 
  
 
 
 
 PATCH 
テンプレートを編集します。
  
    
      URI引数 
      必須 
      条件 
      説明 
     
    
  
  name 
  Yes 
  100文字以下の文字列 
  テンプレートの名前 
 
   
  Request 
      
     
     
    
    
 1 
PATCH  https://api.sendgrid.com/v3/templates/:template_id  HTTP / 1.1 
  
  
    
  Response 
      
     
     
    
    
 1 
2 
3 
4 
5 
6 
7 
8 
9 
HTTP / 1.1  200  OK 
 { 
  "id" :  "733ba07f-ead1-41fc-933a-3976baa23716" , 
   "name" :  "new_example_name" , 
   "generation" :  "dynamic" , 
   "updated_at" :  "2021-04-28 13:12:46" , 
   "versions" :  [] 
 } 
  
 
 
 
 DELETE 
テンプレートを削除します。
  Request 
      
     
     
    
    
 1 
DELETE  https://api.sendgrid.com/v3/templates/:template_id  HTTP / 1.1 
  
  
    
  Response 
      
     
     
    
    
 1 
HTTP / 1.1  204  NO  CONTENT  ( OK )