MONII Guides Netlify bandwidth alerts: the script, and the shortcut
Guide · Netlify

Netlify bandwidth alerts: the script, and the shortcut

Netlify's alerting is three fixed emails. If you want to know at 85%, you have to build it — or use something that already did.

Netlify's native alerting is three emails: 50%, 75%, 100%. Fixed. That is the complete feature.

If your traffic pattern means 75% and 100% are four hours apart, that is not much of a warning system.

The script#

Netlify's API exposes account bandwidth directly. Poll it, compare, notify.

#!/usr/bin/env bash
# netlify-bandwidth-alert.sh — alert when bandwidth crosses a threshold.
set -euo pipefail

: "${NETLIFY_TOKEN:?set NETLIFY_TOKEN}"
: "${NETLIFY_ACCOUNT_ID:?set NETLIFY_ACCOUNT_ID}"
: "${SLACK_WEBHOOK:?set SLACK_WEBHOOK}"
THRESHOLD="${THRESHOLD:-85}"

read -r used included < <(
  curl -fsS "https://api.netlify.com/api/v1/accounts/${NETLIFY_ACCOUNT_ID}/bandwidth" \
    -H "Authorization: Bearer ${NETLIFY_TOKEN}" |
  python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["used"], d["included"])'
)

pct=$(( used * 100 / included ))
echo "bandwidth: ${pct}% (${used}/${included} bytes)"

if (( pct >= THRESHOLD )); then
  curl -fsS -X POST "$SLACK_WEBHOOK" \
    -H 'Content-Type: application/json' \
    -d "{\"text\":\"Netlify bandwidth at ${pct}% of plan allowance.\"}"
fi

Run it on a schedule:

*/15 * * * * /path/to/netlify-bandwidth-alert.sh >> /var/log/netlify-alert.log 2>&1

That is genuinely all it takes, and if you have somewhere to run a cron job you should probably just do this.

What the script costs you#

Being honest about it, because "just write a script" is easy advice to give and slightly harder to live with:

  • It needs somewhere to run. Your laptop does not count — it is shut at 3am, which is when this matters. So now you are hosting a monitor, which is a thing to maintain and, ironically, to pay for.
  • A long-lived Netlify token sits in that environment. Scope it as tightly as Netlify allows, and know where it is.
  • Slack at 3am is not a page. A message in a channel is not the same as a notification that wakes you.
  • It watches bandwidth only. Build minutes, function invocations and credits need their own polling against their own endpoints.
  • It cannot do anything. It tells you. Stopping it is still a separate manual scramble.

None of that makes it a bad idea. It is a good idea, and for a lot of people it is the right answer.

The shortcut#

MONII does the same polling, at any threshold you choose, pushed to your phone rather than a channel — and with the Netlify kill switch attached to the notification, so finding out and acting are the same gesture.

Same honest caveat as the script: roughly a fifteen-minute poll interval, and Netlify's own usage figures are themselves delayed. Neither approach is real-time, because the underlying data is not.

The one that actually prevents it#

Both of the above are alarms. Neither is prevention.

If unexpected bandwidth is a recurring worry, put Cloudflare in front of Netlify. It absorbs the traffic before it reaches Netlify's meter, which is strictly better than being told about it quickly. Do that first, then add an alarm for what gets through.

Questions people actually ask

Does Netlify have bandwidth alerts?

Only fixed ones. Netlify sends a usage email and in-app notification at 50%, 75% and 100% of your allowance. There is no way to set your own threshold natively.

Can I get a Netlify alert at 85%?

Not natively. You need to poll the Netlify API yourself, or use a third-party monitor.

Which Netlify API endpoint reports bandwidth?

The account-level bandwidth endpoint, /api/v1/accounts/{account_id}/bandwidth, returns used and included figures for the current billing period.

Skip the cron job

MONII watches Netlify bandwidth and credits, alerts at any percentage you set, and can password-lock the site from the notification.

Get MONII for iOS ›