V3 REFERENCE Template

/template

List template resources available for this apikey, use a GET request. Alternatively, you may want to add one or more filters.

# list template resources

curl -s -X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template
Unique Key

In addition to the resource $ID, you can also use the unique key $OwnerType|$Name to identify this resource. Please refer to the field(s) description below for more information.

Properties
Name Description
Author The name of the author.
  • [ Type AnsiString ]
Categories list of strings in language string, list_type "Template categories" (27) E.g. "full", "basic", "newsletter", "e-commerce", "events", "travel", "sports", "welcome", "contact-property-update", "support", "invoice", "anniversary", "account", "activation"
  • [ Type TStrings ]
Copyright The copyright message.
  • [ Type AnsiString ]
Description The template description, free text.
  • [ Type AnsiString ]
EditMode tool(1), html(2), snippet(3), mjml(4)
  • [ Type SmallInt ]
ID The ID of template
  • Read Only
  • [ Type Int64 ]
IsStarred True if the template is starred for the current owner
  • [ Type Boolean ]
Locale Template's locale (AnsiString)
  • [ Type AnsiString ]
Name The template name.
  • [ Type AnsiString ]
OwnerId ID of the Owner. Depending on OwnerType resp. 1, User ID, akid . OwnerType and OwnerID determine the visibility for the template. An akid can GET the templates from Global, the templates from the user that owns the akid and the templates owned by the akid itself. An akid can modify the templates it owns directly or, if it is the master key, the ones that are owned by the user. This includes modifying OwnerType and OwnerID. The master key only can change the ownertype to user. Only the privileged apikey can change the ownertype to global. Name, OwnerType, OwnerID is a unique combination. Changing the ownertype could cause a duplicate and the API will also return a duplicate name error in that case.
  • Read Only
  • [ Type LongInt ]
OwnerType Global, User, Apikey.
  • [ Type TOwnerType ]

Allowed values:
  • apikey
  • user
  • global
Presets A JSON array containing the different styles pre-defined for this template.
  • [ Type AnsiString ]
Previews List of data id’s for the previews
  • Read Only
  • [ Type TIDList ]
Purposes List of strings in language string, list_type "Template purposes" (28) E.g. "marketing", "transactional", "automation"
  • [ Type TStrings ]
Filters
Name Description
APIKey Only retrieve template resources for which APIKey equals the specified value.
  • [ Type Int64 ]
Categories List of valid categories. Only retrieve template resources for which Catregories are among the listed/contain all the listed/are contained into the listed (depending of the specified CategoriesSelectionMethod).
  • [ Type AnsiString ]
CategoriesSelectionMethod One of the following values: containsany (default) / containsall / issubset. Describes the relation between the Categories filter's value and the template's purposes list.
  • [ Type AnsiString ]
EditMode Only retrieve template resources for which EditMode equals the specified value.
  • [ Type SmallInt ]
Name Only retrieve template resources for which Name equals the specified value.
  • [ Type AnsiString ]
OwnerType Only retrieve template resources for which OwnerType equals the specified value.
  • [ Type AnsiString ]
Purposes List of valid purposes. Only retrieve template resources for which Purposes are among the listed/contain all the listed/are contained into the listed (depending of the specified PurposesSelectionMethod).
  • [ Type AnsiString ]
PurposesSelectionMethod One of the following values: containsany (default) / containsall / issubset. Describes the relation between the Purposes filter's value and the template's purposes list.
  • [ Type AnsiString ]
User Only retrieve template resources for which User equals the specified value.
  • [ Type Int64 ]

Access a given template resource, use a GET request, providing the template's ID value.

# access the template resource identified by $ID

curl -s -X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$ID

    
# access the resource through the OwnerType|Name's value
# note: all keys marked as 'unique' may be used as an alternate ID

curl -s -X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$OwnerType|$Name
    
    
Unique Key

In addition to the resource $ID, you can also use the unique key $OwnerType|$Name to identify this resource. Please refer to the field(s) description below for more information.

Properties
Name Description
Author The name of the author.
  • [ Type AnsiString ]
Categories list of strings in language string, list_type "Template categories" (27) E.g. "full", "basic", "newsletter", "e-commerce", "events", "travel", "sports", "welcome", "contact-property-update", "support", "invoice", "anniversary", "account", "activation"
  • [ Type TStrings ]
Copyright The copyright message.
  • [ Type AnsiString ]
Description The template description, free text.
  • [ Type AnsiString ]
EditMode tool(1), html(2), snippet(3), mjml(4)
  • [ Type SmallInt ]
ID The ID of template
  • Read Only
  • [ Type Int64 ]
IsStarred True if the template is starred for the current owner
  • [ Type Boolean ]
Locale Template's locale (AnsiString)
  • [ Type AnsiString ]
Name The template name.
  • [ Type AnsiString ]
OwnerId ID of the Owner. Depending on OwnerType resp. 1, User ID, akid . OwnerType and OwnerID determine the visibility for the template. An akid can GET the templates from Global, the templates from the user that owns the akid and the templates owned by the akid itself. An akid can modify the templates it owns directly or, if it is the master key, the ones that are owned by the user. This includes modifying OwnerType and OwnerID. The master key only can change the ownertype to user. Only the privileged apikey can change the ownertype to global. Name, OwnerType, OwnerID is a unique combination. Changing the ownertype could cause a duplicate and the API will also return a duplicate name error in that case.
  • Read Only
  • [ Type LongInt ]
OwnerType Global, User, Apikey.
  • [ Type TOwnerType ]

Allowed values:
  • apikey
  • user
  • global
