Senders method 📊 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.
Usage
ts
import { MailChannelsClient, Metrics } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const metrics = new Metrics(mailchannels)
const { data, error } = await metrics.senders("campaigns")ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.metrics.senders("campaigns")Params
typeMetricsSendersTyperequired: The type of senders to retrieve metrics for. Can be eithersub-accountsorcampaigns.optionsMetricsSendersOptionsoptional: Optional filter options.startTimestringoptional: The beginning of the time range for retrieving top senders metrics (inclusive). Formats:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZ. Defaults to one month ago if not provided.endTimestringoptional: The end of the time range for retrieving top senders metrics (exclusive). Formats:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZ. Defaults to the current time if not provided.limitnumberoptional: The maximum number of senders to return. Possible values are 1 to 1000. Defaults to 10 if not provided.offsetnumberoptional: The number of senders to skip before returning results. Defaults to 0 if not provided.sortOrder"asc" | "desc"optional: The order in which to sort the results, based on total messages (processed + dropped). Defaults todescif not provided.
Response
dataMetricsSenders | nullnullableendTimestringguaranteedlimitnumberguaranteedoffsetnumberguaranteedsendersobject[]guaranteedbouncednumberguaranteeddeliverednumberguaranteeddroppednumberguaranteednamestringguaranteedprocessednumberguaranteed
startTimestringguaranteedtotalnumberguaranteed: The total number of senders in this category that sent messages in the given time range.
errorErrorResponse | nullnullable: Error information if the operation failed.messagestringguaranteed: A human-readable description of the error.statusCodenumber | nullnullable: The HTTP status code from the API, ornullif the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.typestringguaranteed: A string identifier for the type of error. This field is intended for diagnostic use only and should not be relied upon.
Type declarations
Signature
ts
async function senders (type: MetricsSendersType, options?: MetricsSendersOptions): Promise<MetricsSendersResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};Shared metrics type declarations
ts
interface MetricsOptions {
startTime?: string;
endTime?: string;
campaignId?: string;
interval?: "hour" | "day" | "week" | "month";
}Senders type declarations
ts
type MetricsSendersType = "sub-accounts" | "campaigns";ts
interface MetricsSendersOptions {
startTime?: string;
endTime?: string;
limit?: number;
offset?: number;
sortOrder?: "asc" | "desc";
}ts
interface MetricsSenders {
endTime: string;
limit: number;
offset: number;
senders: {
bounced: number;
delivered: number;
dropped: number;
name: string;
processed: number;
}[];
startTime: string;
total: number;
}ts
type MetricsSendersResponse = DataResponse<MetricsSenders>;Source
Source • Playground • Docs • Tests