Claude API Multi-Tenant Key Isolation: How It Works
If you're building a SaaS product on top of Claude and serving multiple customers (tenants) from a single backend, "multi-tenant key isolation" means giving each tenant their own distinct API credential, usage quota, and audit trail — instead of routing every customer's requests through one shared Anthropic API key. This matters because a single shared key has no concept of "customer A" vs "customer B": every request looks identical to Anthropic, which makes per-tenant rate limiting, billing, revocation, and abuse containment nearly impossible without building that logic yourself.
The short answer to "how do I isolate keys per tenant on the Claude API" is: Anthropic's API doesn't give you per-tenant sub-keys natively, so you either build an internal key-management and proxy layer, or use a service that already does this for you. Below is what proper isolation looks like, why it's harder than it sounds, and the tradeoffs between the two approaches.
Why a single shared key breaks multi-tenant apps
Most teams start simple: one ANTHROPIC_API_KEY in an environment variable, used by every request regardless of which customer triggered it. This works fine for a single-tenant app, but it falls apart once you have paying customers or internal teams sharing the same backend:
- No per-tenant rate limits. One noisy tenant can exhaust your shared quota and degrade service for everyone else.
- No clean revocation. If a tenant's integration is compromised or they churn, you can't disable just their access without rotating the key for every customer.
- No usage attribution. You can't answer "how many tokens did tenant X use this month" without building your own request-tagging and logging pipeline.
- Weak blast radius control. A bug in one tenant's prompt template or a leaked key in their client-side code exposes your entire account, not just their slice of it.
- Compliance gaps. Enterprise customers increasingly ask for proof that their data and usage are logically separated from other tenants — a shared key makes that hard to demonstrate.
None of these problems are fatal at a handful of customers, but they compound quickly as you scale past a few dozen tenants or start selling to enterprise accounts that ask security questionnaires about key management.
What proper key isolation actually requires
To isolate tenants properly, each tenant needs:
- A unique credential that maps 1:1 to their account, not shared with anyone else.
- Independent rate limits and quotas so one tenant's usage spike doesn't affect another.
- Scoped revocation — the ability to disable one tenant's access instantly without touching others.
- Separate usage metering — token counts, request counts, and cost attributed per tenant, ideally per API key.
- Audit logging tied to the tenant's own credential, not a generic application-level log.
Since Anthropic issues one API key per account rather than per customer-of-your-customer, you need a layer between your application and Anthropic's API that enforces these rules. There are two realistic ways to build that layer.
Option 1: Build the proxy and key-management layer yourself
A self-built solution typically looks like this:
- Store a mapping of
tenant_id → internal_keyin your database. - Issue each tenant a key with your own prefix (e.g.
tenant_abc_live_...) that your backend validates on every request. - Maintain a single real Anthropic API key server-side, and proxy all traffic through your backend after validating the tenant's key.
- Implement rate limiting per tenant key (token bucket or sliding window, stored in Redis).
- Log every request with
tenant_id, token counts, and latency for billing and audit purposes. - Build a revocation endpoint that flips a tenant's key to inactive without touching anyone else's.
This works, but it's a non-trivial amount of infrastructure to build and maintain correctly: key generation and hashing, rate limiter accuracy under concurrency, usage aggregation, and a dashboard for support staff to see per-tenant activity. Most teams underestimate the ongoing maintenance — especially streaming responses, retry logic, and keeping per-tenant metering accurate when requests fail midway.
Option 2: Use a layer that already does this
This is exactly the gap SubToAPI (https://subtoapi.app) is built to close. Instead of exposing your raw Anthropic access to every tenant, you generate a sub_live_... application API key per tenant from your SubToAPI dashboard. Each key is independently scoped: it has its own usage metadata, can be revoked on its own, and routes through the same clean HTTPS interface regardless of how many tenants you have.
A typical setup looks like this:
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 support ticket."}
]
}'
You generate one sub_live_ key per tenant (or per environment, or per internal team), swap in $SUBTOAPI_KEY accordingly, and the rest of your integration code doesn't change. Streaming, tool use, and usage metadata work the same way per key, so you get isolation without rewriting your request logic — see the /docs/quickstart and /docs/messages pages for the full request shape, and /docs/streaming if your tenants consume responses as a stream.
For teams managing this across multiple people rather than purely programmatic tenants, the Team (€19/seat) and Scale (€49/seat) plans add multiple seats so your support, ops, and engineering staff can each have distinct credentials inside the same dashboard, rather than everyone sharing one login and one key. The Solo plan (€9) covers a single-tenant setup if you're not yet at the point of needing per-customer isolation. Pricing details are on /pricing, and you can start with a free trial at /signup.
Practical patterns regardless of approach
Whichever path you take, a few patterns hold up well in production:
- Never embed the real Anthropic key in client-side code. Tenants should only ever see their own scoped key, never the upstream credential.
- Tag every log line with tenant ID, even if you're using a managed key layer — it makes debugging support tickets dramatically faster.
- Set conservative default rate limits per tenant and let high-usage customers request increases, rather than giving everyone unlimited throughput by default.
- Rotate keys on a schedule for enterprise tenants, and make sure your revocation path is a single action, not a multi-step manual process.
- Monitor for anomalous usage per key — a sudden 10x spike from one tenant is often the first sign of a leaked credential or a runaway integration.
Questions
Does Anthropic provide native per-tenant sub-keys for the Claude API? No. Anthropic issues account-level API keys. Per-tenant isolation has to be implemented by you, either through a custom proxy layer or a service like SubToAPI that issues scoped keys per tenant.
What's the minimum viable isolation if I only have a few tenants? Tag every request with a tenant ID in your own logs and apply basic rate limiting per tenant in your application code. It won't give you independent revocation, but it covers usage attribution until you need stronger separation.
Can I revoke one tenant's access without affecting others? Yes, if each tenant has its own credential. With a shared Anthropic key this isn't possible without rotating for everyone; with per-tenant scoped keys (built yourself or via SubToAPI) you can disable a single key instantly.