Presets A JSON array containing the different styles pre-defined for this template.
  • [ Type AnsiString ]
Previews List of data id’s for the previews
  • Read Only
  • [ Type TIDList ]
Purposes List of strings in language string, list_type "Template purposes" (28) E.g. "marketing", "transactional", "automation"
  • [ Type TStrings ]

Add a new template resource with a POST request.

# add a new template resource, beware of the Read Only fields!

curl -s -X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template \
-H 'Content-Type: application/json' \
-d '{"Author": ...}'
Unique Key

In addition to the resource $ID, you can also use the unique key $OwnerType|$Name to identify this resource. Please refer to the field(s) description below for more information.

Properties
Name Description
Author The name of the author.
  • [ Type AnsiString ]
Categories list of strings in language string, list_type "Template categories" (27) E.g. "full", "basic", "newsletter", "e-commerce", "events", "travel", "sports", "welcome", "contact-property-update", "support", "invoice", "anniversary", "account", "activation"
  • [ Type TStrings ]
Copyright The copyright message.
  • [ Type AnsiString ]
Description The template description, free text.
  • [ Type AnsiString ]
EditMode tool(1), html(2), snippet(3), mjml(4)
  • [ Type SmallInt ]
ID The ID of template
  • Read Only
  • [ Type Int64 ]
IsStarred True if the template is starred for the current owner
  • [ Type Boolean ]
Locale Template's locale (AnsiString)
  • [ Type AnsiString ]
Name The template name.
  • [ Type AnsiString ]
OwnerId ID of the Owner. Depending on OwnerType resp. 1, User ID, akid . OwnerType and OwnerID determine the visibility for the template. An akid can GET the templates from Global, the templates from the user that owns the akid and the templates owned by the akid itself. An akid can modify the templates it owns directly or, if it is the master key, the ones that are owned by the user. This includes modifying OwnerType and OwnerID. The master key only can change the ownertype to user. Only the privileged apikey can change the ownertype to global. Name, OwnerType, OwnerID is a unique combination. Changing the ownertype could cause a duplicate and the API will also return a duplicate name error in that case.
  • Read Only
  • [ Type LongInt ]
OwnerType Global, User, Apikey.
  • [ Type TOwnerType ]

Allowed values:
  • apikey
  • user
  • global
Presets A JSON array containing the different styles pre-defined for this template.
  • [ Type AnsiString ]
Previews List of data id’s for the previews
  • Read Only
  • [ Type TIDList ]
Purposes List of strings in language string, list_type "Template purposes" (28) E.g. "marketing", "transactional", "automation"
  • [ Type TStrings ]

Update one specific template resource with a PUT request, providing the template's ID value. Be sure to include all the mandatory properties.

# update content of resource template identified by ID $ID

curl -s -X PUT \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$ID \
-H 'Content-Type: application/json' \
-d '{"Author": ...}'

    
# update the content, using the value of the OwnerType|Name property
# note: all keys marked as 'unique' may be used as an alternate ID

curl -s -X PUT \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/:OwnerType|Name \
-H 'Content-Type: application/json' \
-d '{"Author": ...}'
    
Unique Key

In addition to the resource $ID, you can also use the unique key $OwnerType|$Name to identify this resource. Please refer to the field(s) description below for more information.

Properties
Name Description
Author The name of the author.
  • [ Type AnsiString ]
Categories list of strings in language string, list_type "Template categories" (27) E.g. "full", "basic", "newsletter", "e-commerce", "events", "travel", "sports", "welcome", "contact-property-update", "support", "invoice", "anniversary", "account", "activation"
  • [ Type TStrings ]
Copyright The copyright message.
  • [ Type AnsiString ]
Description The template description, free text.
  • [ Type AnsiString ]
EditMode tool(1), html(2), snippet(3), mjml(4)
  • [ Type SmallInt ]
ID The ID of template
  • Read Only
  • [ Type Int64 ]
IsStarred True if the template is starred for the current owner
  • [ Type Boolean ]
Locale Template's locale (AnsiString)
  • [ Type AnsiString ]
Name The template name.
  • [ Type AnsiString ]
OwnerId ID of the Owner. Depending on OwnerType resp. 1, User ID, akid . OwnerType and OwnerID determine the visibility for the template. An akid can GET the templates from Global, the templates from the user that owns the akid and the templates owned by the akid itself. An akid can modify the templates it owns directly or, if it is the master key, the ones that are owned by the user. This includes modifying OwnerType and OwnerID. The master key only can change the ownertype to user. Only the privileged apikey can change the ownertype to global. Name, OwnerType, OwnerID is a unique combination. Changing the ownertype could cause a duplicate and the API will also return a duplicate name error in that case.
  • Read Only
  • [ Type LongInt ]
OwnerType Global, User, Apikey.
  • [ Type TOwnerType ]

Allowed values:
  • apikey
  • user
  • global
Presets A JSON array containing the different styles pre-defined for this template.
  • [ Type AnsiString ]
Previews List of data id’s for the previews
  • Read Only
  • [ Type TIDList ]
Purposes List of strings in language string, list_type "Template purposes" (28) E.g. "marketing", "transactional", "automation"
  • [ Type TStrings ]

Remove one given template resource with a DELETE request, providing the template's ID value.

# delete resource template with ID $ID

curl -s -X DELETE \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$ID
    
# delete the resource using the alternate unique key OwnerType|Name
# note: all keys marked as 'unique' may be used as an alternate ID

curl -s -X DELETE \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/:OwnerType|Name
    
Unique Key

In addition to the resource $ID, you can also use the unique key $OwnerType|$Name to identify this resource. Please refer to the field(s) description below for more information.