Skip to content

[FEATURE] Expose enterprise spending limit data via /api/oauth/usage #34348

Description

@hongjun-bae

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

I'm building a Claude Code statusline extension that displays real-time usage information. For subscription plans, the /api/oauth/usage endpoint provides five_hour and seven_day utilization data, which works great for showing usage limits with reset timers.

However, for enterprise plans, this endpoint returns no usage data at all. Enterprise users have per-user monthly spending limits visible in the Console UI (Settings > Usage), but there's no programmatic way to access this information. The statusline can only show rough session cost estimates, while subscription users get a much richer experience with actual limit tracking.

This makes it impossible to build tools that help enterprise users monitor their budget consumption in real time.

Proposed Solution

The /api/oauth/usage endpoint should return spending limit data for enterprise plans, similar to how it already returns five_hour/seven_day data for subscription plans:

{
  "spending_limit": {
    "limit_usd": 1000.00,
    "used_usd": 133.49,
    "utilization": 13.35,
    "resets_at": "2025-05-01T00:00:00Z"
  }
}

This keeps the response structure consistent — enterprise users get a spending_limit object, subscription users get five_hour/seven_day objects. Tools consuming this API can handle both plan types uniformly.

Alternative Solutions

  • Console UI: Manually checking Settings > Usage in the browser — not programmatic, breaks workflow.
  • Session cost estimation: Calculating approximate cost from token counts per model — inaccurate and doesn't reflect the actual spending limit or cumulative usage.

Priority

Nice to have — Enterprise users can still work without this, but it would significantly improve the developer experience and enable better tooling.

Feature Category

API / CLI behavior

Use Case Example

  1. An enterprise user starts a Claude Code session with a $1,000/month spending limit
  2. They've used $800 so far this month and want to be mindful of remaining budget
  3. Their statusline currently shows: Opus 4.6 | v1.0.80 | main | 120k/1.0M | $2.35 (only session cost)
  4. With this feature, the statusline could show: Opus 4.6 | v1.0.80 | main | 120k/1.0M | 80% (5d12h) — showing 80% of monthly limit used with reset timer, just like subscription plans show their 5h/7d limits
  5. This helps users pace their usage and avoid hitting the limit unexpectedly

Additional Context

  • The subscription plan response structure (five_hour.utilization, five_hour.resets_at) is a great pattern to follow
  • The proposed spending_limit object mirrors the same shape for consistency
  • This would enable the community to build richer statusline extensions and monitoring tools for enterprise environments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions