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
companyNamestringrequired: 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.
handlestringoptional: 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
dataSubAccountsAccount | nullnullablecompanyNamestringguaranteed: The name of the company associated with the sub-account.enabledbooleanguaranteed: If the sub-account is enabled.handlestringguaranteed: The handle for the sub-account.
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.
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
Source • Playground • Docs • Tests