Node.js
import { MailChannels } from "mailchannels-sdk";
const { PARENT_API_KEY, SUB_ACCOUNT_HANDLE, SMTP_PASSWORD_ID } = process.env;
if (!PARENT_API_KEY) throw new Error("Set PARENT_API_KEY (a parent-account API key) before running");
if (!SUB_ACCOUNT_HANDLE) throw new Error("Set SUB_ACCOUNT_HANDLE");
if (!SMTP_PASSWORD_ID) throw new Error("Set SMTP_PASSWORD_ID (the ID of the password to delete)");
const mailchannels = new MailChannels(PARENT_API_KEY);
const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword(
SUB_ACCOUNT_HANDLE,
Number(SMTP_PASSWORD_ID),
);
if (!success) {
console.error("Delete SMTP password failed:", error);
process.exit(1);
}
console.log(`Deleted SMTP password ${SMTP_PASSWORD_ID} for sub-account ${SUB_ACCOUNT_HANDLE}`);import os
import sys
import mailchannels
parent_api_key = os.environ.get("PARENT_API_KEY")
handle = os.environ.get("SUB_ACCOUNT_HANDLE")
password_id = os.environ.get("SMTP_PASSWORD_ID")
if not parent_api_key:
sys.exit("Set PARENT_API_KEY (a parent-account API key) before running")
if not handle:
sys.exit("Set SUB_ACCOUNT_HANDLE")
if not password_id:
sys.exit("Set SMTP_PASSWORD_ID (the ID of the password to delete)")
mailchannels.api_key = parent_api_key
response = mailchannels.SubAccounts.SmtpPasswords.delete(handle, password_id)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$parent_api_key = getenv('PARENT_API_KEY') or exit("Error: PARENT_API_KEY is not set\n");
$sub_account_handle = getenv('SUB_ACCOUNT_HANDLE') or exit("Error: SUB_ACCOUNT_HANDLE is not set\n");
$smtp_password_id = getenv('SMTP_PASSWORD_ID') or exit("Error: SMTP_PASSWORD_ID is not set\n");
$client = new Client(apiKey: $parent_api_key);
$response = $client->subAccounts->smtpPasswords->delete($sub_account_handle, (int) $smtp_password_id);
echo "HTTP Status: " . $response->statusCode . "\n";curl --request DELETE \
--url https://api.mailchannels.net/tx/v1/sub-account/{handle}/smtp-password/{id} \
--header 'X-Api-Key: <x-api-key>'Delete Sub-account SMTP Password
Deletes the SMTP password identified by its ID for the specified sub-account.
DELETE
/
sub-account
/
{handle}
/
smtp-password
/
{id}
Node.js
import { MailChannels } from "mailchannels-sdk";
const { PARENT_API_KEY, SUB_ACCOUNT_HANDLE, SMTP_PASSWORD_ID } = process.env;
if (!PARENT_API_KEY) throw new Error("Set PARENT_API_KEY (a parent-account API key) before running");
if (!SUB_ACCOUNT_HANDLE) throw new Error("Set SUB_ACCOUNT_HANDLE");
if (!SMTP_PASSWORD_ID) throw new Error("Set SMTP_PASSWORD_ID (the ID of the password to delete)");
const mailchannels = new MailChannels(PARENT_API_KEY);
const { success, error } = await mailchannels.subAccounts.deleteSmtpPassword(
SUB_ACCOUNT_HANDLE,
Number(SMTP_PASSWORD_ID),
);
if (!success) {
console.error("Delete SMTP password failed:", error);
process.exit(1);
}
console.log(`Deleted SMTP password ${SMTP_PASSWORD_ID} for sub-account ${SUB_ACCOUNT_HANDLE}`);import os
import sys
import mailchannels
parent_api_key = os.environ.get("PARENT_API_KEY")
handle = os.environ.get("SUB_ACCOUNT_HANDLE")
password_id = os.environ.get("SMTP_PASSWORD_ID")
if not parent_api_key:
sys.exit("Set PARENT_API_KEY (a parent-account API key) before running")
if not handle:
sys.exit("Set SUB_ACCOUNT_HANDLE")
if not password_id:
sys.exit("Set SMTP_PASSWORD_ID (the ID of the password to delete)")
mailchannels.api_key = parent_api_key
response = mailchannels.SubAccounts.SmtpPasswords.delete(handle, password_id)
print(response)<?php
require_once __DIR__ . '/vendor/autoload.php';
use MailChannels\Client;
$parent_api_key = getenv('PARENT_API_KEY') or exit("Error: PARENT_API_KEY is not set\n");
$sub_account_handle = getenv('SUB_ACCOUNT_HANDLE') or exit("Error: SUB_ACCOUNT_HANDLE is not set\n");
$smtp_password_id = getenv('SMTP_PASSWORD_ID') or exit("Error: SMTP_PASSWORD_ID is not set\n");
$client = new Client(apiKey: $parent_api_key);
$response = $client->subAccounts->smtpPasswords->delete($sub_account_handle, (int) $smtp_password_id);
echo "HTTP Status: " . $response->statusCode . "\n";curl --request DELETE \
--url https://api.mailchannels.net/tx/v1/sub-account/{handle}/smtp-password/{id} \
--header 'X-Api-Key: <x-api-key>'Was this page helpful?
⌘I

