Skip to content

🚫 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

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

  • options SuppressionsCreateOptions required: The details of the suppression entries to create.
    • addToSubAccounts boolean optional: If true, 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.
    • entries object[] required: The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed 1000.
      • notes string optional: Must be less than 1024 characters.
      • recipient string required: The email address to suppress. Must be a valid email address format and less than 255 characters.
      • 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

  • success boolean guaranteed: Whether the operation was successful.
  • error string | null nullable

Delete method

Deletes suppression entry associated with the account based on the specified recipient and source.

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.delete("name@example.com", "api")
ts
import { MailChannels } from 'mailchannels-sdk'

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

const { success, error } = await mailchannels.suppressions.delete("name@example.com", "api")

Params

  • recipient string required: 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 to api. If source is set to all, 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

  • success boolean guaranteed: Whether the operation was successful.
  • error string | null nullable

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

ts
import { MailChannelsClient, Suppressions } from 'mailchannels-sdk'

const mailchannels = new MailChannelsClient('your-api-key')
const suppressions = new Suppressions(mailchannels)

const { data, error } = await suppressions.list()
ts
import { MailChannels } from 'mailchannels-sdk'

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

const { data, error } = await mailchannels.suppressions.list()

Params

  • options SuppressionsListOptions optional: Optional filter options.
    • recipient string optional: 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.

    • createdBefore string optional: The date and/or time before which the suppression entries were created. Format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
    • createdAfter string optional: The date and/or time after which the suppression entries were created. Format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ
    • limit number optional: The maximum number of suppression entries to return. Must be between 1 and 1000. Defaults to 1000.
    • offset number optional: The number of suppression entries to skip before returning results. Defaults to 0.

Response

  • data SuppressionsListEntry[] | null nullable
    • createdAt string guaranteed
    • notes string | null optional
    • recipient string guaranteed: The email address that is suppressed.
    • sender string | null optional
    • source "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all" guaranteed
    • types ("transactional" | "non-transactional")[] guaranteed
  • error string | null nullable

Type declarations

ts
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

ts
interface DataResponse<T> {
  data: T | null;
  error: string | null;
}
ts
interface SuccessResponse {
  success: boolean;
  error: string | null;
}

Create type declarations

ts
type SuppressionsTypes = "transactional" | "non-transactional";
ts
interface SuppressionsCreateOptions {
  addToSubAccounts?: boolean;
  entries: {
    notes?: string;
    recipient: string;
    types?: SuppressionsTypes[];
  }[];
}

List type declarations

ts
type SuppressionsSource = "api" | "unsubscribe_link" | "list_unsubscribe" | "hard_bounce" | "spam_complaint" | "all";
ts
interface SuppressionsListOptions {
  recipient?: string;
  source?: Exclude<SuppressionsSource, "all">;
  createdBefore?: string;
  createdAfter?: string;
  limit?: number;
  offset?: number;
}
ts
interface SuppressionsListEntry {
  createdAt: string;
  notes?: string;
  recipient: string;
  sender?: string;
  source: SuppressionsSource;
  types: SuppressionsTypes[];
}
ts
type SuppressionsListResponse = DataResponse<SuppressionsListEntry[]>;

Source

SourcePlaygroundDocs

Released under the MIT License.