Skip to content

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

  • 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 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 (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

SourcePlaygroundDocsTests

Released under the MIT License.