NAV
cURL PHP NODE RUBY PYTHON GO JAVA

Getting started

Welcome to this API reference. It has been designed to help you transition your API integration from Mandrill/Mailchimp to Mailjet.

Mailjet was built as an all-in-one solution from day one, being convinced that marketing and transactional email must closely feed into each other.

To ease the migration process, this documentation will follow the same layout as the Mandrill one, so you can easily find your way around our API and understands faster how to remap with your own integration.

Mandrill says Mailjet says Comments
merge vars contact metadata or variables Mailjet being an all-in-one solution, we accept both contact based properties and message variables
Messages Send API
Templates Template Mailjet API resource names are always singular
Senders Sender Mailjet API resource’s names are always singular
Webhook Event API
Inbound Parse API
Tags Custom ID

About the Mailjet RESTful API

API in a Nutshell

The Mailjet API is designed to be RESTful compliant. This means that the API communicates over HTTP (including the use of HTTP verbs) . The API allows you to create, read, update and delete (CRUD) resources. Also, each resource has a URI (Unique Resource Identifier) to help access its properties.

The CRUD methods on the Mailjet API correspond to HTTP verbs POST, GET, PUT and DELETE, so that, depending on the resources and providing you have the access rights, you can do the following :

Each resource has a list of properties and methods. You can see them in our API reference.

Authenticate

In order to use the Mailjet API you have to authenticate using HTTP Basic Auth. HTTP Basic Auth requires you to provide a username and a password for each API request. The username is your API Key and the password is your API Secret Key, which are both generated for you after registration.

#To make better use of our cURL examples you can set your keys in your environment variables with the following commands:
export MJ_APIKEY_PUBLIC=xxxxxxxxxxxxxxxxxxxxxx
export MJ_APIKEY_PRIVATE=xxxxxxxxxxxxxxxxxxxxxxx

#View user information : now, you don't need to replace $MJ_APIKEY_PUBLIC and $MJ_APIKEY_PRIVATE when running a cURL command
curl --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" https://api.mailjet.com/v3/REST/user

The server should respond with the following data:

{
    "Count": 1,
    "Data": [
        {
            "ACL": "",
            "CreatedAt": "",
            "Email": "miss@mailjet.com",
            "ID": "",
            "LastIp": "",
            "LastLoginAt": "",
            "Locale": "",
            "MaxAllowedAPIKeys": "5",
            "Timezone": "",
            "Username": "",
            "WarnedRatelimitAt": ""
        }
    ],
    "Total": 1
}

Most developers use one of our API libraries for their production systems and the respective library documentation tells you where to place your API Keys. However for testing purposes it can be nice to query the API directly from the shell.

In this example :

Both these keys can be found in your control panel, once you’re logged-in and your account is provisioned (activated).

The usual json payload response will have the following structure : {"Count": int, "Data": array, "Total": int} where Count and Total represent the number of lines affected by your API call. When using the countOnly filter Total will be the global number of elements corresponding to your API call.

Status Codes

These status codes will be sent back by the API to notify of the success or failure of your calls.

Code Description
200 OK All went well. Congrats!
201 Created The POST request was successfully executed.
204 No Content No content found or expected to return. Returned when DELETE was successful.
304 Not Modified The PUT request didn’t affect any record.
400 Bad Request One or more parameters are missing or maybe mispelled (unknown resource or action)
401 Unauthorized You have specified an incorrect Api Key / API Secret Key. You may be unauthorized to access the API or your API key may be expired. Visit API keys Management section to check your keys.
403 Forbidden You are not authorised to access this resource.
404 Not Found The resource with the specified ID you are trying to reach does not exist.
405 Method Not Allowed The method requested on the resource does not exist.
500 Internal Server Error Ouch! Something went wrong on our side and we apologize! Please contact our support team, who’ll be able to help you on this
{
    "ErrorInfo": "Bad Request",
    "ErrorMessage": "Unknown resource: \"contacts\"",
    "StatusCode": 400
}

In addition to the status codes, in case of error, you can find hints in a standardised JSON response with the reason under ErrorMessage.

Migration Tool

Our team developed a command line tool to easily transfer account setup from a Mandrill to a Mailjet.

The tool allows to migrate :

This tool is currently in private beta testing and hosted on Github. If you wish to have access to the beta testing, please send us a request to api@mailjet.com with your github username.

The libraries

Mailjet got your covered with wrappers in all the main programming languages:

You can find even more useful tools and plugins on the Mailjet GitHub

We welcome any contribution to these repositories.

Please follow the following intruction to make it easier to process your improvements :

Please do not include changes to the gemspec (Ruby), or version files.

Integrations

Worried about loosing your favorite Mandrill-integrated tools? Not to stress, we are integrated with many of the same tools as Mandrill…and much more:

Senders Calls

Introduction

Senders represent sender addresses or domains which have been validated on Mailjet’s system to send transactional emails. The Mailjet resource matching the senders Mandrill resource is sender.

