# List of Templates

Endpoint: `GET https://api.mailjet.com/v1/REST/templates`

Using this endpoint, you can retrieve comprehensive list of templates and their corresponding data, including the `ExternalID` which is needed to send your templates.

## Query Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `Sort` | string | Sort is available for `Name`, `CreatedAt`, `IsStarred` and `UpdatedAt`. Default: `ID ASC`. |
| `CheckLocaleOnLastContent` | boolean | `True` = check the value of the `Locale` query parameter based on the last content |
| `ID` | integer | Search by the ID of the template. |
| `IDs` | array of integers | Search by multiple template IDs. |
| `Name` | string | Search by the template name. Only returns exact match. |
| `PartialName` | string | Search by partial or fragmentary name. |
| `Locale` | string | Search by the template locale. See the list of accepted locales. |
| `EditMode` | integer | Accepted values: `1`, `2`, `3` or `4`. See more about Edit mode. |
| `LabelIDs` | array of integers | Search by label IDs associated to a template. |
| `Purposes` | string | Comma-separated list of purposes. Filters templates having all specified purposes. Accepted values: `marketing`, `transactional`, `opt-in` and `automation`. Learn more about template purposes. |
| `ExternalID` | string | Search by the send ID of the template. |
| `IsPublished` | boolean | `True` = published |
| `IsStarred` | boolean | `True` = favorite |


### Example Request

```
curl --request GET \
  --url https://api.mailjet.com/v1/rest/templates?Limit=3&Sort=UpdatedAt%20DESC&IsStarred=false&Purposes=marketing' / \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3'
```

Status Code `200`

## Response Data Field Structure:

| Name | Type | Description |
|  --- | --- | --- |
| `ID` | integer | The ID of the template. |
| `Name` | string | The name of the template. |
| `EditMode` | integer | Specifies the mode in which the template can be edited. |
| `LabelIDs` | array of integers | An array of IDs representing labels associated with the template. |
| `Purposes` | array of strings | The type of template. Learn more about template purposes. |
| `ExternalID` | string or null | The ID that must be used to send the template. |
| `Description` | string or null | A brief description of the template. |
| `IsPublished` | boolean | Indicates whether the template is published. |
| `IsStarred` | boolean | Indicates whether the template is marked as a favorite. |
| `IsTextPartGenerationEnabled` | boolean | Determines if text part generation functionality is enabled for this template. |
| `CreatedAt` | Date RFC3339 | The date and time when the template was created. |
| `UpdatedAt` | Date RFC3339 | The date and time when the template was last updated. |


### API Reponse Example

```
{
	"Count": 3,
	"Total": 6,
	"Data": [
		{
			"ID": 12,
			"OrganisationID": 2,
			"Name": "Welcome to Mailjet1",
			"EditMode": 2,
			"LabelIDs": [],
			"LastContentType": null,
			"PartialIDs": [],
			"Purposes": [
				"marketing",
				"transactional"
			],
			"Categories": [
				"e-commerce"
			],
			"Presets": null,
			"ExternalID": "123",
			"Description": null,
			"IsPublished": false,
			"IsStarred": false,
			"SoftDeleted": false,
			"IsTextPartGenerationEnabled": false,
			"CreatedAt": "2024-04-19T11:44:24.0638Z",
			"UpdatedAt": "2024-04-19T11:44:24.0638Z"
		},
		{
			"ID": 11,
			"OrganisationID": 2,
			"Name": "Welcome to Mailjet2",
			"EditMode": 2,
			"LabelIDs": [],
			"LastContentType": null,
			"PartialIDs": [],
			"Purposes": [
				"marketing",
				"transactional"
			],
			"Categories": null,
			"Presets": null,
			"ExternalID": "456",
			"Description": null,
			"IsPublished": false,
			"IsStarred": false,
			"SoftDeleted": false,
			"IsTextPartGenerationEnabled": false,
			"CreatedAt": "2024-04-19T11:43:56.283337Z",
			"UpdatedAt": "2024-04-19T11:43:56.283337Z"
		},
		{
			"ID": 10,
			"OrganisationID": 2,
			"Name": "Welcome to Mailjet3",
			"EditMode": 2,
			"LabelIDs": [],
			"LastContentType": null,
			"PartialIDs": [],
			"Purposes": [
				"marketing",
				"transactional"
			],
			"Categories": null,
			"Presets": null,
			"ExternalID": "789",
			"Description": null,
			"IsPublished": false,
			"IsStarred": false,
			"SoftDeleted": false,
			"IsTextPartGenerationEnabled": false,
			"CreatedAt": "2024-04-19T11:33:57.789254Z",
			"UpdatedAt": "2024-04-19T11:33:57.789254Z"
		}
	]
}
```

## Retrieve a Single Template

Endpoint: `GET https://api.mailjet.com/v1/REST/templates/:id`

Using this endpoint, you can retrieve detailed information about a specific email template using its unique template ID. This endpoint is particularly useful when you need to fetch the details of a single template for viewing, editing, or sending purposes.

#### URL Parameters

`id` = The ID of the template.

### Example Request

```
curl --request GET \
  --url https://api.mailjet.com/v1/rest/templates/1 \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3'
```

Status code: `200`

### Response Data Field Structure:

| Name | Type | Description |
|  --- | --- | --- |
| `ID` | integer | The ID of the template. |
| `Name` | string | The name of the template. |
| `EditMode` | integer | Specifies the mode in which the template can be edited. |
| `LabelIDs` | array of integers | An array of IDs representing labels associated with the template. |
| `Purposes` | array of strings | The type of template. Learn more about template purposes. |
| `ExternalID` | string or null | The ID that must be used to send the template. |
| `Description` | string or null | A brief description of the template. |
| `IsPublished` | boolean | Indicates whether the template is published. |
| `IsStarred` | boolean | Indicates whether the template is marked as a favorite. |
| `IsTextPartGenerationEnabled` | boolean | Determines if text part generation functionality is enabled for this template. |
| `CreatedAt` | Date RFC3339 | The date and time when the template was created. |
| `UpdatedAt` | Date RFC3339 | The date and time when the template was last updated. |


### API Response Example

```
{
    "Count": 1,
    "Total": 1,
    "Data": [
        {
            "ID": 27,
            "OrganisationID": 2,
            "Name": "Welcome to Mailjet!",
            "EditMode": 2,
            "LabelIDs": [],
            "LastContentType": null,
            "PartialIDs": [],
            "Purposes": [
                "marketing",
                "transactional"
            ],
            "Categories": [
                "e-commerce"
            ],
            "Presets": null,
            "ExternalID": "123",
            "Description": null,
            "IsPublished": false,
            "IsStarred": true,
            "SoftDeleted": false,
            "IsTextPartGenerationEnabled": false,
            "CreatedAt": "2024-05-23T09:05:22.21546Z",
            "UpdatedAt": "2024-05-23T09:05:22.21546Z"
        }
    ]
}
```