The custom message limit imposes a hard limit on how many messages your account can send during a calendar month.
Fetch the details of custom sending limit on the account
import fetch from 'node-fetch'; async function run() { const resp = await fetch( `https://api.mailgun.net/v5/accounts/limit/custom/monthly`, { method: 'GET', headers: { Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64') } } ); const data = await resp.text(); console.log(data); } run();
{- "limit": 10000,
- "current": 0,
- "period": "1m"
}
Set a custom sending limit
import fetch from 'node-fetch'; async function run() { const query = new URLSearchParams({limit: '0'}).toString(); const resp = await fetch( `https://api.mailgun.net/v5/accounts/limit/custom/monthly?${query}`, { method: 'PUT', headers: { Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64') } } ); const data = await resp.text(); console.log(data); } run();
{- "success": true
}
Delete a custom sending limit
import fetch from 'node-fetch'; async function run() { const resp = await fetch( `https://api.mailgun.net/v5/accounts/limit/custom/monthly`, { method: 'DELETE', headers: { Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64') } } ); const data = await resp.text(); console.log(data); } run();
{- "success": true
}
Re-enable an account that was disabled for reaching the custom sending limit
import fetch from 'node-fetch'; async function run() { const resp = await fetch( `https://api.mailgun.net/v5/accounts/limit/custom/enable`, { method: 'PUT', headers: { Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64') } } ); const data = await resp.text(); console.log(data); } run();
{- "success": true
}