Skip to content

Create method 🪪 Sub-Accounts

Creates a new sub-account under 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.create('My Company', 'validhandle123')
ts
import { MailChannels } from 'mailchannels-sdk'

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

const { data, error } = await mailchannels.subAccounts.create('My Company', 'validhandle123')

Params

  • companyName string required: The name of the company associated with the sub-account.

    TIP

    This name is used for display purposes only and does not affect the functionality of the sub-account. The length must be between 3 and 128 characters.

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

    TIP

    The length must be between 3 and 128 characters, and it may contain only lowercase letters and numbers.

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

Response

  • data SubAccountsAccount | 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.

Type declarations

Signature

ts
async function create (companyName: string, handle?: string): Promise<SubAccountsCreateResponse>

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

Account type declarations

ts
interface SubAccountsAccount {
  companyName: string;
  enabled: boolean;
  handle: string;
}
ts
type SubAccountsCreateResponse = DataResponse<SubAccountsAccount>;

Source

SourcePlaygroundDocsTests

Released under the MIT License.