List

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Sender);
$response->success() && var_dump($response->getData());
?>
# View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/sender
/**
 *
 * View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("sender")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Sender.all()
"""
View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.sender.get()
print result.status_code
print result.json()
/*
View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Sender
    _, _, err := mailjetClient.List("sender", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Sender;
public class MyClass {
    /**
     * View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Sender.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "CreatedAt": "2015-09-07T06:59:52Z",
            "DNSID": "1",
            "Email": "anothersender@example.com",
            "EmailType": "unknown",
            "Filename": "0123456789abcdef.txt",
            "ID": "1",
            "IsDefaultSender": "false",
            "Name": "Myname",
            "Status": "Inactive"
        }
    ],
    "Total": 1
}

Issue a GET request on the sender resource

Domains

The senders domains are included in the sender resource. A sender domain is represented in the form of “*@domain.com”.

Add-Domain

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Dns);
$response->success() && var_dump($response->getData());
?>
# View : Sender Domain properties.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/dns
/**
 *
 * View : Sender Domain properties.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("dns")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Sender Domain properties.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Dns.all()
"""
View : Sender Domain properties.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.dns.get()
print result.status_code
print result.json()
/*
View : Sender Domain properties.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Dns
    _, _, err := mailjetClient.List("dns", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Dns;
public class MyClass {
    /**
     * View : Sender Domain properties.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Dns.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "DKIMRecordName": "",
            "DKIMRecordValue": "",
            "DKIMStatus": "",
            "Domain": "",
            "ID": "",
            "IsCheckInProgress": "false",
            "LastCheckAt": "",
            "OwnerShipToken": "",
            "OwnerShipTokenRecordName": "",
            "SPFRecordValue": "",
            "SPFStatus": ""
        }
    ],
    "Total": 1
}

Everytime you post a new sender (address or domain) which doesn’t map to an existing domain in the Mailjet system, a new dns resource is created. You can then issue GET request on this request, using the ID or the domain name. The dns resource provides you with all the information you need to setup your domain in a valid way to start sending using a related sender address or domain.

Check-Domain

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->post(Resources::$DnsCheck, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Check : Run a check on a domain
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/dns/$ID_OR_DOMAINNAME/check \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Check : Run a check on a domain
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("dns")
    .id($ID_OR_DOMAINNAME)
    .action("check")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Check : Run a check on a domain
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Dns_check.create(id: $ID_OR_DOMAINNAME)
"""
Check : Run a check on a domain
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID_OR_DOMAINNAME'
result = mailjet.dns_check.create(id=id)
print result.status_code
print result.json()
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.DnsCheck;
public class MyClass {
    /**
     * Check : Run a check on a domain
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(DnsCheck.resource, ID);
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
/*
Check : Run a check on a domain
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.DnsCheck
    mr := &MailjetRequest{
      Resource: "dns",
      ID: RESOURCE_ID,
      Action: "check",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.DnsCheck {
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
{
    "Count": 1,
    "Data": [
        {
            "DKIMErrors": [ "no DKIM record" ],
            "DKIMRecordCurrentValue": "",
            "DKIMStatus": "Error",
            "SPFErrors": [],
            "SPFRecordsCurrentValues": [ "v=spf1 include:spf.mailjet.com -all" ],
            "SPFStatus": "OK"
        }
    ],
    "Total": 1
}

To check the configuration of a given domain, issue a POST request on dns/:id/check resource. This action checks if the DNS configuration for SPF and DKIM records matches the expected configuration from Mailjet.

Verify-Domain

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->post(Resources::$SenderValidate, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Validate : check if the Ownership token has been properly setup on the website or DNS
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/sender/$ID/validate \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Validate : check if the Ownership token has been properly setup on the website or DNS
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("sender")
    .id($ID)
    .action("validate")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Validate : check if the Ownership token has been properly setup on the website or DNS
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Sender_validate.create(id: $ID)
"""
Validate : check if the Ownership token has been properly setup on the website or DNS
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.sender_validate.create(id=id)
print result.status_code
print result.json()
/*
Validate : check if the Ownership token has been properly setup on the website or DNS
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.SenderValidate
    mr := &MailjetRequest{
      Resource: "sender",
      ID: RESOURCE_ID,
      Action: "validate",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.SenderValidate {
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.SenderValidate;
public class MyClass {
    /**
     * Validate : check if the Ownership token has been properly setup on the website or DNS
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(SenderValidate.resource, ID);
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
{
    "Count": 1,
    "Data": [
        {
            "Errors": {
                "DNSValidationError": " DNS record verification failed as no TXT record for that ownership token was found on the remote server.",
                "FileValidationError": " File verification failed as ecff63dc3593b2323b5ab3d7d823c103.txt cannot be found at domain root."
            },
            "GlobalError": "Neither the file at your domain root nor the DNS TXT record have been found to validate this sender.",
            "ValidationMethod": ""
        }
    ],
    "Total": 1
}

Once you cleared out your DNS configuration, you can validate the related sender

Info

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Sender);
$response->success() && var_dump($response->getData());
?>
# View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/sender
/**
 *
 * View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("sender")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Sender.all()
"""
View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.sender.get()
print result.status_code
print result.json()
/*
View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Sender
    _, _, err := mailjetClient.List("sender", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Sender;
public class MyClass {
    /**
     * View : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Sender.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "CreatedAt": "2015-09-07T06:59:52Z",
            "DNSID": "1",
            "Email": "anothersender@example.com",
            "EmailType": "unknown",
            "Filename": "0123456789abcdef.txt",
            "ID": "1",
            "IsDefaultSender": "false",
            "Name": "Myname",
            "Status": "Inactive"
        }
    ],
    "Total": 1
}

Issue a GET request to the sender resource with the associated ID.

Time-Series

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Senderstatistics);
$response->success() && var_dump($response->getData());
?>
# View : API Key sender email address message/open/click statistical information.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/senderstatistics
/**
 *
 * View : API Key sender email address message/open/click statistical information.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("senderstatistics")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : API Key sender email address message/open/click statistical information.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Senderstatistics.all()
"""
View : API Key sender email address message/open/click statistical information.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.senderstatistics.get()
print result.status_code
print result.json()
/*
View : API Key sender email address message/open/click statistical information.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Senderstatistics
    _, _, err := mailjetClient.List("senderstatistics", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Senderstatistics;
public class MyClass {
    /**
     * View : API Key sender email address message/open/click statistical information.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Senderstatistics.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "BlockedCount": "",
            "BouncedCount": "",
            "ClickedCount": "",
            "DeliveredCount": "",
            "LastActivityAt": "",
            "OpenedCount": "",
            "ProcessedCount": "",
            "QueuedCount": "",
            "SenderID": "",
            "SpamComplaintCount": "",
            "UnsubscribedCount": ""
        }
    ],
    "Total": 1
}

The senderstatistics resource will provide you with all the main information you need. By using the Sender query filter you can filter data only on the sender resource you’re interested in.

Messages Calls

Introduction

This is a key part of both APIs, since it is from here that you will be able to trigger transactional email. The key Mailjet API resources in that section are /send/message and /message.

Mailjet’s Send API allows you to send transactional emails using our HTTP API, using POST requests. This solution is aimed at users needing a programmatically way to send messages.

Send API allows you to send single messages but also to mutualise the calls by leveraging templating and personalization of the content.

The API will return a simple response indicating if the message is ready to be processed by the Mailjet system. This makes the error management on your side simple and efficient.

Our Send API offers templating features, similar to the Mandrill one. Please refer to our dedicated API guide here.

Send

from mailjet import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
    'FromEmail': 'pilot@mailjet.com',
    'FromName': 'Mailjet Pilot',
    'Subject': 'Your email flight plan!',
    'Text-part': 'Dear passenger, welcome to Mailjet! May the delivery force be with you!',
    'Html-part': '<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!',
    'Recipients': [{'Email':'passenger@mailjet.com'}]
}
result = mailjet.send.create(data=data)
print result.status_code
print result.json()
/*
This calls sends an email to one recipient.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    email := &MailjetSendMail {
      FromEmail: "pilot@mailjet.com",
      FromName: "Mailjet Pilot",
      Subject: "Your email flight plan!",
      TextPart: "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
      HtmlPart: "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
      Recipients: []MailjetRecipient {
        MailjetRecipient {
          Email: "passenger@mailjet.com",
        },
      },
    }
    res, err := mailjetClient.SendMail(email)
    if err != nil {
            fmt.Println(err)
    } else {
            fmt.Println("Success")
            fmt.Println(res)
    }
}
<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'FromEmail' => "pilot@mailjet.com",
    'FromName' => "Mailjet Pilot",
    'Subject' => "Your email flight plan!",
    'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
    'Html-part' => "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
    'Recipients' => [
        [
            'Email' => "passenger@mailjet.com"
        ]
    ]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Send.create(
        from_email: "pilot@mailjet.com",
        from_name: "Mailjet Pilot",
        subject: "Your email flight plan!",
        text_part: "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
        html_part: "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
        recipients: [{ 'Email'=> 'passenger@mailjet.com'}])
package MyClass;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Email;
public class MyClass {
    /**
     * This calls sends an email to one recipient.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Email.resource)
                        .property(Email.FROMEMAIL, "pilot@mailjet.com")
                        .property(Email.FROMNAME, "Mailjet Pilot")
                        .property(Email.SUBJECT, "Your email flight plan!")
                        .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                        .property(Email.HTMLPART, "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!")
                        .property(Email.RECIPIENTS, new JSONArray()
                .put(new JSONObject()
                    .put("Email", "passenger@mailjet.com")));
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
# This calls sends an email to one recipient.
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/send \
    -H 'Content-Type: application/json' \
    -d '{
        "FromEmail":"pilot@mailjet.com",
        "FromName":"Mailjet Pilot",
        "Subject":"Your email flight plan!",
        "Text-part":"Dear passenger, welcome to Mailjet! May the delivery force be with you!",
        "Html-part":"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
        "Recipients":[{"Email":"passenger@mailjet.com"}]
    }'
/**
 *
 * This calls sends an email to one recipient.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("send")
    .request({
        "FromEmail":"pilot@mailjet.com",
        "FromName":"Mailjet Pilot",
        "Subject":"Your email flight plan!",
        "Text-part":"Dear passenger, welcome to Mailjet! May the delivery force be with you!",
        "Html-part":"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
        "Recipients":[{"Email":"passenger@mailjet.com"}]
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });

API response:

{
    "Sent": [
        {
            "Email": "passenger@mailjet.com",
            "MessageID": 111111111111111
        }
    ]
}

Here are the Mailjet Send API properties definitions, along with samples in all the languages we support through our official libraries.

Property Name Description
FromEmail Must be a valid, activated and registered sender for this account
May include the name part: john@example.com or <john@example.com> or "John Doe" <john@example.com>
MANDATORY - MAX FROM: 1
FromName Must be a valid, activated and registered sender for this account
May include the name part: john@example.com or <john@example.com> or "John Doe" <john@example.com>
MANDATORY - MAX FROM: 1
Sender This can be set only on given API Keys. Contact the support team if you want us to enable this setting on your account.
Must be a valid active sender for this account.
Perform a simple GET on resource /sender to view a list of allowed senders for your account, or within the Mailjet Account Settings under Sender Addresses
MAX SENDER: 1
Recipients List of recipients, must include at least a property Email in each element
Sample: [{"Email":"passenger@mailjet.com","Name":"passenger"}]
MANDATORY
To May include the name part: john@example.com or <john@example.com> or "John Doe" <john@example.com>
If a recipient is specified twice (in the to, cc, or bcc), it is counted only once.
Can be a magic list @lists.mailjet.com. See the Address contactslist property.
MAX RECIPIENTS: 50
Cc, Bcc May include the name part: john@example.com or <john@example.com> or "John Doe" <john@example.com>
If one recipient is specified twice, it will be counted as one only (including to, cc, bcc)
MAX RECIPIENTS: 50
Cc and Bcc can’t be used in conjunction with Recipients property
Subject At least 1 char, maximum length is 255 chars
MANDATORY - MAX SUBJECTS: 1
Text-part Provides the Text part of the message
Mandatory if the HTML param is not specified
MANDATORY IF NO HTML - MAX PARTS: 1
Html-part Provides the HTML part of the message
Mandatory if the text param is not specified
MANDATORY IF NO TEXT - MAX PARTS: 1
Mj-TemplateID The Template ID or Name to be used as content for this email. Overrides the HTML/Text parts if any.
MANDATORY IF NO HTML/TEXT - MAX TEMPLATEID: 1
Mj-TemplateLanguage Activate the template language processing. By default the template language processing is desactivated. Use True to activate.
Equivalent to using the X-MJ-TemplateLanguage header through SMTP.
More information
MJ-TemplateErrorReporting Email Address where a carbon copy with error message is sent to.
Equivalent to using the X-MJ-TemplateErrorReporting header through SMTP.
More information
MJ-TemplateErrorDeliver Define if the message is delivered if an error is discovered in the templating language. By default the delivery is desactivated. Use deliver to let the message be delivered to the recipient, 0 to stop it.
Equivalent to using the X-MJ-TemplateErrorDeliver header through SMTP.
More information
Attachments Attach files automatically to this Email
Sum of all attachments, including inline may not exceed 15 MB total
Sample: [{“Content-type”: “MIME TYPE”, “Filename”: “FILENAME.EXT”, “content”:“BASE64 ENCODED CONTENT”}]
Inline_attachments Attach a file for inline use via cid:FILENAME.EXT
Sum of all attachements, including inline may not exceed 15 MB total
Sample: [{“Content-type”: “MIME TYPE”, “Filename”: “FILENAME.EXT”, “content”:“BASE64 ENCODED CONTENT”}]
Mj-prio Manage message processing priority inside your account (API key) scheduling queue.
Default is 2 as in the SMTP submission.
Equivalent of using X-Mailjet-Prio header through SMTP
More information
Mj-campaign Groups multiple messages in one campaign
Equivalent of using X-Mailjet-Campaign header through SMTP.
More information
Mj-deduplicatecampaign Block/unblock messages to be sent multiple times inside one campaign to the same contact.
0: unblocked (default behavior) - 1: blocked
Equivalent of using X-Mailjet-DeduplicateCampaign header through SMTP.
Can only be used if mj-campaign is specified.
More information
Mj-trackopen Force or disable open tracking on this message, overriding preferences.
Equivalent of using X-Mailjet-TrackOpen header through SMTP.
Can only be used with a HTML part.
More information
Mj-trackclick Force or disable click tracking on this message, overriding preferences.
Equivalent to using the X-Mailjet-TrackClick header through SMTP.
Can only be specified if the HTML part is provided.
More information
Mj-CustomID Attach a custom ID to the message
Equivalent to using the X-MJ-CustomID header through SMTP.
More information
Mj-EventPayLoad Attach a payload to the message
Equivalent to using the X-MJ-EventPayload header through SMTP.
More information
Headers Add lines to the email headers
List of headers as "property":"value" pairs
Notice: overriding values of header properties (ie: subject)
Sample: {"X-My-Header":"my own value", "X-My-Header-2":"my own value 2"}
Vars Global variables used for personalisation
Messages List of messages
Used for bulk emailing.
More information

Send-Template

package MyClass;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.errors.MailjetClient;
import com.mailjet.client.errors.MailjetRequest;
import com.mailjet.client.errors.MailjetResponse;
import com.mailjet.client.resource.Email;
public class MyClass {
    /**
     * This calls sends an email to one recipient.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Email.resource)
                        .property(Email.FROMEMAIL, "pilot@mailjet.com")
                        .property(Email.FROMNAME, "Mailjet Pilot")
                        .property(Email.MJTEMPLATEID, 1)
                        .property(Email.MJTEMPLATELANGUAGE, true)
                        .property(Email.SUBJECT, "Your email flight plan!")
                        .property(Email.RECIPIENTS, new JSONArray()
                .put(new JSONObject()
                    .put("Email", "passenger@mailjet.com")))
                        .property(Email.MJEVENTPAYLOAD, "Eticket,1234,row,15,seat,B");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'FromEmail' => "pilot@mailjet.com",
    'FromName' => "Mailjet Pilot",
    'Subject' => "Your email flight plan!",
    'MJ-TemplateID' => 1,
    'MJ-TemplateLanguage' => true,
    'Recipients' => [['Email' => "passenger@mailjet.com"]]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
# This calls sends an email to one recipient.
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/send \
    -H 'Content-Type: application/json' \
    -d '{
        "FromEmail":"pilot@mailjet.com",
        "FromName":"Mailjet Pilot",
        "Subject":"Your email flight plan!",
        "MJ-TemplateID":"1",
        "MJ-TemplateLanguage":true,
        "Recipients":[
                {
                        "Email": "passenger@mailjet.com"
                }
        ]
    }'
/**
 *
 * This calls sends an email to one recipient.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("send")
    .request({
        "FromEmail":"pilot@mailjet.com",
        "FromName":"Mailjet Pilot",
        "Subject":"Your email flight plan!",
        "MJ-TemplateID":"1",
        "MJ-TemplateLanguage":"true",
        "Recipients":[
                {
                        "Email": "passenger@mailjet.com"
                }
        ]
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# This calls sends an email to one recipient.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Send.create(
  from_email: "pilot@mailjet.com",
  from_name: "Mailjet Pilot",
  subject: "Your email flight plan!",
  "Mj-TemplateID": "1",
  "Mj-TemplateLanguage": true,
  recipients: [{ 'Email'=> 'passenger@mailjet.com'}]
)
"""
This calls sends an email to one recipient.
"""
from mailjet import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'FromEmail': 'pilot@mailjet.com',
  'FromName': 'Mailjet Pilot',
  'Subject': 'Your email flight plan!',
  'MJ-TemplateID': '1',
  'MJ-TemplateLanguage': true,
  'Recipients': [
                {
                        "Email": "passenger@mailjet.com"
                }
        ]
}
result = mailjet.send.create(data=data)
print result.status_code
print result.json()
/*
This calls sends an email to one recipient.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    email := &MailjetSendMail {
      FromEmail: "pilot@mailjet.com",
      FromName: "Mailjet Pilot",
      Subject: "Your email flight plan!",
      MJTemplateID: 1,
      MJTemplateLanguage: "true",
      Recipients: []MailjetRecipient {
        MailjetRecipient {
          Email: "passenger@mailjet.com",
        },
      },
    },
    res, err := mailjetClient.SendMail(email)
    if err != nil {
            fmt.Println(err)
    } else {
            fmt.Println("Success")
            fmt.Println(res)
    }
}

API response:

{
    "Sent": [
        {
            "Email": "passenger@mailjet.com",
            "MessageID": 111111111111111
        }
    ]
}

First, please visit our Templates dedicated section to learn how to create and store templates with the Mailjet API.

Use the Mj-TemplateID property in your Send API payload to specify the ID of the the template you created.

You must set the Mj-TemplateLanguage property in the payload at true to have the templating language interpreted.

Mailjet offers a templating language to customize the content of your messages, based on conditions and loops. Please visit our dedicated API guide section to learn more

The response payload of a Send API call will provide you with the MessageID of your messages. You can use this MessageID to access information and statistics about the message.

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Message, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# View : Details of a specific Message (e-mail) processed by Mailjet
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/message/$ID_MESSAGE
/**
 *
 * View : Details of a specific Message (e-mail) processed by Mailjet
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("message")
    .id($ID_MESSAGE)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Details of a specific Message (e-mail) processed by Mailjet
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Message.find($ID_MESSAGE)
"""
View : Details of a specific Message (e-mail) processed by Mailjet
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID_MESSAGE'
result = mailjet.message.get(id=id)
print result.status_code
print result.json()
/*
View : Details of a specific Message (e-mail) processed by Mailjet
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Message
    mr := &MailjetRequest{
      Resource: "message",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Get(mr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Message;
public class MyClass {
    /**
     * View : Details of a specific Message (e-mail) processed by Mailjet
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Message.resource, ID);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ArrivedAt": "2015-07-06T07:10:24Z",
            "AttachmentCount": "0",
            "AttemptCount": "0",
            "CampaignID": "51",
            "ContactID": "45",
            "Delay": "0",
            "DestinationID": "14",
            "FilterTime": "61",
            "FromID": "1",
            "ID": "16888509234525280",
            "IsClickTracked": "false",
            "IsHTMLPartIncluded": "false",
            "IsOpenTracked": "false",
            "IsTextPartIncluded": "false",
            "IsUnsubTracked": "false",
            "MessageSize": "20248",
            "SpamassassinScore": "0",
            "SpamassRules": "",
            "StateID": "0",
            "StatePermanent": "false",
            "Status": "sent"
        }
    ],
    "Total": 1
}

Perform a GET on /message to get basic information about a message, such as the contact it was sent to, who it was sent by, if there were any attachments and how large the message was.

The StateID property shows the current status the messages are in. To get the full listing of StateId and their meaning, use the /messagestate resource.

Search-Time-Series

Filter by time range

Leveraging the FromTs and ToTs query filters of the message API resource, you can find messages matching the period. These filters expect UNIX epoch timestamp.

Filter by tag (custom ID)

You can find all the messages associated to a given custom ID (limited to 1 per message at the moment) through the CustomID query filter of the messagesentstatistics resource.

Filter by sender domain

You can filter all the messages sent from a given domain using the FromID query filter of the messagesentstatistics resource. The ID refers to a valid sender resource

Info

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Message, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# View : Details of a specific Message (e-mail) processed by Mailjet
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/message/$ID_MESSAGE
/**
 *
 * View : Details of a specific Message (e-mail) processed by Mailjet
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("message")
    .id($ID_MESSAGE)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Details of a specific Message (e-mail) processed by Mailjet
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Message.find($ID_MESSAGE)
"""
View : Details of a specific Message (e-mail) processed by Mailjet
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID_MESSAGE'
result = mailjet.message.get(id=id)
print result.status_code
print result.json()
/*
View : Details of a specific Message (e-mail) processed by Mailjet
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Message
    mr := &MailjetRequest{
      Resource: "message",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Get(mr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Message;
public class MyClass {
    /**
     * View : Details of a specific Message (e-mail) processed by Mailjet
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Message.resource, ID);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ArrivedAt": "2015-07-06T07:10:24Z",
            "AttachmentCount": "0",
            "AttemptCount": "0",
            "CampaignID": "51",
            "ContactID": "45",
            "Delay": "0",
            "DestinationID": "14",
            "FilterTime": "61",
            "FromID": "1",
            "ID": "16888509234525280",
            "IsClickTracked": "false",
            "IsHTMLPartIncluded": "false",
            "IsOpenTracked": "false",
            "IsTextPartIncluded": "false",
            "IsUnsubTracked": "false",
            "MessageSize": "20248",
            "SpamassassinScore": "0",
            "SpamassRules": "",
            "StateID": "0",
            "StatePermanent": "false",
            "Status": "sent"
        }
    ],
    "Total": 1
}

Issue a GET request to message containing the ID which was returned by our Send API

Templates Calls

Introduction

In the Mailjet API, Templates are handled with the /template resource and it’s sub-resource /template/$id/detailcontent.

/template is the definition of the basic template information.

/template/$id/detailcontent stores the content of the template.

For more information, visit Transactional templating guide.

Add

Adding a template is done in 2 steps:

Creating the template

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'Name' => "First Template"
];
$response = $mj->post(Resources::$Template, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Create : 
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template \
    -H 'Content-Type: application/json' \
    -d '{
        "Name":"First Template"
    }'
/**
 *
 * Create : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("template")
    .request({
        "Name":"First Template"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Create : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Template.create(name: "First Template")
"""
Create : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'Name': 'First Template'
}
result = mailjet.template.create(data=data)
print result.status_code
print result.json()
/*
Create : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Template
    mr := &MailjetRequest{
      Resource: "template",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Template {
      Name: "First Template",
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Template;
public class MyClass {
    /**
     * Create : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Template.resource)
                        .property(Template.NAME, "First Template");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "Author": "",
            "Categories": "",
            "Copyright": "",
            "Description": "",
            "EditMode": "",
            "ID": "",
            "IsStarred": "false",
            "Name": "First Template",
            "OwnerId": "5",
            "OwnerType": "",
            "Presets": "",
            "Previews": "",
            "Purposes": ""
        }
    ],
    "Total": 1
}

Issue a POST request to template

Updating the content

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'Html-part' => "Hello <strong>world</strong>!",
    'Text-part' => "Hello world!"
];
$response = $mj->post(Resources::$TemplateDetailcontent, ['id' => $id, 'body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Create : Template content
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template/$ID/detailcontent \
    -H 'Content-Type: application/json' \
    -d '{
        "Html-part":"Hello <strong>world</strong>!",
        "Text-part":"Hello world!"
    }'
/**
 *
 * Create : Template content
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("template")
    .id($ID)
    .action("detailcontent")
    .request({
        "Html-part":"Hello <strong>world</strong>!",
        "Text-part":"Hello world!"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Create : Template content
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Template_detailcontent.create(id: $ID, , html_part: "Hello <strong>world</strong>!",text_part: "Hello world!")
"""
Create : Template content
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
data = {
  'Html-part': 'Hello <strong>world</strong>!',
  'Text-part': 'Hello world!'
}
result = mailjet.template_detailcontent.create(id=id, data=data)
print result.status_code
print result.json()
/*
Create : Template content
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.TemplateDetailcontent
    mr := &MailjetRequest{
      Resource: "template",
      ID: RESOURCE_ID,
      Action: "detailcontent",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.TemplateDetailcontent {
      HtmlPart: "Hello <strong>world</strong>!",
      TextPart: "Hello world!",
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.TemplateDetailcontent;
public class MyClass {
    /**
     * Create : Template content
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(TemplateDetailcontent.resource, ID)
                        .property(TemplateDetailcontent.HTMLPART, "Hello <strong>world</strong>!")
                        .property(TemplateDetailcontent.TEXTPART, "Hello world!");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "Html-part": "Hello <strong>world</strong>!",
            "Text-part": "Hello world!"
        }
    ],
    "Total": 1
}

Issue a POST request to template/$ID/detailcontent with the ID to set your content

Info

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Template, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# View : 
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template/$ID
/**
 *
 * View : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("template")
    .id($ID)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Template.find($ID)
"""
View : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.template.get(id=id)
print result.status_code
print result.json()
/*
View : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Template
    mr := &MailjetRequest{
      Resource: "template",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Get(mr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Template;
public class MyClass {
    /**
     * View : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Template.resource, ID);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "Author": "",
            "Categories": "",
            "Copyright": "",
            "Description": "",
            "EditMode": "",
            "ID": "",
            "IsStarred": "false",
            "Name": "First Template",
            "OwnerId": "5",
            "OwnerType": "",
            "Presets": "",
            "Previews": "",
            "Purposes": ""
        }
    ],
    "Total": 1
}

Issue a GET request to template with the ID to get specific template

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$TemplateDetailcontent, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# View : 
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template/$ID/detailcontent 
/**
 *
 * View : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("template")
    .id($ID)
    .action("detailcontent")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Template_detailcontent.find($ID)
"""
View : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.template_detailcontent.get(id=id)
print result.status_code
print result.json()
/*
View : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.TemplateDetailcontent
    mr := &MailjetRequest{
      Resource: "template",
      ID: RESOURCE_ID,
      Action: "detailcontent",
    }
    err := mailjetClient.Get(mr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.TemplateDetailcontent;
public class MyClass {
    /**
     * View : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(TemplateDetailcontent.resource, ID);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "Html-part": "Hello <strong>world</strong>!",
            "Text-part": "Hello world!"
        }
    ],
    "Total": 1
}

Issue a GET request to template/$ID/detailcontent with the ID to get specific template content

Update

# Modify : 
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":"",
        "Categories":"",
        "Copyright":"",
        "Description":"",
        "EditMode":"",
        "IsStarred":"false",
        "Presets":"",
        "Purposes":""
    }'
/**
 *
 * Modify : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .put("template")
    .id($ID)
    .request({
        "Author":"",
        "Categories":"",
        "Copyright":"",
        "Description":"",
        "EditMode":"",
        "IsStarred":"false",
        "Presets":"",
        "Purposes":""
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'Author' => "",
    'Categories' => "",
    'Copyright' => "",
    'Description' => "",
    'EditMode' => "",
    'IsStarred' => "false",
    'Presets' => "",
    'Purposes' => ""
];
$response = $mj->put(Resources::$Template, ['id' => $id, 'body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Modify : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Template.find($ID)
target.update_attributes(author: "",categories: "",copyright: "",description: "",edit_mode: "",is_starred: "false",presets: "",purposes: "")
"""
Modify : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
data = {
  'Author': '',
  'Categories': '',
  'Copyright': '',
  'Description': '',
  'EditMode': '',
  'IsStarred': 'false',
  'Presets': '',
  'Purposes': ''
}
result = mailjet.template.update(id=id, data=data)
print result.status_code
print result.json()
/*
Modify : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "template",
      ID: RESOURCE_ID,
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Template {
      Author: ,
      Categories: ,
      Copyright: ,
      Description: ,
      EditMode: ,
      IsStarred: "false",
      Presets: ,
      Purposes: ,
    },
    }
    err := mailjetClient.Put(fmr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Template;
public class MyClass {
    /**
     * Modify : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Template.resource, ID)
                        .property(Template.AUTHOR, )
                        .property(Template.CATEGORIES, )
                        .property(Template.COPYRIGHT, )
                        .property(Template.DESCRIPTION, )
                        .property(Template.EDITMODE, )
                        .property(Template.ISSTARRED, "false")
                        .property(Template.PRESETS, )
                        .property(Template.PURPOSES, );
      response = client.put(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

Issue a PUT request to template with the ID to get specific template

Delete

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->delete(Resources::$Template, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Delete : 
curl -s \
    -X DELETE \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template/$ID \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Delete : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .delete("template")
    .id($ID)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Delete : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Template.find($ID)
target.delete()
"""
Delete : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.template.delete(id=id)
print result.status_code
print result.json()
/*
Delete : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "template",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Delete(mr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Template;
public class MyClass {
    /**
     * Delete : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Template.resource, ID);
      response = client.delete(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

Issue a DELETE request to template with the ID to get specific template

List

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Template);
$response->success() && var_dump($response->getData());
?>
# View : 
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/template 
/**
 *
 * View : 
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("template")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : 
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Template.all()
"""
View : 
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.template.get()
print result.status_code
print result.json()
/*
View : 
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Template
    _, _, err := mailjetClient.List("template", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Template;
public class MyClass {
    /**
     * View : 
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Template.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "Author": "",
            "Categories": "",
            "Copyright": "",
            "Description": "",
            "EditMode": "",
            "ID": "",
            "IsStarred": "false",
            "Name": "First Template",
            "OwnerId": "5",
            "OwnerType": "",
            "Presets": "",
            "Previews": "",
            "Purposes": ""
        }
    ],
    "Total": 1
}

Issue a GET request to template

Migrate your templates

Mailjet Templating Language uses a syntax closer to templating language like Jinja2 (Python) or Twig (PHP).

Feature Mandrill syntax Mailjet syntax Comments
Conditions {{#if condition}}...{/if}} {% if condition %}...{% endif %}
Loops {{#each list}}...{{this}}...{{/each}} {% for foo in bar %}{{foo}}{% endfor %}
Nested Variables {{foo.bar}} {{foo.bar}}
Variables {{foobar}} {{data:foobar}} or {{var:foobar}} Transactional messages can contain both contact properties or message variables

Webhooks Calls

Introduction

Instead of polling to get data, you can use our Event API for your system to be notified in near real-time when any event you’ve subscribed to happen. The Mailjet resource involved here is eventcallbackurl, which lets you define a webhook per event type we support (including sent,open,click,bounce,blocked and spam).

List

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Eventcallbackurl);
$response->success() && var_dump($response->getData());
?>
# View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/eventcallbackurl
/**
 *
 * View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("eventcallbackurl")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
"""
View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.eventcallbackurl.get()
print result.status_code
print result.json()
# View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Eventcallbackurl.all()
/*
View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Eventcallbackurl
    _, _, err := mailjetClient.List("eventcallbackurl", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Eventcallbackurl;
public class MyClass {
    /**
     * View : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Eventcallbackurl.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKeyID": "",
            "EventType": "",
            "ID": "",
            "IsBackup": "false",
            "Status": "",
            "Url": "",
            "Version": ""
        }
    ],
    "Total": 1
}

Issue a GET request to eventcallbackurl to list all the resources for your current API key.

Add

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'EventType' => "open",
    'Url' => "https://mydomain.com/event_handler"
];
$response = $mj->post(Resources::$Eventcallbackurl, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Create an handler for the open event
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/eventcallbackurl \
    -H 'Content-Type: application/json' \
    -d '{
        "EventType":"open",
        "Url":"https://mydomain.com/event_handler"
    }'
/**
 *
 * Create an handler for the open event
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("eventcallbackurl")
    .request({
        "EventType":"open",
        "Url":"https://mydomain.com/event_handler"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Create an handler for the open event
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Eventcallbackurl.create(event_type: "open",url: "https://mydomain.com/event_handler")
"""
Create an handler for the open event
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'EventType': 'open',
  'Url': 'https://mydomain.com/event_handler'
}
result = mailjet.eventcallbackurl.create(data=data)
print result.status_code
print result.json()
/*
Create an handler for the open event
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Eventcallbackurl
    mr := &MailjetRequest{
      Resource: "eventcallbackurl",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Eventcallbackurl {
      EventType: "open",
      Url: "https://mydomain.com/event_handler",
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Eventcallbackurl;
public class MyClass {
    /**
     * Create an handler for the open event
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Eventcallbackurl.resource)
                        .property(Eventcallbackurl.EVENTTYPE, "open")
                        .property(Eventcallbackurl.URL, "https://mydomain.com/event_handler");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKey": "",
            "EventType": "",
            "ID": "",
            "IsBackup": "false",
            "Status": "",
            "Url": "",
            "Version": ""
        }
    ],
    "Total": 1
}

Issue a POST request to eventcallbackurl to create a new event subscriber.

Info

Issue a GET request to eventcallbackurl with the ID or the event type to list it. See #List above.

Update

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'APIKeyID' => "",
    'IsBackup' => "false",
    'Status' => "",
    'Url' => "",
    'Version' => ""
];
$response = $mj->put(Resources::$Eventcallbackurl, ['id' => $id, 'body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
curl -s \
    -X PUT \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/eventcallbackurl/$ID \
    -H 'Content-Type: application/json' \
    -d '{
        "APIKeyID":"",
        "IsBackup":"false",
        "Status":"",
        "Url":"",
        "Version":""
    }'
/**
 *
 * Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .put("eventcallbackurl")
    .id($ID)
    .request({
        "APIKeyID":"",
        "IsBackup":"false",
        "Status":"",
        "Url":"",
        "Version":""
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Eventcallbackurl.find($ID)
target.update_attributes(apikey_id: "",is_backup: "false",status: "",url: "",version: "")
"""
Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
data = {
  'APIKeyID': '',
  'IsBackup': 'false',
  'Status': '',
  'Url': '',
  'Version': ''
}
result = mailjet.eventcallbackurl.update(id=id, data=data)
print result.status_code
print result.json()
/*
Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "eventcallbackurl",
      ID: RESOURCE_ID,
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Eventcallbackurl {
      APIKeyID: ,
      IsBackup: "false",
      Status: ,
      Url: ,
      Version: ,
    },
    }
    err := mailjetClient.Put(fmr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Eventcallbackurl;
public class MyClass {
    /**
     * Modify : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Eventcallbackurl.resource, ID)
                        .property(Eventcallbackurl.APIKEYID, )
                        .property(Eventcallbackurl.ISBACKUP, "false")
                        .property(Eventcallbackurl.STATUS, )
                        .property(Eventcallbackurl.URL, )
                        .property(Eventcallbackurl.VERSION, );
      response = client.put(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKeyID": "",
            "EventType": "",
            "ID": "",
            "IsBackup": "false",
            "Status": "",
            "Url": "",
            "Version": ""
        }
    ],
    "Total": 1
}

Issue a PUT request to eventcallbackurl with the ID to update

Delete

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->delete(Resources::$Eventcallbackurl, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
curl -s \
    -X DELETE \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/eventcallbackurl/$ID \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .delete("eventcallbackurl")
    .id($ID)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Eventcallbackurl.find($ID)
target.delete()
"""
Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.eventcallbackurl.delete(id=id)
print result.status_code
print result.json()
/*
Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "eventcallbackurl",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Delete(mr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Eventcallbackurl;
public class MyClass {
    /**
     * Delete : Manage event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Eventcallbackurl.resource, ID);
      response = client.delete(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKeyID": "",
            "EventType": "",
            "ID": "",
            "IsBackup": "false",
            "Status": "",
            "Url": "",
            "Version": ""
        }
    ],
    "Total": 1
}

Issue a PUT request to eventcallbackurl with the ID to delete

Events content sample

All JSON event objects contain the following properties:

Sent event

Sample sent event:

{
   "event": "sent",
   "time": 1433333949,
   "MessageID": 19421777835146490,
   "email": "api@mailjet.com",
   "mj_campaign_id": 7257,
   "mj_contact_id": 4,
   "customcampaign": "",
   "mj_message_id": "19421777835146490",
   "smtp_reply": "sent (250 2.0.0 OK 1433333948 fa5si855896wjc.199 - gsmtp)",
   "CustomID": "helloworld",
   "Payload": ""
}

Dispatched when the destination SMTP server (gmail, hotmail, yahoo, etc) has accepted the message. Depending on your volume, it could dispatch a lot of events to your system. See Event grouping section to group events together.

Sent event additional properties:

Open event

Sample open event

{
   "event": "open",
   "time": 1433103519,
   "MessageID": 19421777396190490,
   "email": "api@mailjet.com",
   "mj_campaign_id": 7173,
   "mj_contact_id": 320,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "ip": "127.0.0.1",
   "geo": "US",
   "agent": "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0"
}

Open event additional properties:

Click event

Sample click event

{
   "event": "click",
   "time": 1433334653,
   "MessageID": 19421777836302490,
   "email": "api@mailjet.com",
   "mj_campaign_id": 7272,
   "mj_contact_id": 4,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "url": "https://mailjet.com",
   "ip": "127.0.0.1",
   "geo": "FR",
   "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36"
}

Click event additional properties:

Bounce event

Sample bounce event

{
   "event": "bounce",
   "time": 1430812195,
   "MessageID": 13792286917004336,
   "email": "bounce@mailjet.com",
   "mj_campaign_id": 0,
   "mj_contact_id": 0,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "blocked": true,
   "hard_bounce": true,
   "error_related_to": "recipient",
   "error": "user unknown"
}

Bounce event additional properties:

Blocked event

Sample blocked event

{
   "event": "blocked",
   "time": 1430812195,
   "MessageID": 13792286917004336,
   "email": "bounce@mailjet.com",
   "mj_campaign_id": 0,
   "mj_contact_id": 0,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "error_related_to": "recipient",
   "error": "user unknown"
}

Blocked event additional properties:

Spam event

Sample spam event


{
   "event": "spam",
   "time": 1430812195,
   "MessageID": 13792286917004336,
   "email": "bounce@mailjet.com",
   "mj_campaign_id": 0,
   "mj_contact_id": 0,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "source": "JMRPP"
}

Spam event additional properties:

Unsub event

Sample unsub event

{
   "event": "unsub",
   "time": 1433334941,
   "MessageID": 20547674933128000,
   "email": "api@mailjet.com",
   "mj_campaign_id": 7276,
   "mj_contact_id": 126,
   "customcampaign": "",
   "CustomID": "helloworld",
   "Payload": "",
   "mj_list_id": 1,
   "ip": "127.0.0.1",
   "geo": "FR",
   "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36"
}

Unsub event additional properties:

Inbound Calls

Introduction

Mailjet provides a way to receive email, in addition to sending them. To achieve that, you should start creating a parseroute which maps a given email address to your webhook.

For testing purposes, Mailjet provides auto generated email addresses on the domain parse-in1.mailjet.com.

For production setup, we however recommend you to setup the Parse API with your own domain, as explained below.

Domains

In Mailjet API, Inbound Domains are called parseroute

Add-Domain

Adding a domain is done through the sender resource.

Check-Domain

Domain verification is tied to the sender resource.

Please refer to the Senders calls guide to learn more.

Delete-Domain

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->delete(Resources::$Sender, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
curl -s \
    -X DELETE \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/sender/$ID \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .delete("sender")
    .id($ID)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Sender.find($ID)
target.delete()
"""
Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.sender.delete(id=id)
print result.status_code
print result.json()
/*
Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "sender",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Delete(mr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Sender;
public class MyClass {
    /**
     * Delete : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Sender.resource, ID);
      response = client.delete(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

Issue a DELETE request on the sender resource to set its status to Deleted

Routes

Inbound routes are called parseroute in the Mailjet API.

Add-Route

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'APIKeyID' => "",
    'Email' => "miss@mailjet.com",
    'Url' => ""
];
$response = $mj->post(Resources::$Parseroute, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Create : ParseRoute description
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/parseroute \
    -H 'Content-Type: application/json' \
    -d '{
        "APIKeyID":"",
        "Email":"miss@mailjet.com",
        "Url":""
    }'
/**
 *
 * Create : ParseRoute description
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("parseroute")
    .request({
        "APIKeyID":"",
        "Email":"miss@mailjet.com",
        "Url":""
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Create : ParseRoute description
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Parseroute.create(apikey_id: "",email: "miss@mailjet.com",url: "")
"""
Create : ParseRoute description
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'APIKeyID': '',
  'Email': 'miss@mailjet.com',
  'Url': ''
}
result = mailjet.parseroute.create(data=data)
print result.status_code
print result.json()
/*
Create : ParseRoute description
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Parseroute
    mr := &MailjetRequest{
      Resource: "parseroute",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Parseroute {
      APIKeyID: ,
      Email: "miss@mailjet.com",
      Url: ,
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Parseroute;
public class MyClass {
    /**
     * Create : ParseRoute description
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Parseroute.resource)
                        .property(Parseroute.APIKEYID, )
                        .property(Parseroute.EMAIL, "miss@mailjet.com")
                        .property(Parseroute.URL, );
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKeyID": "",
            "Email": "miss@mailjet.com",
            "ID": "",
            "Url": ""
        }
    ],
    "Total": 1
}

In order to create a new parseroute, issue a POST request.

Update-Route

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'APIKeyID' => "",
    'Url' => ""
];
$response = $mj->put(Resources::$Parseroute, ['id' => $id, 'body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Modify : ParseRoute description
curl -s \
    -X PUT \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/parseroute/$ID \
    -H 'Content-Type: application/json' \
    -d '{
        "APIKeyID":"",
        "Url":""
    }'
/**
 *
 * Modify : ParseRoute description
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .put("parseroute")
    .id($ID)
    .request({
        "APIKeyID":"",
        "Url":""
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Modify : ParseRoute description
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Parseroute.find($ID)
target.update_attributes(apikey_id: "",url: "")
"""
Modify : ParseRoute description
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
data = {
  'APIKeyID': '',
  'Url': ''
}
result = mailjet.parseroute.update(id=id, data=data)
print result.status_code
print result.json()
/*
Modify : ParseRoute description
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "parseroute",
      ID: RESOURCE_ID,
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Parseroute {
      APIKeyID: ,
      Url: ,
    },
    }
    err := mailjetClient.Put(fmr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Parseroute;
public class MyClass {
    /**
     * Modify : ParseRoute description
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Parseroute.resource, ID)
                        .property(Parseroute.APIKEYID, )
                        .property(Parseroute.URL, );
      response = client.put(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "APIKeyID": "",
            "Email": "miss@mailjet.com",
            "ID": "",
            "Url": ""
        }
    ],
    "Total": 1
}

In order to update parseroute, issue a PUT request with its given ID.

Delete-Route

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->delete(Resources::$Parseroute, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
# Delete : ParseRoute description
curl -s \
    -X DELETE \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/parseroute/$ID \
    -H 'Content-Type: application/json' \
    -d '{
    }'
/**
 *
 * Delete : ParseRoute description
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .delete("parseroute")
    .id($ID)
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Delete : ParseRoute description
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
target = Mailjet::Parseroute.find($ID)
target.delete()
"""
Delete : ParseRoute description
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
id = '$ID'
result = mailjet.parseroute.delete(id=id)
print result.status_code
print result.json()
/*
Delete : ParseRoute description
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    mr := &MailjetRequest{
      Resource: "parseroute",
      ID: RESOURCE_ID,
    }
    err := mailjetClient.Delete(mr)
    if err != nil {
      fmt.Println(err)
    }
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Parseroute;
public class MyClass {
    /**
     * Delete : ParseRoute description
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Parseroute.resource, ID);
      response = client.delete(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

In order to delete parseroute, issue a DELETE request with its given ID.

Tags

Introduction

Tags are a way to tag messages with a meaningful value for your business. Mailjet API provides such mechanism through Custom ID. At the moment, we accept only one Custom ID per message but we’re planning to support more in a near future.

Custom ID is a message property, so there is not a dedicated resource.

Assigning a CustomID to a message is easy through the Send API. Please refer to our dedicated API guide here to learn more.

Info

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$filters = [
  'CustomID' => 'PassengerEticket1234'
];
$response = $mj->get(Resources::$Messagesentstatistics, ['filters' => $filters]);
$response->success() && var_dump($response->getData());
?>
# View : API Key Statistical campaign/message data.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/messagesentstatistics?CustomID=PassengerEticket1234 
/**
 *
 * View : API Key Statistical campaign/message data.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("messagesentstatistics")
    .request({
        "CustomID":"PassengerEticket1234"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : API Key Statistical campaign/message data.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Messagesentstatistics.all(custom_id: "PassengerEticket1234")
"""
View : API Key Statistical campaign/message data.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
filters = {
  'CustomID': 'PassengerEticket1234'
}
result = mailjet.messagesentstatistics.get(filters=filters)
print result.status_code
print result.json()
/*
View : API Key Statistical campaign/message data.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Messagesentstatistics
    _, _, err := mailjetClient.List("messagesentstatistics", &data, Filter("CustomID", "PassengerEticket1234"))
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Messagesentstatistics;
public class MyClass {
    /**
     * View : API Key Statistical campaign/message data.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Messagesentstatistics.resource)
                  .filter(Messagesentstatistics.CUSTOMID, "PassengerEticket1234");
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

In order to retrieve last messages tagged with a given Custom ID, issue a GET request on messagesentstatistics including the CustomID you’re looking for.

All-Time-Series

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$filters = [
  'CustomID' => 'PassengerEticket1234'
];
$response = $mj->get(Resources::$Messagesentstatistics, ['filters' => $filters]);
$response->success() && var_dump($response->getData());
?>
# View : API Key Statistical campaign/message data.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/messagesentstatistics?CustomID=PassengerEticket1234&AllMessages=1
/**
 *
 * View : API Key Statistical campaign/message data.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("messagesentstatistics")
    .request({
        "CustomID":"PassengerEticket1234",
        "AllMessages": "1"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : API Key Statistical campaign/message data.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Messagesentstatistics.all(custom_id: "PassengerEticket1234", all_messages: "1")
"""
View : API Key Statistical campaign/message data.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
filters = {
  'CustomID': 'PassengerEticket1234'
}
result = mailjet.messagesentstatistics.get(filters=filters)
print result.status_code
print result.json()
/*
View : API Key Statistical campaign/message data.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Messagesentstatistics
    _, _, err := mailjetClient.List("messagesentstatistics", &data, Filter("CustomID", "PassengerEticket1234"), Filter("AllMessages", "1"))
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Messagesentstatistics;
public class MyClass {
    /**
     * View : API Key Statistical campaign/message data.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Messagesentstatistics.resource)
                  .filter(Messagesentstatistics.CUSTOMID, "PassengerEticket1234")
                  .filter(Messagesentstatistics.ALLMESSAGES, "1");
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

In order to retrieve last messages tagged with a given Custom ID, issue a GET request on messagesentstatistics including the CustomID you’re looking for along with the query filter AllMessages set to 1.

Subaccounts Calls

Introduction

Mandrill Subaccounts can be mapped on Mailjet sub API keys manageable with apikey. The Mailjet REST API lets you manage multiple API key. Each API key will have its own contacts, lists, newsletters and statistics dedicated database. The contacts and lists will not be shared between API keys (including the main API key)..

List

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Apikey);
$response->success() && var_dump($response->getData());
?>
# View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/apikey 
/**
 *
 * View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("apikey")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Apikey.all()
"""
View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.apikey.get()
print result.status_code
print result.json()
/*
View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Apikey
    _, _, err := mailjetClient.List("apikey", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Apikey;
public class MyClass {
    /**
     * View : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Apikey.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ACL": "",
            "APIKey": "",
            "CreatedAt": "",
            "ID": "",
            "IsActive": "false",
            "IsMaster": "false",
            "Name": "",
            "QuarantineValue": "",
            "Runlevel": "Normal",
            "SecretKey": "",
            "TrackHost": "",
            "UserID": ""
        }
    ],
    "Total": 1
}

Issue a GET request on the apikey resource

Add

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'Name' => "MynewKEY"
];
$response = $mj->post(Resources::$Apikey, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>
# Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
curl -s \
    -X POST \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/apikey \
    -H 'Content-Type: application/json' \
    -d '{
        "Name":"MynewKEY"
    }'
/**
 *
 * Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .post("apikey")
    .request({
        "Name":"MynewKEY"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Apikey.create(name: "MynewKEY")
"""
Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'Name': 'MynewKEY'
}
result = mailjet.apikey.create(data=data)
print result.status_code
print result.json()
/*
Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Apikey
    mr := &MailjetRequest{
      Resource: "apikey",
    }
    fmr := &FullMailjetRequest{
      Info: mr,
      Payload: &resources.Apikey {
      Name: "MynewKEY",
    },
    }
    err := mailjetClient.Post(fmr, &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Apikey;
public class MyClass {
    /**
     * Create : Manage your Mailjet API Keys. API keys are used as credentials to access the API and SMTP server.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Apikey.resource)
                        .property(Apikey.NAME, "MynewKEY");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ACL": "",
            "APIKey": "",
            "CreatedAt": "",
            "ID": "",
            "IsActive": "false",
            "IsMaster": "false",
            "Name": "",
            "QuarantineValue": "",
            "Runlevel": "Normal",
            "SecretKey": "",
            "TrackHost": "",
            "UserID": ""
        }
    ],
    "Total": 1
}

To create a new API key , you just need to do a POST request on the apikey.

The response will contain a new APIKey and SecretKey. Please allow a few seconds before running any additional API request on this new APIkey as the full setup process of this new sub-account will take longer than the API call.

Metadata Calls

Introduction

Mailjet being an all-in-one email solution, we allow you to upload contact properties to personalise the content of your messages, whether that’s in the context of a marketing campaign or in a transactional email.

The contactmetadata resource allows you to define contact properties while the contactdata let you attach them to a given contact.

Later on you can use them in your emails. Please refer to our Personalization API guide to learn more.

Urls Calls

Introduction

The toplinkclicked API resource help you identify from where links in your emails are clicked.

In addition to that, our API offers a full range of statistics related methods to help you extract meaningful data about your email. Please refer to our dedicated guide to learn more.

List

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Toplinkclicked);
$response->success() && var_dump($response->getData());
?>
# View : Top links clicked historgram.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/toplinkclicked 
/**
 *
 * View : Top links clicked historgram.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("toplinkclicked")
    .request();
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Top links clicked historgram.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Toplinkclicked.all()
"""
View : Top links clicked historgram.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
result = mailjet.toplinkclicked.get()
print result.status_code
print result.json()
/*
View : Top links clicked historgram.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Toplinkclicked
    _, _, err := mailjetClient.List("toplinkclicked", &data)
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Toplinkclicked;
public class MyClass {
    /**
     * View : Top links clicked historgram.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Toplinkclicked.resource);
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ClickedCount": "3",
            "ID": "-1",
            "LinkId": "1",
            "Url": "www.example.com"
        }
    ],
    "Total": 1
}

Issue a GET request to toplinkclicked.

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$filters = [
  'FromDomain' => 'example.com'
];
$response = $mj->get(Resources::$Toplinkclicked, ['filters' => $filters]);
$response->success() && var_dump($response->getData());
?>
# View : Top links clicked historgram.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/toplinkclicked?FromDomain=example.com
/**
 *
 * View : Top links clicked historgram.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("toplinkclicked")
    .request({
        "FromDomain":"example.com"
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Top links clicked historgram.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Toplinkclicked.all(from_domain: "example.com")
"""
View : Top links clicked historgram.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
filters = {
  'FromDomain': 'example.com'
}
result = mailjet.toplinkclicked.get(filters=filters)
print result.status_code
print result.json()
/*
View : Top links clicked historgram.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Toplinkclicked
    _, _, err := mailjetClient.List("toplinkclicked", &data, Filter("FromDomain", "example.com"))
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Toplinkclicked;
public class MyClass {
    /**
     * View : Top links clicked historgram.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Toplinkclicked.resource)
                     .filter(Messagesentstatistics.FROMDOMAIN, "example.com");
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ClickedCount": "3",
            "ID": "-1",
            "LinkId": "1",
            "Url": "www.example.com"
        }
    ],
    "Total": 1
}

Issue a GET request to toplinkclicked using the FromDomain query filter, to filter the dataset on the domain you’re looking for.

Time-Series

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$filters = [
  'FromTs' => '1456479862',
  'ToTs' => '1458985462'
];
$response = $mj->get(Resources::$Toplinkclicked, ['filters' => $filters]);
$response->success() && var_dump($response->getData());
?>
# View : Top links clicked historgram.
curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/toplinkclicked?FromTs=1456479862&ToTs=1458985462
/**
 *
 * View : Top links clicked historgram.
 *
 */
