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.senders("campaigns", {
startTime: "2026-01-01T00:00:00Z",
endTime: "2026-01-31T23:59:59Z",
});
if (error) {
console.error("Get senders 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 the top 50 campaigns by total messages (processed + dropped) for January 2026.
response = mailchannels.Metrics.senders(
"campaigns",
start_time="2026-01-01T00:00:00Z",
end_time="2026-01-31T23:59:59Z",
limit=50,
offset=0,
sort_order="desc",
)
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 the top 50 campaigns by total messages (processed + dropped) for January 2026.
$response = $client->metrics->senders(
senderType: 'campaigns',
startTime: '2026-01-01T00:00:00Z',
endTime: '2026-01-31T23:59:59Z',
limit: 50,
offset: 0,
sortOrder: 'desc',
);
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/metrics/senders/{sender_type} \
--header 'X-Api-Key: <x-api-key>'{
"limit": 123,
"offset": 123,
"senders": [
{
"bounced": 1,
"delivered": 1,
"dropped": 1,
"name": "<string>",
"processed": 1
}
],
"total": 123,
"end_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z"
}Retrieve Sender Metrics
Retrieves a list of senders, either sub-accounts or campaigns, with their associated message metrics. Sorted by total # of sent messages (processed + dropped) Supports optional filter for time range, and optional settings for limit, offset, and sort order. Note: senders without any messages in the given time range will not be included in the results. The default time range is from one month ago to now, and the default sort order is descending.
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.senders("campaigns", {
startTime: "2026-01-01T00:00:00Z",
endTime: "2026-01-31T23:59:59Z",
});
if (error) {
console.error("Get senders 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 the top 50 campaigns by total messages (processed + dropped) for January 2026.
response = mailchannels.Metrics.senders(
"campaigns",
start_time="2026-01-01T00:00:00Z",
end_time="2026-01-31T23:59:59Z",
limit=50,
offset=0,
sort_order="desc",
)
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 the top 50 campaigns by total messages (processed + dropped) for January 2026.
$response = $client->metrics->senders(
senderType: 'campaigns',
startTime: '2026-01-01T00:00:00Z',
endTime: '2026-01-31T23:59:59Z',
limit: 50,
offset: 0,
sortOrder: 'desc',
);
print_r($response->toArray());curl --request GET \
--url https://api.mailchannels.net/tx/v1/metrics/senders/{sender_type} \
--header 'X-Api-Key: <x-api-key>'{
"limit": 123,
"offset": 123,
"senders": [
{
"bounced": 1,
"delivered": 1,
"dropped": 1,
"name": "<string>",
"processed": 1
}
],
"total": 123,
"end_time": "2023-11-07T05:31:56Z",
"start_time": "2023-11-07T05:31:56Z"
}Headers
Path Parameters
campaigns, sub-accounts Query Parameters
The beginning of the time range for retrieving top senders 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 top senders metrics (exclusive). Formats: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ Defaults to the current time if not provided.
The maximum number of senders to return The default is 10.
1 <= x <= 1000The number of senders to skip before returning results.
x >= 0The order in which to sort the results, based on total messages (processed + dropped).
asc, desc Response
Successfully retrieved top senders metrics
Was this page helpful?

