Get Usage method 🪪 Sub-Accounts
Retrieves usage statistics for the specified sub-account during the current billing period.
Usage
ts
import { MailChannelsClient, SubAccounts } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)
const { data, error } = await subAccounts.getUsage('validhandle123')ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.subAccounts.getUsage('validhandle123')Params
handlestringrequired: The handle of the sub-account to query usage stats for.
Response
dataSubAccountsUsage | nullnullableendDatestringoptional: The end date of the current billing period (ISO 8601 format).startDatestringoptional: The start date of the current billing period (ISO 8601 format).totalnumberguaranteed: The total usage for the current billing period.monthlyLimitnumberguaranteed: The effective monthly limit for the current billing period. A limit of zero means the account cannot send any messages. For sub-accounts with no explicit limit set (i.e., -1), the monthly limit for the parent account is returned.
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.responseRecord<string, unknown> | nullnullable: An object containing the response, if available. This field may benullif no response is available or if the error is not related to an HTTP request or if the response is not a JSON object.
Type declarations
Signature
ts
async function getUsage (handle: string): Promise<SubAccountsUsageResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
response: Record<string, unknown> | null;
}ts
type DataResponse<T> = {
data: T;
error: null;
} | {
data: null;
error: ErrorResponse;
};Usage type declarations
ts
interface SubAccountsUsage {
endDate?: string;
startDate?: string;
total: number;
monthlyLimit: number;
}ts
type SubAccountsUsageResponse = DataResponse<SubAccountsUsage>;Source
Source • Playground • Docs • Tests