Claude API Audit Logging for Enterprise Teams
Enterprise teams adopting Claude almost always hit the same wall: the raw Anthropic API gives you a model endpoint, not an audit trail. If you need to answer "who called the API, with what prompt, at what time, and how much did it cost" for a security review or compliance checklist, you have to build that layer yourself.
This matters because audit logging for an LLM API isn't optional once more than one person or one application touches it. Security teams want to know which internal user or service triggered a request. Finance wants a per-team cost breakdown. Compliance wants proof that access was reviewed and revoked when someone left. None of this comes out of the box with a single shared API key — and a single shared key is exactly what most teams start with.
What "audit logging" actually means for an LLM API
Audit logging for Claude usage typically needs to answer five questions:
- Who made the request (user, service account, or team)
- What was sent and received (prompt, response, tool calls)
- When it happened (timestamp, with timezone)
- How much it cost (tokens in/out, model used)
- Why access existed (which key, which role, when it was granted or revoked)
A real audit system needs all five, tied together and queryable. Most teams only get partial coverage, usually just application-level logs that break down the moment someone shares a key or forgets to log a call.
What Anthropic's API gives you natively
The Claude API itself is intentionally minimal: you send a request with your API key, you get a response. There's no built-in per-user attribution, no searchable request history, and no exportable audit log tied to individual team members inside a single raw key. If your whole organization shares one key, every request looks identical from an audit standpoint — you lose the "who" entirely.
This is fine for a prototype. It becomes a liability the moment Claude is wired into production workflows touching customer data, financial decisions, or regulated content.
Building an audit trail yourself
If you're calling the Claude API directly, the audit layer is your responsibility. A minimal version looks like this:
async function callClaudeWithAudit({ userId, prompt, model }) {
const start = Date.now();
const response = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model,
max_tokens: 1024,
messages: [{ role: "user", content: prompt }],
}),
});
const data = await response.json();
await logToAuditStore({
userId,
model,
promptHash: hash(prompt),
tokensIn: data.usage?.input_tokens,
tokensOut: data.usage?.output_tokens,
timestamp: new Date().toISOString(),
latencyMs: Date.now() - start,
});
return data;
}
This pattern works, but it has three recurring problems in practice:
- Key sprawl. Every team, service, and environment needs its own key, and someone has to track which key belongs to which human or system.
- Inconsistent enforcement. If logging lives in application code, a new feature branch or a direct script can bypass it entirely.
- No central revocation. When a key needs to be killed — someone leaves, a key leaks — you need a place to do that without redeploying code.
Separating keys by user and team
The fastest way to get real audit granularity without building a logging pipeline from scratch is to issue distinct, scoped API keys per user, team, or service, instead of one shared Anthropic key for the whole org. This is the core idea behind SubToAPI: it turns your existing Claude access into application-level API keys (sub_live_...) so each team or service gets its own identifiable key, with usage metadata — token counts, request volume, cost — tracked per key in one dashboard.
That gives you the "who" and "how much" for free, which is usually the hardest part of an audit setup to retrofit later. Team seats mean you can tie keys to actual people instead of a shared secret passed around in Slack, and revoking access for one person doesn't mean rotating a key for the entire organization. For the content and timing side of the audit trail (prompts, responses, timestamps), you still log at the application layer as shown above — SubToAPI handles the identity and usage side, not full prompt-content archiving.
If you're setting this up, start with the quickstart to generate per-service keys, check the messages docs for request/response shape, and see pricing for how seats map to teams. Solo is €9, Team is €19/seat, Scale is €49/seat, and there's a free trial at signup.
Checklist for an enterprise-ready setup
- Issue a distinct key per team or service, never a single org-wide key
- Log every request with a user/service identifier, timestamp, and token usage
- Store prompts and responses only as long as your retention policy requires
- Review and revoke keys on a schedule, not just when someone asks
- Separate streaming and tool-use calls in your logs — they have different failure modes worth tracking separately (see streaming and tool use docs)
- Export usage data regularly so audits don't depend on live dashboard access alone
None of this requires exotic infrastructure. It requires treating API keys as identities, not shared secrets, and treating logging as a non-optional part of the integration, not an afterthought bolted on after a security review flags it.
questions
Does the Claude API have built-in audit logs? No. The raw API returns responses with usage data per request, but it doesn't provide per-user attribution or a searchable audit history out of the box — that layer has to be built or added separately.
What's the minimum audit data enterprises should capture? Who made the request, what was sent and received, when it happened, token usage/cost, and which key or role was used. Missing any one of these makes later investigations much harder.
Can I get per-team usage tracking without building a logging system? Yes — issuing separate API keys per team or user and tracking usage per key, as SubToAPI does, covers identity and cost tracking. You'll still need your own application logging for prompt and response content.