The Template Engine API lets you programmatically create and manage templates for your transactional email.

GET

Retrieve all templates.

Request

1
GET https://api.sendgrid.com/v3/templates HTTP/1.1

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
    "templates": [
        {
            "id": "e8ac01d5-a07a-4a71-b14c-4721136fe6aa",
            "name": "example template name",
            "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"
                }
            ]
        }
    ]
}

GET

Retrieve a single template.

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
21
{
    "templates": [
        {
            "id": "e8ac01d5-a07a-4a71-b14c-4721136fe6aa",
            "name": "example template name",
            "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%>",
                "subject": "<%subject%>",
                "updated_at": "2014-05-22 20:05:21"
             }
          ]
        }
    ]
}

POST

Create a template.

Parameter Required Requirements Description
name true String with fewer than 100 characters The name of the new template

Request

1
POST https://api.sendgrid.com/v3/templates HTTP/1.1
Request Body
1
2
3
{
  "name": "example_name"
}

Response

1
2
3
4
5
6
7
HTTP/1.1 201 OK

{
    "id": "733ba07f-ead1-41fc-933a-3976baa23716",
    "name": "example_name",
    "versions": []
}

PATCH

Edit a template.

Parameter Required Requirements Description
name true String with fewer than 100 characters The name of the new template

Request

1
PATCH https://api.sendgrid.com/v3/templates/:template_id HTTP/1.1
Request Body
1
2
3
{
  "name": "new_example_name"
}

Response

1
2
3
4
5
6
7
HTTP/1.1 200 OK

{
    "id": "733ba07f-ead1-41fc-933a-3976baa23716",
    "name": "new_example_name",
    "versions": []
}

DELETE

Delete a template.

Request

1
DELETE https://api.sendgrid.com/v3/templates/:template_id HTTP/1.1

Response

1
HTTP/1.1 204 NO CONTENT (OK)