# Update Template Content

Endpoint: `PUT https://api.mailjet.com/v1/REST/templates/:id/contents/types/:content_type`

You can use this endpoint to update draft template content. When you make updates, the endpoint takes the latest draft version, applies your changes, and creates a new draft version. This enables you to modify various elements of the template, such as the text, HTML, and headers.

Info
If your template content is published, you will can create template content at the following endpoint: `POST https://api.mailjet.com/v1/REST/templates/:id/contents.`

Once it is created, you can publish it using this endpoint: `POST https://api.mailjet.com/v1/REST/templates/:id/contents/publish.`

URL Parameters:

`id` = The ID of the template.
`content_type` = The content status that you wish to update. Accepted value: D (Draft).

### Body Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `Author` | string | The name of the person or entity creating the template content. |
| `Name` | string | The name of the template content. |
| `Locale` | string | Specifies the locale (language and region) for the template content. See the full list of accepted locales. |
| `MJMLPart` | string or null | The MJML code for the template. |
| `HTMLPart` | string or null | The HTML code for the template. |
| `TextPart` | string or null | The plain text version of the template content. |
| `Headers` | json string | Additional headers for the template in JSON format. |


### Example Request

```
curl --request PUT \
  --url https://api.mailjet.com//v1/rest/templates/27/contents/types/D \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --header 'Content-Type: application/json' \
  --data '{
      "Locale": "fr_FR",
      "Headers": {
          "Subject": "Welcome to Mailjet",
          "From": "MyCompany <info@mycompany.com>",
          "Reply-To": "",
          "SenderName": "My Company",
          "SenderEmail": "info@mycompany.com"
      },
      "HTMLPart": "<!doctype html><html><body><p>May the delivery force be with you!</p></body></html>",
      "TextPart": "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
      "Name": "New Name",
      "Author": "John Doe"
}'
```

Status Code `200`

### Response Data Field Structure

| Name | Type | Description |
|  --- | --- | --- |
| `ID` | integer | The ID of the content version. |
| `TemplateID` | integer | The ID of the template. |
| `ContentType` | string | "D", "P" or "A". Always "D" when created. |
| `Author` | string or null | The name of the person or entity creating the template content. |
| `Name` | string | The name of the template content. |
| `IsLocked` | boolean | If this field is true (locked), the template content cannot be edited. |
| `Locale` | string | Specifies the locale (language and region) for the template content. |
| `MJMLPart` | string or null | The MJML code for the template. |
| `HTMLPart` | string or null | The HTML code for the template. |
| `TextPart` | string or null | The plain text version of the template content. |
| `Headers` | json string | Additional headers for the template in JSON format. |
| `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

```
{
	"Count": 1,
	"Total": 1,
	"Data": [
		{
			"ID": 23,
			"OrganisationID": 2,
			"UserID": 2,
			"TemplateID": 27,
			"ContentType": "D",
			"Author": "John Doe",
			"Name": "New Name",
			"IsLocked": false,
			"Locale": "fr_FR",
			"Headers": {
				"Subject": "Welcome to Mailjet",
				"From": "MyCompany <info@mycompany.com>",
				"Reply-To": "",
				"SenderName": "My Company",
				"SenderEmail": "info@mycompany.com"
			},
			"HTMLPart": "<!doctype html><html><body><p>May the delivery force be with you!</p></body></html>",
			"TextPart": "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
			"CreatedAt": "2024-05-23T09:54:37.300091Z",
			"UpdatedAt": "2024-05-23T09:54:37.300091Z"
    }
	]
}
```