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([
  {
    notes: "test",
    recipient: "name@example.com",
    types: ["transactional"]
  }
], { addToSubAccounts: false })
ts
import { MailChannels } from 'mailchannels-sdk'

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

const { success, error } = await mailchannels.suppressions.create([
  {
    notes: "test",
    recipient: "name@example.com",
    types: ["transactional"]
  }
], { addToSubAccounts: false })

Params

  • entries SuppressionsCreateEntry[] 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.

  • options Omit<SuppressionsCreateOptions, "entries"> optional: The options 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.

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.
    • response Record<string, unknown> | null nullable: An object containing the response, if available. This field may be null if no response is available or if the error is not related to an HTTP request or if the response is not a JSON object.

Type declarations

Signature

ts
async function create (entries: SuppressionsCreateEntry[], options?: Omit<SuppressionsCreateOptions, "entries">): Promise<SuccessResponse>

Response type declarations

ts
interface ErrorResponse {
  message: string;
  statusCode: number | null;
  type: ErrorType;
  response: Record<string, unknown> | null;
}
ts
interface SuccessResponse {
  success: boolean;
  error: ErrorResponse | null;
}

Create type declarations

ts
type SuppressionsTypes = "transactional" | "non-transactional";
ts
interface SuppressionsCreateOptions {
  addToSubAccounts?: boolean;
  /** @deprecated Use `create(entries, options?)` instead. */
  entries: SuppressionsCreateEntry[];
}
ts
interface SuppressionsCreateEntry {
  notes?: string;
  recipient: string;
  types?: SuppressionsTypes[];
}

Source

SourcePlaygroundDocsTests

Released under the MIT License.