Skip to main content

Overview

The Usage Tracking API provides visibility into token consumption, costs, and usage patterns across all Claude accounts. You can retrieve summary statistics, historical usage data, and per-window breakdowns.
All Usage endpoints require dashboard authentication via session cookie.

Get Usage Summary

endpoint
Retrieve aggregated usage statistics including current window state, costs, and key metrics.

Response

object
required
Primary (daily) usage window aggregate
object
Secondary (weekly) usage window aggregate (if applicable)
object
required
Cost metrics
object
Usage metrics

Example Request

Example Response

Get Usage History

endpoint
Retrieve historical usage data per account over a specified time window.

Query Parameters

integer
default:"24"
Number of hours to look back (1-168). Default is 24 hours.

Response

integer
required
The number of hours covered by this response
array
required
Array of per-account usage history

Example Request

Example Response

Get Usage Window

endpoint
Retrieve current usage breakdown by window (primary or secondary) for all accounts.

Query Parameters

string
default:"primary"
Which window to query: primary (daily) or secondary (weekly)

Response

string
required
The window type queried (primary or secondary)
integer
Window duration in minutes
array
required
Array of per-account usage in this window (same structure as history endpoint)

Example Request

Example Response

Usage Windows

Claude accounts have two usage windows:

Primary Window (Daily)

  • Resets every 24 hours
  • Typically more restrictive quota
  • Used for short-term rate limiting
  • window_minutes: 1440

Secondary Window (Weekly)

  • Resets every 7 days
  • Larger quota for sustained usage
  • Used for longer-term capacity planning
  • window_minutes: 10080
Both windows are tracked independently. Codex-LB considers both when routing requests using the usage_weighted strategy.

Usage Metrics Explained

Credits vs Tokens

  • Credits: Abstract capacity units used by Claude. Not directly equivalent to tokens.
  • Tokens: Actual text units processed (input + output)
  • Cached Tokens: Input tokens served from prompt cache

Cost Tracking

Costs are calculated based on:
  • Model pricing (varies by model)
  • Token counts (input, output, cached)
  • Any reasoning effort multipliers
The totalUsd7d field aggregates costs across all accounts for the past 7 days.

Error Rate

The errorRate7d metric shows the percentage of requests that resulted in errors over the past week. Common error types:
  • overloaded_error: Claude API is overloaded
  • rate_limit_error: Account quota exceeded
  • invalid_request_error: Malformed request
The top_error field shows the most frequent error message, helping identify systemic issues.

Aggregation Logic

Summary Endpoint

The summary endpoint aggregates across all active accounts:
  • remaining_percent: Weighted average based on capacity
  • capacity_credits: Sum of all account capacities
  • remaining_credits: Sum of remaining credits across accounts
  • reset_at: Earliest reset time across accounts (primary window)

History Endpoint

Historical data is sampled at regular intervals. The remaining_percent_avg represents the average remaining capacity over the requested time window.

Use Cases

Capacity Planning

Monitor primary and secondary window usage to predict when you’ll need additional accounts.

Cost Management

Track 7-day costs to stay within budget and identify expensive models or usage patterns.

Health Monitoring

Watch error rates and top errors to detect API issues or configuration problems.

Load Distribution

Use per-account history to verify load balancing is working as expected.

Authentication

All usage endpoints require dashboard authentication via session cookie.

Common Patterns

Dashboard Widget

Poll the summary endpoint every 30-60 seconds to power a real-time dashboard:

Historical Analysis

Retrieve a week’s worth of history for trend analysis:

Window Comparison

Compare primary and secondary window usage: