Each template can have multiple versions, with different subjects and content for each version.

To retrieve all versions of a template, call the template GET method. Versions are returned as nested resources of the template resource.

To set which version is active, use the version PATCH method to set the active field to 1.

GET

Retrieve a specific version of a template.

Request

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

Response

1
2
3
4
5
6
7
8
9
10
11
12
HTTP/1.1 200 OK

{
    "id": "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f",
    "template_id": "d51480ca-ca3f-465c-bc3e-ceb71d73c38d"
    "active": 1
    "name": "version 1 name",
    "html_content": "<%body%>",
    "plain_content": "<%body%>",
    "subject": "<%subject%>",
    "updated_at": "2014-03-19 18:56:33"
}

POST

Create a new version.

Parameter Required Requirements Description
name true String with fewer than 100 characters The name of the new version
subject true Requires a <%subject%> tag to be present The subject for the new version
html_content true Requires a <%body%> tag inside the content. There is a maximum of 1048576 bytes allowed for html content. The HTML content of the new version.
plain_content true Requires a <%body%> tag inside the content. There is a maximum of 1048576 bytes allowed for plain content. The text/plain content of the new version.
active false 0=Inactive, 1=Active Sets the active version associated with a template. Only one version of template can be active. The first version created for a template will automatically be set to Active.

Request

1
POST https://api.sendgrid.com/v3/templates/:template_id/versions HTTP/1.1
Request Body
1
2
3
4
5
6
7
{
  "name": "example_version_name",
  "html_content": "<%body%>",
  "plain_content": "<%body%>",
  "subject": "<%subject%>",
  "active": "1"
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
HTTP/1.1 201 OK

{
    "id": "8aefe0ee-f12b-4575-b5b7-c97e21cb36f3",
    "template_id": "ddb96bbc-9b92-425e-8979-99464621b543",
    "active": 1,
    "name": "example_version_name",
    "html_content": "<%body%>",
    "plain_content": "<%body%>",
    "subject": "<%subject%>",
    "updated_at": "2014-03-19 18:56:33"
}

POST

Activate a version.

Request

1
POST https://api.sendgrid.com/v3/templates/:template_id/versions/:version_id/activate HTTP/1.1

Response

1
2
3
4
5
6
7
8
9
10
11
12
HTTP/1.1 200 OK

{
    "id": "8aefe0ee-f12b-4575-b5b7-c97e21cb36f3",
    "template_id": "e3a61852-1acb-4b32-a1bc-b44b3814ab78",
    "active": 1,
    "name": "example_version_name",
    "html_content": "<%body%>",
    "plain_content": "<%body%>",
    "subject": "<%subject%>",
    "updated_at": "2014-06-12 11:33:00"
}

PATCH

Edit a version.

Parameter Required Requirements Description
name false String with fewer than 100 characters The updated name of the version
subject false Requires a <%subject%> tag to be present The updated subject for the new version
html_content false Requires a <%body%> tag inside the content. There is a maximum of 1048576 bytes allowed for html content. The HTML content of the new version.
plain_content false Requires a <%body%> tag inside the content. There is a maximum of 1048576 bytes allowed for plain content. The text/plain content of the new version.
active false 0=Inactive, 1=Active Sets the active version associated with a template. Only one version of template can be active.

Request

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

Response

1
2
3
4
5
6
7
8
9
10
11
12
HTTP/1.1 200 OK

{
    "id": "8aefe0ee-f12b-4575-b5b7-c97e21cb36f3",
    "template_id": "ddb96bbc-9b92-425e-8979-99464621b543",
    "active": 1,
    "name": "updated_example_name",
    "html_content": "<%body%>",
    "plain_content": "<%body%>",
    "subject": "<%subject%>",
    "updated_at": "2014-03-19 18:56:33"
}

DELETE

Delete a version.

Request

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

Response

1
HTTP/1.1 204 NO CONTENT (OK)