Skip to content

Create a template version

Request

Adds a new template version. If the template doesn’t contain any other versions, the first version becomes active. A template can store up to 40 versions.

Security
basicAuth
Path
domain_namestringrequired

Domain name the template is associated with.

template_namestringrequired

Template name to create the new version for.

Bodymultipart/form-datarequired
templatestringrequired

Content of the template.

tagstringrequired

Tag of the version that is being created. Must be unique to the template.

commentstring

Comment related to the version that is being created.

activestring

If this flag is set to yes, this version becomes active

headersstring

Key value JSON object of headers to be stored with the template. Where key is the header name and value is the header value. The header names From, Subject, and Reply-To are the only ones currently supported. These headers will be inserted into the MIME at the time we attempt delivery.

Headers set at the message level will override headers set on the template. e.g. Setting the From header at the time of sending will override the From header saved on the template. Additionally, headers generated by templates are not reflected on the accepted event as they are not prepended to the message until the message is prepped for delivery. if a From header is not provided either in the message or template, we will default to postmaster@your-sending-domain.tld

curl -i -X POST \
  -u '<username>:<password>' \
  'https://api.mailgun.net/v3/{domain_name}/templates/{template_name}/versions' \
  -H 'Content-Type: multipart/form-data' \
  -F template=string \
  -F tag=string \
  -F comment=string \
  -F active=string \
  -F headers=string

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Response message

templategithub.com-mailgun-temple-model-Template (object) or nullrequired
Any of:

Template details

Response
{ "message": "new version of the template has been stored", "template": { "name": "template_name", "description": "This is the description of the template", "createdAt": "Sat, 12 Nov 1955 06:38:00 UTC", "createdBy": "user-supplied-value", "id": "46565d87-68b6-4edb-8b3c-34554af4bb77", "domain": "header.tld", "version": {} } }