🚫 Suppressions module Email API
Manage your MailChannels account suppressions list.
Create method
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
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"]
}
]
})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.errorstring | nullnullable
Delete method
Deletes suppression entry associated with the account based on the specified recipient and source.
Usage
import { MailChannelsClient, Suppressions } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const suppressions = new Suppressions(mailchannels)
const { success, error } = await suppressions.delete("name@example.com", "api")import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { success, error } = await mailchannels.suppressions.delete("name@example.com", "api")Params
recipientstringrequired: The email address of the suppression entry to delete.source"api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all"optional: Optional. The source of the suppression entry to be deleted. If source is not provided, it defaults toapi. If source is set toall, all suppression entries related to the specified recipient will be deleted.NOTE
Possible values are:
api,unsubscribe_link,list_unsubscribe,hard_bounce,spam_complaint,all
Response
successbooleanguaranteed: Whether the operation was successful.errorstring | nullnullable
List method
Retrieve suppression entries associated with the specified account. Supports filtering by recipient, source and creation date range. The response is paginated, with a default limit of 1000 entries per page and an offset of 0.
Usage
import { MailChannelsClient, Suppressions } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const suppressions = new Suppressions(mailchannels)
const { data, error } = await suppressions.list()import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.suppressions.list()Params
optionsSuppressionsListOptionsoptional: Optional filter options.recipientstringoptional: The email address of the suppression entry to search for. If provided, the search will return the suppression entry associated with this recipient. If not provided, the search will return all suppression entries for the account.source"api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint"optional: The source of the suppression entries to filter by. If not provided, suppression entries from all sources will be returned.NOTE
Possible values are:
api,unsubscribe_link,list_unsubscribe,hard_bounce,spam_complaint.createdBeforestringoptional: The date and/or time before which the suppression entries were created. Format:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZcreatedAfterstringoptional: The date and/or time after which the suppression entries were created. Format:YYYY-MM-DDorYYYY-MM-DDTHH:MM:SSZlimitnumberoptional: The maximum number of suppression entries to return. Must be between1and1000. Defaults to1000.offsetnumberoptional: The number of suppression entries to skip before returning results. Defaults to0.
Response
dataSuppressionsListEntry[] | nullnullablecreatedAtstringguaranteednotesstring | nulloptionalrecipientstringguaranteed: The email address that is suppressed.senderstring | nulloptionalsource"api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all"guaranteedtypes("transactional" | "non-transactional")[]guaranteed
errorstring | nullnullable
Type declarations
class Suppressions {
constructor (protected mailchannels: MailChannelsClient);
async create (options: SuppressionsCreateOptions): Promise<SuccessResponse>;
async delete (recipient: string, source?: SuppressionsSource): Promise<SuccessResponse>;
async list (options?: SuppressionsListOptions): Promise<SuppressionsListResponse>;
}All type declarations
Responses
interface DataResponse<T> {
data: T | null;
error: string | null;
}interface SuccessResponse {
success: boolean;
error: string | null;
}Create type declarations
type SuppressionsTypes = "transactional" | "non-transactional";interface SuppressionsCreateOptions {
addToSubAccounts?: boolean;
entries: {
notes?: string;
recipient: string;
types?: SuppressionsTypes[];
}[];
}List type declarations
type SuppressionsSource = "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all";interface SuppressionsListOptions {
recipient?: string;
source?: Exclude<SuppressionsSource, "all">;
createdBefore?: string;
createdAfter?: string;
limit?: number;
offset?: number;
}interface SuppressionsListEntry {
createdAt: string;
notes?: string;
recipient: string;
sender?: string;
source: SuppressionsSource;
types: SuppressionsTypes[];
}type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;Source
Source • Playground • Docs