Skip to content

Usage method 📊 Metrics

Retrieves usage statistics during the current billing period.

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.usage()
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { data, error } = await mailchannels.metrics.usage()

Response

  • data MetricsUsageResponse | null nullable
    • endDate string optional: The end date of the current billing period (ISO 8601 format).
    • startDate string optional: The start date of the current billing period (ISO 8601 format).
    • total number guaranteed: The total usage for the current billing period.
  • error ErrorResponse | null nullable: Error information if the operation failed.
    • message string guaranteed: A human-readable description of the error.
    • statusCode number | null nullable: The HTTP status code from the API, or null if the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.
    • type string guaranteed: 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 usage (): Promise<MetricsUsageResponse>

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;
};

Usage type declarations

ts
type MetricsUsageResponse = DataResponse<{
  endDate?: string;
  startDate?: string;
  total: number;
}>;

Source

SourcePlaygroundDocsTests

Released under the MIT License.