import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.metrics.performance({
startTime: "2026-01-01T00:00:00Z",
});
if (error) {
console.error("Get performance metrics failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
# Retrieve processed, delivered, and bounced counts from a chosen start time.
response = mailchannels.Metrics.performance(
start_time="2026-01-01T00:00:00Z",
)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$client = new Client(apiKey: $api_key);
// Retrieve processed, delivered, and bounced counts from a chosen start time.
$response = $client->metrics->performance(
startTime: '2026-01-01T00:00:00Z',
);
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/metrics/performance \
--header 'X-Api-Key: <x-api-key>'{
"bounced": 1,
"buckets": {
"bounced": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"complained": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"delivered": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"processed": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
]
},
"complained": 1,
"delivered": 1,
"processed": 1,
"end_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z"
}{
"errors": [
"<string>"
]
}Retrieve Performance Metrics
Retrieve performance metrics for messages sent from your account, including counts of processed, delivered, hard-bounced, and complained events. Supports optional filters for time range, and campaign ID.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { data, error } = await mailchannels.metrics.performance({
startTime: "2026-01-01T00:00:00Z",
});
if (error) {
console.error("Get performance metrics failed:", error);
process.exit(1);
}
console.log(data);import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY before running")
# Retrieve processed, delivered, and bounced counts from a chosen start time.
response = mailchannels.Metrics.performance(
start_time="2026-01-01T00:00:00Z",
)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$client = new Client(apiKey: $api_key);
// Retrieve processed, delivered, and bounced counts from a chosen start time.
$response = $client->metrics->performance(
startTime: '2026-01-01T00:00:00Z',
);
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/metrics/performance \
--header 'X-Api-Key: <x-api-key>'{
"bounced": 1,
"buckets": {
"bounced": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"complained": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"delivered": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
],
"processed": [
{
"count": 1,
"period_start": "2023-11-07T05:31:56Z"
}
]
},
"complained": 1,
"delivered": 1,
"processed": 1,
"end_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z"
}{
"errors": [
"<string>"
]
}Headers
Query Parameters
The beginning of the time range for retrieving message performance metrics (inclusive). Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ. Defaults to one month ago if not provided.
The end of the time range for retrieving message performance metrics (exclusive). Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ. Defaults to the current time if not provided.
The ID of the campaign to filter metrics by. If not provided, metrics for all campaigns will be returned.
The interval for aggregating metrics data. Allowed values:
- hour: Hourly breakdown
- day: Daily breakdown (default)
- week: Weekly breakdown
- month: Monthly breakdown
hour, day, week, month Response
Successfully retrieved performance metrics
Count of messages hard-bounced during the specified time range.
x >= 0A series of metrics aggregations bucketed by time interval (e.g. hour, day)
Show child attributes
Show child attributes
Count of messages complained during the specified time range.
x >= 0Count of messages delivered during the specified time range.
x >= 0Count of messages processed during the specified time range.
x >= 0The end of the time range for retrieving message performance metrics (exclusive).
The beginning of the time range for retrieving message performance metrics (inclusive).
Was this page helpful?

