import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, RECIPIENT } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!RECIPIENT) throw new Error("Set RECIPIENT to the email address to suppress");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { success, error } = await mailchannels.suppressions.create({
entries: [{ recipient: RECIPIENT }],
});
if (!success) {
console.error("Create suppression failed:", error);
process.exit(1);
}
console.log("Suppression created");import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY (parent or sub-account) before running")
recipient = os.environ.get("RECIPIENT")
if not recipient:
sys.exit("Set RECIPIENT to the email address to suppress")
response = mailchannels.Suppressions.create([{"recipient": recipient}])
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$recipient = getenv('RECIPIENT') or exit("Error: RECIPIENT is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->suppressions->create([['recipient' => $recipient]]);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/suppression-list \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"suppression_entries": [
{
"recipient": "<string>",
"notes": "<string>",
"suppression_types": []
}
],
"add_to_sub_accounts": false
}
'{
"errors": [
"<string>"
]
}Create Suppression Entries
Creates suppression entries for the specified account. Parent accounts can create suppression entries for all associated sub-accounts. If suppression_type 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.
import { MailChannels } from "mailchannels-sdk";
const { MAILCHANNELS_API_KEY, RECIPIENT } = process.env;
if (!MAILCHANNELS_API_KEY) throw new Error("Set MAILCHANNELS_API_KEY before running");
if (!RECIPIENT) throw new Error("Set RECIPIENT to the email address to suppress");
const mailchannels = new MailChannels(MAILCHANNELS_API_KEY);
const { success, error } = await mailchannels.suppressions.create({
entries: [{ recipient: RECIPIENT }],
});
if (!success) {
console.error("Create suppression failed:", error);
process.exit(1);
}
console.log("Suppression created");import os
import sys
import mailchannels
if not os.environ.get("MAILCHANNELS_API_KEY"):
sys.exit("Set MAILCHANNELS_API_KEY (parent or sub-account) before running")
recipient = os.environ.get("RECIPIENT")
if not recipient:
sys.exit("Set RECIPIENT to the email address to suppress")
response = mailchannels.Suppressions.create([{"recipient": recipient}])
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$api_key = getenv('MAILCHANNELS_API_KEY') or exit("Error: MAILCHANNELS_API_KEY is not set\n");
$recipient = getenv('RECIPIENT') or exit("Error: RECIPIENT is not set\n");
$client = new Client(apiKey: $api_key);
$response = $client->suppressions->create([['recipient' => $recipient]]);
print_r($response->toArray());curl --request POST \
--url https://api.mailchannels.net/tx/v1/suppression-list \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"suppression_entries": [
{
"recipient": "<string>",
"notes": "<string>",
"suppression_types": []
}
],
"add_to_sub_accounts": false
}
'{
"errors": [
"<string>"
]
}Headers
Body
The details of the suppression entries to create.
The total number of suppression entries to create, for the parent and/or its sub-accounts, must not exceed 1000.
Show child attributes
Show child attributes
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
All suppression entries were successfully created.
Was this page helpful?