var mailjet = require ('node-mailjet')
    .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
    .get("toplinkclicked")
    .request({
        "FromTs":"1456479862",
        "ToTs": "1458985462",
    });
request
    .on('success', function (response, body) {
        console.log (response.statusCode, body);
    })
    .on('error', function (err, response) {
        console.log (response.statusCode, err);
    });
# View : Top links clicked historgram.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Toplinkclicked.all(from_ts: "1456479862", to_ts: "1458985462")
"""
View : Top links clicked historgram.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
filters = {
  'FromTs': '1456479862'
  'ToTs': '1458985462'
}
result = mailjet.toplinkclicked.get(filters=filters)
print result.status_code
print result.json()
/*
View : Top links clicked historgram.
*/
package main
import (
    "fmt"
    . "github.com/mailjet/mailjet-apiv3-go"
    "github.com/mailjet/mailjet-apiv3-go/resources"
    "os"
)
func main () {
    mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
    var data []resources.Toplinkclicked
    _, _, err := mailjetClient.List("toplinkclicked", &data, Filter("FromTs", "1456479862"), Filter("ToTs", "1458985462"))
    if err != nil {
      fmt.Println(err)
    }
    fmt.Printf("Data array: %+v\n", data)
}
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Toplinkclicked;
public class MyClass {
    /**
     * View : Top links clicked historgram.
     */
    public static void main(String[] args) throws MailjetException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient("api key", "api secret");
      request = new MailjetRequest(Toplinkclicked.resource)
                     .filter(Messagesentstatistics.FROMTS, "1456479862")
                     .filter(Messagesentstatistics.TOTS, "1458985462")
      response = client.get(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ClickedCount": "3",
            "ID": "-1",
            "LinkId": "1",
            "Url": "www.1456479862"
        }
    ],
    "Total": 1
}

API response:

{
    "Count": 1,
    "Data": [
        {
            "ClickedCount": "3",
            "ID": "-1",
            "LinkId": "1",
            "Url": "www.example.com"
        }
    ],
    "Total": 1
}

Issue a GET request to toplinkclicked using the FromTs and ToTs query filters, to filter the dataset within your date range. These filters expect UNIX epoch timestamps.

SMTP Relay

Postfix Installation

You can configure your Postfix to send via in.mailjet.com relay, depending on the sender, by following these steps:

In this example, all outgoing emails are sent directly to Mail eXchangers (MX), except for when from is *@example.com or example@example.net which are going through Mailjet.

Caution, for Postfix, a sender is not the From: but the sender envelope passed to sendmail (in the 5th mail() argument: -fexample@example.com or in PHP config php.ini : sendmail_path = /path/to/sendmail -t -i -fexample@example.com).

In /etc/postfix/main.cf (remove relayhost).

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

In /etc/postfix/sender_relay, list addresses that must go through a relay.

@example.com in.mailjet.com
example@example.net in.mailjet.com

In /etc/postfix/sasl_passwd, provide credentials for each address listed in /etc/postfix/sender_relay.

@example.com apikey:secretkey
example@example.net apikey2:secretkey2

Don’t forget the following commands.

cd /etc/postfix
chmod 600 sasl_passwd
chown root:root sasl_passwd
postmap sasl_passwd sender_relay
postfix reload

Other configurations

Custom Headers

When using SMTP relay, you can use the following custom headers to specify how Mailjet will handle your message

X-Mailjet-Campaign

This header value must be unique for all emails belonging to a specific campaign. This will regroup emails into only one line in your dashboard, and provide cool reports ! It can be an alpha-numeric value of your choice (space, dash and underscore are also accepted), of up to 255 characters in only one line.

X-Mailjet-DeduplicateCampaign

In combination with X-Mailjet-Campaign, this boolean (true, yes, y, 1) indicates that you do not wish to send a message inside the campaign twice to the same recipient. In this case, we check that the recipient hasn’t been sent the message, or otherwise block any duplicate (only the first message goes through). Please note that this is based on the recipient’s email address, it will not block a message sent to the same person on two different email addresses.

X-MJ-CustomID

This custom value will help you track your message more easily.

X-MJ-EventPayload

If you need more than an ID, no problem: insert a payload to your messages, using any format (XML, JSON, CSV…)

X-Mailjet-TrackOpen

This boolean (0 or 1) indicates whether you want to activate or not the open tracking on the concerned message. This option overrides your tracking options set on your user account.

X-Mailjet-TrackClick

This boolean (0 or 1) indicates whether you want to activate or not the click tracking on the concerned message. This option overrides your tracking options set on your user account.

X-Mailjet-Prio

This header manages the different types of email by defining up to four priority levels. More information

MJML

<!-- MJML -->
<mj-body>
  <mj-section>
    <mj-column>

      <mj-image src="assets/img/logo-small.png"></mj-image>

      <mj-divider border-color="#F45E43"></mj-divider>

      <mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>

    </mj-column>
  </mj-section>
</mj-body>

becomes :

<!-- HTML -->
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>undefined</title>
  <style type="text/css">

  #outlook a { padding: 0; }
  .ReadMsgBody { width: 100%; }
  .ExternalClass { width: 100%; }
  .ExternalClass * { line-height:100%; }
    body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
    table, td { border-collapse:collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
  img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }
  p {
    display: block;
    margin: 13px 0;
  }
  @media only screen and (min-width:480px) {
    .mj-2column, * [aria-labelledby="mj-2column"] { width:50%!important; }
    .mj-3column, * [aria-labelledby="mj-3column"] { width:33.3333%!important; }
    .mj-4column, * [aria-labelledby="mj-4column"] { width:25%!important; }
  }

  </style>
  <!--[if !mso]><!-->
  <style type="text/css">
    @import url(https://fonts.googleapis.com/css?family=Ubuntu:400,500,700,300);
  </style>
  <style type="text/css">
    @media only screen and (max-width:480px) {
      @-ms-viewport { width:320px; }
      @viewport { width:320px; }
    }
  </style>
  <link href="https://fonts.googleapis.com/css?family=Ubuntu:400,500,700,300" rel="stylesheet" type="text/css">
  <!--<![endif]-->
<style type="text/css">
    @media only screen and (min-width:480px) {
    }</style></head>
<body id="YIELD_MJML" style=""><div class="mj-body"><!--[if mso]>
        <table border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;"><tr><td>
        <![endif]--><div style="margin:0 auto;max-width:600px;"><table class="" cellpadding="0" cellspacing="0" style="width:100%;font-size:0px;" align="center"><tbody><tr><td style="text-align:center;vertical-align:top;font-size:0;padding-top:20px;padding-bottom:20px;"><!--[if mso]>
      <table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:600px;">
      <![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;" class="mj-1column" aria-labelledby="mj-1column" data-column-width="NaN"><table width="100%"><tbody><tr><td style="font-size:0;padding-top:10px;padding-bottom:10px;padding-right:25px;padding-left:25px;" align="center"><table cellpadding="0" cellspacing="0" style="border-collapse:collapse;border-spacing:0px;" align="center"><tbody><tr><td><img alt="" src="assets/img/logo-small.png" style="border:none;display:block;outline:none;text-decoration:none;max-width:NaN;"></td></tr></tbody></table></td></tr><tr><td style="font-size:0;padding-top:10px;padding-bottom:10px;padding-right:25px;padding-left:25px;"><div style="height:0px;font-size:1px;border-color:#F45E43;border-style:solid;border-width:4px 0 0;margin-bottom:30px;margin-left:10px;margin-right:10px;margin-top:30px;"></div></td></tr><tr><td style="font-size:0;padding-top:10px;padding-bottom:10px;padding-right:25px;padding-left:25px;" align="left"><div class="mj-content" style="cursor:auto;color:#F45E43;font-family:helvetica;font-size:20px;line-height:22px;">Hello World</div></td></tr></tbody></table></div><!--[if mso]>
      </td></tr></table>
      <![endif]--></td></tr></tbody></table></div><!--[if mso]>
        </td></tr></table>
        <![endif]--></div></body>
</html>

images/logo_mjml.png

MJML is a markup language designed to reduce the pain of coding a responsive email. Its semantic syntax makes it easy and straightforward and its rich standard components library speeds up your development time and lightens your email codebase. MJML’s open-source engine generates high quality responsive HTML compliant with best practices.

images/mjml_screen.png

Visit mjml.io for more details about this open source project initiated by the Mailjet development team.

Find the mjml repository on Github.

Demos

Mailjet Live Event API Dashboard

Test the Event API in 3 easy steps. Built in ReactJS and Golang

NodeJs wrapper Demo

Check out a simple example of NodeJS implementation.

Reply by email, messaging app

This is a messaging app example which lets a group of people communicate together. If a user tagged in a message is currently offline, he’ll receive an email notification so that he doesn’t miss a beat and can reply (directly by email), even if he wants to stay offline.

This demo uses Mailjet Parse API, ReactJS and NodeJS.

Need Help?

We have an international Developers Relations team that you can contact at api@mailjet.com or find on Twitter

Mailjet full API documentation is available at http://dev.mailjet.com/guides/

For any wrapper related issues, please open an issue on the dedicated Github repository.

In addition to this API documentation, we have a more general FAQ available at https://www.mailjet.com/support

For issues with your account, please contact our support at https://www.mailjet.com/support/ticket

Feel free to reach out to share your feedback!