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.
<?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());
?>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.
<?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());
?>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.