Claude API Usage Alerts: Slack Notifications Setup
If you're searching for a way to get Slack notifications when Claude API usage or spend crosses a threshold, the short answer is: the Claude API itself has no built-in alerting system, so you need to poll usage data on a schedule and push it to a Slack incoming webhook yourself. This is a solved problem — it takes about 30 minutes to wire up — but there are a few design decisions that determine whether your alerts are actually useful or just noise.
This guide walks through how to build usage alerts for Claude, what thresholds are worth watching, and how to route the data into Slack in a way your team will actually pay attention to.
Why you need usage alerts in the first place
Token-based billing is easy to underestimate. A prompt that costs €0.02 in testing can cost €200/day once it's live and getting real traffic, especially with long context windows, tool use loops, or a feature that accidentally re-sends the full conversation history on every turn. Without alerts, the first signal you get is often the invoice — or a rate-limit error in production at 2am.
Slack notifications solve the "who finds out and when" problem: instead of someone manually checking a dashboard, the team gets pinged the moment usage crosses a line you defined in advance.
What to alert on
Not every number needs a Slack message. Useful alert categories:
- Daily spend threshold — e.g. notify if today's Claude API cost exceeds €50
- Token volume spike — a sudden 3x jump in input or output tokens compared to the same hour yesterday
- Error rate — a rise in 429s (rate limits) or 5xx responses
- Per-key or per-team usage — useful once you have multiple apps or teams sharing a Claude integration
- Approaching a hard cap — if you've set a monthly budget, alert at 80% and 100%
Trying to alert on everything (every request, every token) just trains people to ignore the channel. Pick 3–4 thresholds and start there.
Building the alert pipeline
The pattern is always the same three steps:
- Pull usage data on a schedule (cron job, scheduled Lambda, GitHub Action, etc.)
- Compare it against your thresholds
- Post a formatted message to a Slack incoming webhook if a threshold is breached
Step 1: Get usage data
If you're calling the Claude API directly, you'll need to log token counts and cost yourself on every request, since there's no centralized usage endpoint to query after the fact. Most teams end up writing this logging logic from scratch and storing it in a database or a simple log file.
If you're using SubToAPI as your Claude API layer, this part is already done — every request through your sub_live_ key returns usage metadata (input tokens, output tokens, cost) and the dashboard aggregates it per key and per team seat. You can pull that data directly instead of building your own tracking table. See /docs/messages for the response shape.
Step 2: Compare against thresholds
A simple daily check script:
const THRESHOLD_EUR = 50;
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
async function checkUsage() {
const today = new Date().toISOString().slice(0, 10);
const usage = await getUsageForDate(today); // your own tracking or SubToAPI usage data
if (usage.costEur >= THRESHOLD_EUR) {
await notifySlack({
text: `⚠️ Claude API spend for ${today} is €${usage.costEur.toFixed(2)}, over the €${THRESHOLD_EUR} threshold.`,
tokens: usage.totalTokens,
requests: usage.requestCount,
});
}
}
checkUsage();
Step 3: Post to Slack
Create an incoming webhook in your Slack workspace (Slack app settings → Incoming Webhooks → Add New Webhook to Workspace), copy the URL, and store it as an environment variable. Then post to it:
async function notifySlack({ text, tokens, requests }) {
await fetch(process.env.SLACK_WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text,
blocks: [
{
type: "section",
text: { type: "mrkdwn", text },
},
{
type: "context",
elements: [
{
type: "mrkdwn",
text: `Tokens: ${tokens.toLocaleString()} · Requests: ${requests}`,
},
],
},
],
}),
});
}
Run this on a schedule with cron, a Vercel/Netlify scheduled function, or a GitHub Action with a schedule trigger. Hourly is usually enough for spend alerts; if you're watching for error-rate spikes, every 5–10 minutes is better.
Pulling usage from SubToAPI into the same pipeline
If you're running Claude through SubToAPI, each application key exposes usage metadata you can query and feed straight into the script above instead of maintaining your own token-tracking database:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket"}]
}'
The response includes usage fields alongside the message content, so your alert script just needs to sum them per key over the day and compare against your threshold — no separate accounting system required. Team and Scale plans also break usage down per seat in the dashboard, which is useful if you want per-team Slack channels instead of one firehose channel. See /pricing for plan details and /docs/quickstart to get a key.
Keeping alerts useful over time
A few practical tips once the pipeline is running:
- Route by severity to different channels. Send hard-cap breaches to a channel with @here, and soft warnings to a quieter one nobody needs to react to immediately.
- Include a link to the dashboard or query, not just a number, so whoever reads the alert can dig in without switching tools.
- Re-evaluate thresholds monthly. Traffic grows, and a threshold that made sense at launch will trigger constantly six months later.
- Alert on rate-limit errors separately from cost. A spike in 429s is a UX problem right now, not just a billing concern — see /docs/streaming and /docs/tools if your usage spikes are coming from streaming retries or tool-use loops.
questions
Does the Claude API have native Slack integration for usage alerts? No. Anthropic's API doesn't ship a built-in alerting or Slack integration — you poll usage data on a schedule and push it to a Slack incoming webhook yourself, as shown above.
What's the easiest way to track Claude API cost without building my own logging? Route your calls through a service that returns usage and cost metadata per request, like SubToAPI, and aggregate that instead of instrumenting every call in your own codebase. See /docs/messages for the response format.
How often should usage alert checks run? Daily spend checks work well on an hourly cadence; error-rate or spike detection should run every 5–10 minutes so you catch problems while they're still small.