Class: Anthropic::Resources::Beta::Organization::Analytics::UserUsageReport

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/organization/analytics/user_usage_report.rb,
sig/anthropic/resources/beta/organization/analytics/user_usage_report.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ UserUsageReport

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UserUsageReport.

Parameters:



118
119
120
# File 'lib/anthropic/resources/beta/organization/analytics/user_usage_report.rb', line 118

def initialize(client:)
  @client = client
end

Instance Method Details

#list(starting_at:, bucket_width: nil, claude_tag_categories: nil, claude_tag_user_ids: nil, context_windows: nil, ending_at: nil, exclude_deleted_users: nil, group_by: nil, inference_geos: nil, limit: nil, models: nil, order: nil, order_by: nil, page: nil, products: nil, rbac_group_ids: nil, slack_channel_ids: nil, speeds: nil, user_ids: nil, request_options: {}) ⇒ Anthropic::Internal::ReportPageCursor<Anthropic::Models::Beta::Organization::BetaAnalyticsUsageUsersItem>

[Legacy] Get per-user token usage across a date range.

Returns usage per user, ranked by the chosen token metric; group_by[] or bucket_width splits a user across several rows. Use this to see which users consume the most tokens. Only usage attributed to a user account is included, so usage with no user account, such as Code Review usage and Claude Tag usage in Slack channels, is left out. Claude Tag one-to-one direct messages are included, with product claude-tag, only for members who have connected a Claude account. To see all usage by product, call GET /v1/organizations/analytics/usage_report with group_by[]=product. Available to organizations on a Claude Enterprise plan. Requires an API key with the read:analytics scope.

This endpoint is one of the legacy Claude Enterprise usage and cost reports. For new integrations, use GET /v1/organizations/analytics/usage in the Usage and Cost Analytics API instead. To move an existing integration, see Migrate from the Claude Enterprise usage and cost reports.

Some parameter documentations has been truncated, see Models::Beta::Organization::Analytics::UserUsageReportListParams for more details.

Parameters:

  • starting_at (Time) —

    Start of range, inclusive. RFC 3339 tz-aware. Must be within the last 365 days a

  • bucket_width (Symbol, Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::BucketWidth, nil) —

    Time-bucket granularity. When set, each row's starting_at and ending_at are

  • claude_tag_categories (Array<Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsClaudeTagCategory>, nil) —

    Filter to Claude Tag (Claude in Slack) usage in specific spend categories. Usage

  • claude_tag_user_ids (Array<String>, nil) —

    Filter to Claude Tag (Claude in Slack) usage attributed to specific Slack users,

  • context_windows (Array<Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsContextWindow>, nil) —

    Filter to specific context-window pricing tiers. Use group_by[]=context_window

  • ending_at (Time, nil) —

    End of range, exclusive. When omitted, defaults to the earlier of now and

  • exclude_deleted_users (Boolean) —

    If true, omit rows for users who are deleted (deleted: true). A page may conta

  • group_by (Array<Symbol, Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::GroupBy>, nil) —

    Break each actor's row out by the given dimensions. Accepts the same values as t

  • inference_geos (Array<Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsInferenceGeoFilter>, nil) —

    Filter to specific inference regions. not_available matches rows where the reg

  • limit (Integer) —

    Number of rows per page (1-1000, default 20). One row per actor unless

  • models (Array<String>, nil) —

    Models to include. Defaults to all models. Use group_by[]=model to break out p

  • order (Symbol, Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::Order) —

    Sort direction. Defaults to desc.

  • order_by (Symbol, Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::OrderBy) —

    Metric to rank actors by. Defaults to total_tokens.

  • page (String, nil) —

    Opaque cursor from a previous response's next_page field.

  • products (Array<Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsProductFilter>, nil) —

    Product surfaces to include. Defaults to all products.

  • rbac_group_ids (Array<String>, nil) —

    Filter to usage attributed to specific RBAC groups. Accepts tagged RBAC group ID

  • slack_channel_ids (Array<String>, nil) —

    Filter to usage originating from specific Slack channels. Use

  • speeds (Array<Symbol, Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::Speed>, nil) —

    Filter to fast or standard inference mode. Use group_by[]=speed to break out p

  • user_ids (Array<String>, nil) —

    Filter to specific users by tagged user ID.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • starting_at: (Time)
  • bucket_width: (Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::bucket_width, nil)
  • claude_tag_categories: (::Array[Anthropic::Models::Beta::Organization::beta_analytics_claude_tag_category], nil)
  • claude_tag_user_ids: (::Array[String], nil)
  • context_windows: (::Array[Anthropic::Models::Beta::Organization::beta_analytics_context_window], nil)
  • ending_at: (Time, nil)
  • exclude_deleted_users: (Boolean)
  • group_by: (::Array[Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::group_by], nil)
  • inference_geos: (::Array[Anthropic::Models::Beta::Organization::beta_analytics_inference_geo_filter], nil)
  • limit: (Integer)
  • models: (::Array[String], nil)
  • order: (Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::order)
  • order_by: (Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::order_by)
  • page: (String, nil)
  • products: (::Array[Anthropic::Models::Beta::Organization::beta_analytics_product_filter], nil)
  • rbac_group_ids: (::Array[String], nil)
  • slack_channel_ids: (::Array[String], nil)
  • speeds: (::Array[Anthropic::Models::Beta::Organization::Analytics::UserUsageReportListParams::speed], nil)
  • user_ids: (::Array[String], nil)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/anthropic/resources/beta/organization/analytics/user_usage_report.rb', line 77

def list(params)
  parsed, options =
    Anthropic::Beta::Organization::Analytics::UserUsageReportListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed)
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::ORGANIZATION_ANALYTICS_USER_USAGE_REPORT_LIST,
    span_route: "/v1/organizations/analytics/user_usage_report",
    span_query: %w[
      bucket_width
      claude_tag_categories
      claude_tag_user_ids
      context_windows
      ending_at
      exclude_deleted_users
      group_by
      inference_geos
      limit
      models
      order
      order_by
      page
      products
      rbac_group_ids
      slack_channel_ids
      speeds
      starting_at
      user_ids
    ],
    method: :get,
    path: "v1/organizations/analytics/user_usage_report",
    query: query,
    page: Anthropic::Internal::ReportPageCursor,
    model: Anthropic::Beta::Organization::BetaAnalyticsUsageUsersItem,
    options: options
  )
end