Skip to content

Sub-Accounts module ​

Manage your sub-accounts associated with your MailChannels account.

Create method ​

Creates a new sub-account under the parent account.

Usage ​

ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { SubAccounts } from '@yizack/mailchannels/modules'

const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)

const { account } = await subAccounts.create('validhandle123');
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')

const { account } = await mailchannels.subAccounts.create('validhandle123');

Params ​

  • handle: The handle of the sub-account to create.

    TIP

    Sub-account handle must match the pattern [a-z0-9]{3,128}.

    If no handle is provided, a random handle will be generated.

List method ​

Retrieves all sub-accounts associated with the parent account.

Usage ​

ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { SubAccounts } from '@yizack/mailchannels/modules'

const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)

const { accounts } = await subAccounts.list();
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')

const { accounts } = await mailchannels.subAccounts.list();

Params ​

  • options: List sub-accounts options.
    • limit: The number of sub-accounts to return. Possible values are 1 to 1000.
    • offset: 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.

Create API Key method ​

Creates a new API key for the specified sub-account.

Usage ​

ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { SubAccounts } from '@yizack/mailchannels/modules'

const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)

const { id, key } = await subAccounts.createApiKey('validhandle123');
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')

const { id, key } = await mailchannels.subAccounts.createApiKey('validhandle123');

Params ​

  • handle: The handle of the sub-account to create API key for.

Create SMTP Password method ​

Creates a new API key for the specified sub-account.

Usage ​

ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { SubAccounts } from '@yizack/mailchannels/modules'

const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)

const { id, password } = await subAccounts.createSmtpPassword('validhandle123');
ts
import { MailChannels } from '@yizack/mailchannels'
const mailchannels = new MailChannels('your-api-key')

const { id, password } = await mailchannels.subAccounts.createSmtpPassword('validhandle123');

Params ​

  • handle: The handle of the sub-account to create SMTP password for.

Type declarations ​

ts
class SubAccounts {
  constructor (protected mailchannels: MailChannelsClient) {}
  async create (handle?: string): Promise<SubAccountsCreateResponse>;
  async list (options?: SubAccountsListOptions): Promise<SubAccountsListResponse>;
  async createApiKey (handle: string): Promise<SubAccountsCreateApiKeyResponse>;
  async createSmtpPassword (handle: string): Promise<SubAccountsCreateSmtpPasswordResponse>;
}
All type declarations

Create type declarations

ts
interface SubAccountsAccount {
  enabled: boolean;
  handle: string;
}
ts
interface SubAccountsCreateResponse {
  account: SubAccountsAccount;
}

List type declarations

ts
interface SubAccountsListOptions {
  limit?: number;
  offset?: number;
}
ts
interface SubAccountsListResponse {
  accounts: SubAccountsAccount[];
}

Create API Key type declarations

ts
interface SubAccountsCreateApiKeyResponse {
  id: number;
  key: string;
}

Create SMTP Password type declarations

ts
interface SubAccountsCreateSmtpPasswordResponse {
  enabled: boolean;
  id: number;
  password: string;
}

Source ​

Source

Released under the MIT License.