Claude API Usage Quota Per User: Setup Guide
If you're building a product on top of Claude and letting multiple users or customers send requests, you need a way to cap how much each one can consume. The Anthropic API itself doesn't expose a "per end-user quota" setting — it tracks usage at the workspace and API key level, not per individual user inside your app. So setting up per-user quotas means building a thin tracking-and-enforcement layer yourself, or using a provider that already gives you one key per user with visibility into what each key spends.
This article walks through both approaches: a self-built quota system using the usage object returned on every Claude response, and a faster path using per-user API keys where usage metadata is already separated for you. By the end you'll have a working pattern you can drop into a Node.js, Python, or any backend that proxies requests to Claude.
Why per-user quotas matter
Without quotas, a single misbehaving script, an infinite retry loop, or one heavy user can consume your entire monthly budget in a day. Common reasons teams add per-user limits:
- Cost control — cap spend per customer tier (free vs paid plans)
- Fair usage — stop one user from starving API capacity for others
- Billing alignment — meter usage so pricing tiers map to actual consumption
- Abuse prevention — detect and throttle accounts generating unusual volume
Option 1: Build your own tracking layer
Every Claude Messages API response includes a usage field with input_tokens and output_tokens. That's your raw material for quota enforcement — you log it, aggregate it, and check it before letting the next request through.
Step 1: Store usage per user
CREATE TABLE user_usage (
user_id TEXT NOT NULL,
period DATE NOT NULL,
input_tokens INTEGER DEFAULT 0,
output_tokens INTEGER DEFAULT 0,
request_count INTEGER DEFAULT 0,
PRIMARY KEY (user_id, period)
);
Use a daily or monthly period depending on how often you want quotas to reset.
Step 2: Check quota before the call
async function checkQuota(userId, limitTokens) {
const row = await db.query(
"SELECT input_tokens + output_tokens AS total FROM user_usage WHERE user_id = $1 AND period = CURRENT_DATE",
[userId]
);
const used = row.rows[0]?.total || 0;
if (used >= limitTokens) {
throw new Error("Quota exceeded for this period");
}
}
Step 3: Record usage after the call
const response = await claude.messages.create({
model: "claude-opus-4",
max_tokens: 1024,
messages: [{ role: "user", content: prompt }],
});
await db.query(
`INSERT INTO user_usage (user_id, period, input_tokens, output_tokens, request_count)
VALUES ($1, CURRENT_DATE, $2, $3, 1)
ON CONFLICT (user_id, period) DO UPDATE SET
input_tokens = user_usage.input_tokens + EXCLUDED.input_tokens,
output_tokens = user_usage.output_tokens + EXCLUDED.output_tokens,
request_count = user_usage.request_count + 1`,
[userId, response.usage.input_tokens, response.usage.output_tokens]
);
This gives you full control over quota logic — per-request limits, per-day limits, tiered limits by plan, token-type weighting, whatever you need. The tradeoff is that you're maintaining a database table, a reset job, and edge cases around concurrent requests racing past the limit check.
Enforcement strategies
- Hard cutoff — reject requests once the limit is hit, return a 429-style error
- Soft warning — allow the request but flag the account at 80–90% usage
- Graceful downgrade — switch to a cheaper/faster model once a threshold is passed instead of blocking entirely
- Rolling vs fixed windows — fixed resets (start of month) are simpler; rolling windows (last 30 days) feel fairer to users but require more complex queries
Option 2: Per-user API keys with built-in usage metadata
If you don't want to build and maintain the tracking table yourself, the alternative is issuing a separate API key per user or per customer, and reading usage straight from the provider instead of recomputing it in your own database.
This is what SubToAPI is built for: it turns your existing Claude access into an HTTPS API where you can generate individual sub_live_... keys per user or per team seat, and each key reports its own usage metadata. Instead of writing the quota-tracking SQL above, you check usage per key through the dashboard or API and set limits at the key level.
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."}]
}'
Each response includes the same usage fields you'd get from the underlying Claude API, so the enforcement logic in your app stays identical — you're just not responsible for the key management and aggregation plumbing. For teams that need this per-seat (one key per developer or per customer account), the Team and Scale plans handle seat-based key issuance directly, which maps cleanly onto a per-user quota model without extra infrastructure. See /pricing for how seats map to keys, and /docs/quickstart to get a key issued in a few minutes.
Choosing between the two approaches
| Factor | Self-built tracking | Per-user keys | |---|---|---| | Setup time | Hours to days | Minutes | | Maintenance | You own the DB and reset jobs | Managed | | Flexibility | Fully custom logic | Limited to key-level limits + your own app logic | | Good for | Complex tiered billing | Teams, internal tools, fast rollout |
Many teams end up combining both: per-user keys for isolation and basic usage visibility, plus a lightweight app-side check for custom business rules like plan tiers or feature-specific limits.
If you're starting from scratch, read through /docs/messages for the request/response shape and /docs/streaming if your app streams responses — streamed requests still return a final usage object you can log the same way.
Getting started
- Decide your quota unit — tokens, requests, or dollars
- Decide your reset window — daily, monthly, or rolling
- Decide enforcement — hard block, soft warning, or model downgrade
- Pick your tracking method — self-built table or per-user API keys
- Test with a low limit first to confirm the block actually triggers before shipping
If you want to skip the key management layer entirely, you can set up a per-user key structure at /signup and start testing quotas against real usage data within minutes.
questions
Does the Claude API support per-user quotas natively? No. Anthropic meters usage at the API key and workspace level, not per individual end user. Per-user quotas require either custom tracking in your app or issuing a separate key per user.
What's the simplest way to enforce a per-user limit? Log input_tokens and output_tokens from each response into a per-user table keyed by date, then check the running total before allowing the next request.
Should quotas reset daily or monthly? Monthly aligns with billing cycles and subscription plans; daily is better for preventing short bursts of abuse. Many products use monthly hard limits with daily soft warnings.