Create method 🚫 Suppressions
Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If types is not provided, it defaults to non-transactional. The operation is atomic, meaning all entries are successfully added or none are added if an error occurs.
Usage
ts
import { MailChannelsClient, Suppressions } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const suppressions = new Suppressions(mailchannels)
const { success, error } = await suppressions.create({
addToSubAccounts: false,
entries: [
{
notes: "test",
recipient: "name@example.com",
types: ["transactional"]
}
]
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { success, error } = await mailchannels.suppressions.create({
addToSubAccounts: false,
entries: [
{
notes: "test",
recipient: "name@example.com",
types: ["transactional"]
}
]
})Params
optionsSuppressionsCreateOptionsrequired: The details of the suppression entries to create.addToSubAccountsbooleanoptional: Iftrue, the parent account creates suppression entries for all associated sub-accounts. This field is only applicable to parent accounts. Sub-accounts cannot create entries for other sub-accounts.entriesobject[]required: The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed1000.notesstringoptional: Must be less than1024characters.recipientstringrequired: The email address to suppress. Must be a valid email address format and less than255characters.types("transactional" | "non-transactional")[]optional: An array of types of suppression to apply to the recipient. If not provided, it defaults to["non-transactional"].NOTE
Possible type values are:
transactional,non-transactional.
Response
successbooleanguaranteed: Whether the operation was successful.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 (options: SuppressionsCreateOptions): Promise<SuccessResponse>Response type declarations
ts
interface ErrorResponse {
message: string;
statusCode: number | null;
type: ErrorType;
}ts
interface SuccessResponse {
success: boolean;
error: ErrorResponse | null;
}Create type declarations
ts
type SuppressionsTypes = "transactional" | "non-transactional";ts
interface SuppressionsCreateOptions {
addToSubAccounts?: boolean;
entries: {
notes?: string;
recipient: string;
types?: SuppressionsTypes[];
}[];
}Source
Source • Playground • Docs • Tests