Skip to content

List method 🪪 Sub-Accounts

Retrieves all sub-accounts associated with the parent account.

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

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

const { data, error } = await mailchannels.subAccounts.list()

Params

  • options SubAccountsListOptions optional: List sub-accounts options.
    • limit number optional: The number of sub-accounts to return. Possible values are 1 to 1000.
    • offset number optional: The offset number to start returning sub-accounts from.

    TIP

    If no options are provided, the default limit is 1000 and the offset is 0.

Response

  • data SubAccount[] | null nullable
    • companyName string guaranteed: The name of the company associated with the sub-account.
    • enabled boolean guaranteed: If the sub-account is enabled.
    • handle string guaranteed: The handle for the sub-account.
  • 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.
    • response Record<string, unknown> | null nullable: An object containing the response, if available. This field may be null if 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 list (options?: SubAccountsListOptions): Promise<SubAccountsListResponse>

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

Sub-Accounts type declarations

ts
interface SubAccount {
  companyName: string;
  enabled: boolean;
  handle: string;
}
ts
interface SubAccountsListOptions {
  limit?: number;
  offset?: number;
}
ts
type SubAccountsListResponse = DataResponse<SubAccount[]>;

Source

SourcePlaygroundDocsTests

Released under the MIT License.