Node.js
import { MailChannels } from "mailchannels-sdk";
const { PARENT_API_KEY, SUB_ACCOUNT_HANDLE, SEND_LIMIT } = 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 (the sub-account to set a limit on)");
if (!SEND_LIMIT) throw new Error("Set SEND_LIMIT (maximum sends per billing period, integer >= 0)");
const mailchannels = new MailChannels(PARENT_API_KEY);
const { success, error } = await mailchannels.subAccounts.setLimit(SUB_ACCOUNT_HANDLE, {
sends: Number(SEND_LIMIT),
});
if (!success) {
console.error("Set sub-account limit failed:", error);
process.exit(1);
}
console.log({ success });import os
import sys
import mailchannels
parent_api_key = os.environ.get("PARENT_API_KEY")
handle = os.environ.get("SUB_ACCOUNT_HANDLE")
send_limit = os.environ.get("SEND_LIMIT")
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 (the sub-account to set a limit on)")
if not send_limit:
sys.exit("Set SEND_LIMIT (maximum sends per billing period, integer >= 0)")
mailchannels.api_key = parent_api_key
response = mailchannels.SubAccounts.Limits.set(handle, sends=int(send_limit))
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");
$send_limit = getenv('SEND_LIMIT') or exit("Error: SEND_LIMIT is not set\n");
$client = new Client(apiKey: $parent_api_key);
$response = $client->subAccounts->limits->set($sub_account_handle, sends: (int) $send_limit);
print_r($response->toArray());curl --request PUT \
--url https://api.mailchannels.net/tx/v1/sub-account/{handle}/limit \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '{
"sends": 1
}'{
"limit": {
"sends": 123
}
}Set Sub-account Limit
Sets the limit for the specified sub-account. The minimum allowed sends is 0.
PUT
/
sub-account
/
{handle}
/
limit
Node.js
import { MailChannels } from "mailchannels-sdk";
const { PARENT_API_KEY, SUB_ACCOUNT_HANDLE, SEND_LIMIT } = 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 (the sub-account to set a limit on)");
if (!SEND_LIMIT) throw new Error("Set SEND_LIMIT (maximum sends per billing period, integer >= 0)");
const mailchannels = new MailChannels(PARENT_API_KEY);
const { success, error } = await mailchannels.subAccounts.setLimit(SUB_ACCOUNT_HANDLE, {
sends: Number(SEND_LIMIT),
});
if (!success) {
console.error("Set sub-account limit failed:", error);
process.exit(1);
}
console.log({ success });import os
import sys
import mailchannels
parent_api_key = os.environ.get("PARENT_API_KEY")
handle = os.environ.get("SUB_ACCOUNT_HANDLE")
send_limit = os.environ.get("SEND_LIMIT")
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 (the sub-account to set a limit on)")
if not send_limit:
sys.exit("Set SEND_LIMIT (maximum sends per billing period, integer >= 0)")
mailchannels.api_key = parent_api_key
response = mailchannels.SubAccounts.Limits.set(handle, sends=int(send_limit))
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");
$send_limit = getenv('SEND_LIMIT') or exit("Error: SEND_LIMIT is not set\n");
$client = new Client(apiKey: $parent_api_key);
$response = $client->subAccounts->limits->set($sub_account_handle, sends: (int) $send_limit);
print_r($response->toArray());curl --request PUT \
--url https://api.mailchannels.net/tx/v1/sub-account/{handle}/limit \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '{
"sends": 1
}'{
"limit": {
"sends": 123
}
}Headers
Path Parameters
Handle of the sub-account to set limit for.
Body
application/json
The value the sub-account limit to set.
Required range:
x >= 0Response
The limit was successfully updated for the specified sub-account.
Show child attributes
Show child attributes
Was this page helpful?
⌘I

