SPB Git

Repository Public

cost.md 43.4 KB 1,081 lines markdown

1---2title: Cost3url: https://platform.claude.com/docs/en/api/beta/organization/analytics/cost4---56# Cost78## Get Cost Over Time910**GET** `/v1/organizations/analytics/cost_report`1112Get cost in USD over time across a date range.1314Returns cost bucketed by minute, hour, or day, optionally broken down by15product, model, context window, inference region, speed, cost type, or16token type. Available to organizations on a Claude Enterprise plan.17Requires an API key with the `read:analytics` scope.1819### Query parameters2021- `starting_at: string`2223  Start of range, inclusive. RFC 3339 tz-aware. Must be within the last 365 days and no earlier than 2026-01-01T00:00:00Z.2425  format: date-time2627- `bucket_width: optional "1d" or "1h" or "1m"`2829  Time bucket granularity.3031  default: 1d3233  - `"1d"`3435  - `"1h"`3637  - `"1m"`3839- `claude_tag_categories: optional array of "dm" or "engaged" or "monitoring" or 2 more`4041  Filter to Claude Tag (Claude in Slack) usage in specific spend categories. Usage with no category never matches. `dm` usage is reported under the user's product rather than `claude-tag`, so combining this filter with `products[]=claude-tag` excludes it. Use `group_by[]=claude_tag_category` to break out per-category values.4243  maxItems: 1004445  - `"dm"`4647  - `"engaged"`4849  - `"monitoring"`5051  - `"proactive"`5253  - `"scheduled"`5455- `claude_tag_user_ids: optional array of string`5657  Filter to Claude Tag (Claude in Slack) usage attributed to specific Slack users, by Slack user ID (for example `U0123ABCDEF`), not claude.ai user ID. Usage that is not Claude Tag, and Claude Tag usage not attributed to a single user, never matches. Use `group_by[]=claude_tag_user_id` to break out per-user values.5859  maxItems: 1006061- `context_windows: optional array of "0-200k" or "200k-1M"`6263  Filter to specific context-window pricing tiers. Use `group_by[]=context_window` to break out per-tier values.6465  maxItems: 1006667  - `"0-200k"`6869  - `"200k-1M"`7071- `ending_at: optional string`7273  End of range, exclusive. When omitted, defaults to the earlier of now and `starting_at` + 31 days. The range may span at most 31 days.7475  format: date-time7677- `group_by: optional array of "claude_tag_category" or "claude_tag_user_id" or "context_window" or 8 more`7879  Dimensions to break each time bucket out by. Defaults to no grouping (one total per bucket). Each bucket reports at most its top 100 groups; a group beyond that cap has no row in that bucket (there is no remainder row), so grouped buckets are not exhaustive when a dimension has more than 100 distinct values.8081  maxItems: 1008283  - `"claude_tag_category"`8485  - `"claude_tag_user_id"`8687  - `"context_window"`8889  - `"cost_type"`9091  - `"inference_geo"`9293  - `"model"`9495  - `"product"`9697  - `"rbac_group_id"`9899  - `"slack_channel_id"`100101  - `"speed"`102103  - `"token_type"`104105- `inference_geos: optional array of "global" or "not_available" or "us"`106107  Filter to specific inference regions. `not_available` matches rows where the region is unset. Use `group_by[]=inference_geo` to break out per-region values.108109  maxItems: 100110111  - `"global"`112113  - `"not_available"`114115  - `"us"`116117- `limit: optional number`118119  Maximum number of time buckets per page. Defaults and caps vary by `bucket_width` (`1d`: default 7, max 31; `1h`: default 24, max 168; `1m`: default 60, max 256).120121  minimum: 1122123- `models: optional array of string`124125  Models to include. Defaults to all models. Use `group_by[]=model` to break out per-model values.126127  maxItems: 100128129- `page: optional string`130131  Opaque cursor from a previous response's `next_page` field.132133- `products: optional array of "chat" or "claude-tag" or "claude_code" or 4 more`134135  Product surfaces to include. Defaults to all products. Use `group_by[]=product` to break out per-product values.136137  maxItems: 100138139  - `"chat"`140141  - `"claude-tag"`142143  - `"claude_code"`144145  - `"claude_design"`146147  - `"claude_in_chrome"`148149  - `"cowork"`150151  - `"office_agent"`152153- `rbac_group_ids: optional array of string`154155  Filter to usage attributed to specific RBAC groups. Accepts tagged RBAC group IDs (`rbac_group_...`) or bare group UUIDs. A row matches when the user belonged to any of the listed groups on the (UTC) day the usage occurred; usage with no group attribution never matches.156157  maxItems: 100158159- `slack_channel_ids: optional array of string`160161  Filter to usage originating from specific Slack channels. Use `group_by[]=slack_channel_id` to break out per-channel values.162163  maxItems: 100164165- `speeds: optional array of "fast" or "standard"`166167  Filter to fast or standard inference mode. Use `group_by[]=speed` to break out per-mode values.168169  maxItems: 100170171  - `"fast"`172173  - `"standard"`174175- `user_ids: optional array of string`176177  Filter to specific users by tagged user ID.178179  maxItems: 100180181### Returns182183- `BetaCostBucket object`184185  - `data: array of object`186187    Time buckets for this page, oldest first: one per `bucket_width` interval, including intervals with no data (their `results` list is empty). A page holds at most `limit` buckets.188189    - `ending_at: string`190191      End of the time bucket (exclusive) in RFC 3339 format.192193      format: date-time194195    - `results: array of object`196197      Rows for this time bucket. Empty when the bucket has no data; otherwise a single combined row when `group_by[]` is omitted, or one row per group (subject to the per-bucket group cap described on the `group_by[]` parameter).198199      - `amount: string`200201        Amount (post-discount, pre-credit) in fractional cents.202203      - `claude_tag_category: "dm" or "engaged" or "monitoring" or 2 more or null`204205        Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed Claude in a channel or thread), `proactive` (Claude responded without being addressed), `scheduled` (a scheduled routine ran), `monitoring` (Claude watching a channel it was asked to monitor), or `dm` (direct messages with Claude). Populated only when `claude_tag_category` is in `group_by[]`; null for usage that is not Claude Tag. Direct-message usage is billed to the individual user and is reported under that user's product, not under `claude-tag`. New categories may be added over time.206207        - `"dm"`208209        - `"engaged"`210211        - `"monitoring"`212213        - `"proactive"`214215        - `"scheduled"`216217      - `claude_tag_user_id: string or null`218219        Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude in Slack) usage is attributed to, not a claude.ai user ID. Populated only when `claude_tag_user_id` is in `group_by[]`; null for usage that is not Claude Tag and for Claude Tag usage that is not attributed to a single user (for example `monitoring`, and `proactive` usage Claude initiated), so per-user rows can sum to less than the Claude Tag total. Cannot be combined with `group_by[]=rbac_group_id` or the `rbac_group_ids[]` filter.220221      - `context_window: "0-200k" or "200k-1M" or null`222223        Context-window pricing tier of the usage or cost. Null unless `context_window` is in `group_by[]`; it can also be null on grouped rows with no context-window tier, such as code execution.224225        - `"0-200k"`226227        - `"200k-1M"`228229      - `cost_type: "code_execution" or "tokens" or "web_search" or null`230231        Cost component when `group_by[]=cost_type`; null otherwise (amount is the combined total).232233        - `"code_execution"`234235        - `"tokens"`236237        - `"web_search"`238239      - `currency: "USD"`240241        Currency code for the cost amount. Currently always `"USD"`.242243        default: USD244245      - `inference_geo: "global" or "us" or null`246247        Inference region of the usage or cost. Null unless `inference_geo` is in `group_by[]`; it can also be null on grouped rows where the region is not set (the rows that `inference_geos[]=not_available` matches).248249        - `"global"`250251        - `"us"`252253      - `list_amount: string`254255        List-price amount (pre-discount) in fractional cents.256257      - `model: string or null`258259        Model that produced the usage or cost, as a model name in the form the `models[]` filter accepts (for example, `claude-opus-5`). Null unless `model` is in `group_by[]`; it can also be null on grouped rows whose usage or cost is not attributed to a specific model, such as code execution.260261      - `product: string or null`262263        Product surface that produced the usage or cost. Null unless product is in `group_by[]`; it can also be null on grouped rows whose usage cannot be attributed to a known surface. Values include `chat`, `claude_code`, `cowork`, `office_agent`, `claude_in_chrome`, `claude_design`, and `claude-tag`. `claude-tag` is Claude Tag, the Claude product in Slack. Some unattributed usage is reported as "other".264265      - `rbac_group_id: string or null`266267        RBAC group (team) the usage is attributed to, in the public tagged `rbac_group_...` spelling — the same spelling the activity resources use for this key, so the same team has one id across resources and it round-trips as an `rbac_group_ids[]` filter value. Populated only when `rbac_group_id` is in `group_by[]`. Any-membership semantics: a user in several groups contributes their full usage to each of those groups' rows, so the named-group rows overlap and their sum can exceed the org total. A null value is the single unassigned row: users in no group on that (UTC) day. For the true org total, run the same query without `group_by[]`.268269      - `requests: number or null`270271        Number of API requests in this row's scope. Null when `group_by` includes `cost_type` or `token_type` (the count has no per-component attribution; read it from the ungrouped response). For sandbox / code-execution events, this counts execution spans rather than HTTP requests (these rows surface with `product: null`).272273      - `slack_channel_id: string or null`274275        Slack channel the usage originated from. Populated only when `slack_channel_id` is in `group_by[]`; null for usage outside Slack (and for rows recorded before channel attribution was enabled).276277      - `speed: "fast" or "standard" or null`278279        Inference speed mode of the usage or cost: `fast` or `standard`. Null unless `speed` is in `group_by[]`.280281        - `"fast"`282283        - `"standard"`284285      - `token_type: "cache_creation.ephemeral_1h_input_tokens" or "cache_creation.ephemeral_5m_input_tokens" or "cache_read_input_tokens" or 2 more or null`286287        Token type when `group_by[]=token_type` and `cost_type=tokens`; null otherwise.288289        - `"cache_creation.ephemeral_1h_input_tokens"`290291        - `"cache_creation.ephemeral_5m_input_tokens"`292293        - `"cache_read_input_tokens"`294295        - `"output_tokens"`296297        - `"uncached_input_tokens"`298299    - `starting_at: string`300301      Start of the time bucket (inclusive) in RFC 3339 format.302303      format: date-time304305  - `data_refreshed_at: string or null`306307    RFC 3339 timestamp of the export this response was served from. Null when no export yet covers any part of the requested range, in which case every bucket's `results` list is empty. Buckets beyond this watermark are incomplete; for stable results, set `ending_at` to this value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days after the usage date (late-arriving events, reconciliation adjustments).308309    format: date-time310311  - `has_more: boolean`312313    Whether another page is available. When true, pass `next_page` as the `page` parameter to fetch it.314315  - `next_page: string or null`316317    Opaque cursor for the next page, or null when `has_more` is false. Pass it as the `page` parameter, keeping the other parameters unchanged. A cursor can expire after the underlying data refreshes; the request then returns HTTP 410 and pagination must restart from the first page.318319  - `organization_id: string`320321    ID of the Organization.322323### Example324325```bash326curl https://api.anthropic.com/v1/organizations/analytics/cost_report \327    -H 'anthropic-version: 2023-06-01' \328    -H "X-Api-Key: $ANTHROPIC_API_KEY"329```330331#### Response (200)332333```json334{335  "data": [336    {337      "ending_at": "2019-12-27T18:11:19.117Z",338      "results": [339        {340          "amount": "amount",341          "claude_tag_category": "dm",342          "claude_tag_user_id": "U0123ABCDEF",343          "context_window": "0-200k",344          "cost_type": "code_execution",345          "currency": "USD",346          "inference_geo": "global",347          "list_amount": "list_amount",348          "model": "claude-opus-5",349          "product": "chat",350          "rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",351          "requests": 0,352          "slack_channel_id": "C0123ABCDEF",353          "speed": "fast",354          "token_type": "cache_creation.ephemeral_1h_input_tokens"355        }356      ],357      "starting_at": "2019-12-27T18:11:19.117Z"358    }359  ],360  "data_refreshed_at": "2019-12-27T18:11:19.117Z",361  "has_more": true,362  "next_page": "next_page",363  "organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"364}365```366367## Get Per-User Cost368369**GET** `/v1/organizations/analytics/user_cost_report`370371Get per-user cost in USD across a date range.372373Returns one row per user, ranked by spend. Use this to see which users374account for the most cost. Only cost attributable to a seat user is375included; for organization-wide totals including direct API-key and376automation traffic, use the bucketed377`/v1/organizations/analytics/cost_report` endpoint. Available to378organizations on a Claude Enterprise plan. Requires an API key with the379`read:analytics` scope.380381### Query parameters382383- `starting_at: string`384385  Start of range, inclusive. RFC 3339 tz-aware. Must be within the last 365 days and no earlier than 2026-01-01T00:00:00Z.386387  format: date-time388389- `bucket_width: optional "1d" or "1h" or "1m"`390391  Time-bucket granularity. When set, each row's `starting_at` and `ending_at` are populated and one actor may span several rows (one per time bucket with usage). The time bucket counts toward `limit`, so one page can return multiple rows for the same actor. `ending_at` is required when `bucket_width` is set, and with `bucket_width="1m"` the range may span at most 24 hours. When omitted, each row aggregates the full `[starting_at, ending_at)` range.392393  - `"1d"`394395  - `"1h"`396397  - `"1m"`398399- `claude_tag_categories: optional array of "dm" or "engaged" or "monitoring" or 2 more`400401  Filter to Claude Tag (Claude in Slack) usage in specific spend categories. Usage with no category never matches. `dm` usage is reported under the user's product rather than `claude-tag`, so combining this filter with `products[]=claude-tag` excludes it. Use `group_by[]=claude_tag_category` to break out per-category values.402403  maxItems: 100404405  - `"dm"`406407  - `"engaged"`408409  - `"monitoring"`410411  - `"proactive"`412413  - `"scheduled"`414415- `claude_tag_user_ids: optional array of string`416417  Filter to Claude Tag (Claude in Slack) usage attributed to specific Slack users, by Slack user ID (for example `U0123ABCDEF`), not claude.ai user ID. Usage that is not Claude Tag, and Claude Tag usage not attributed to a single user, never matches. Use `group_by[]=claude_tag_user_id` to break out per-user values.418419  maxItems: 100420421- `context_windows: optional array of "0-200k" or "200k-1M"`422423  Filter to specific context-window pricing tiers. Use `group_by[]=context_window` to break out per-tier values.424425  maxItems: 100426427  - `"0-200k"`428429  - `"200k-1M"`430431- `ending_at: optional string`432433  End of range, exclusive. When omitted, defaults to the earlier of now and `starting_at` + 31 days. The range may span at most 31 days.434435  format: date-time436437- `exclude_deleted_users: optional boolean`438439  If true, omit rows for users who are deleted (`deleted: true`). A page may contain fewer than `limit` rows; use `has_more` and `next_page` to paginate as usual.440441  default: false442443- `group_by: optional array of "claude_tag_category" or "claude_tag_user_id" or "context_window" or 8 more`444445  Break each actor's row out by the given dimensions. Accepts the same values as the bucketed `/cost_report` endpoint. The `product`, `model`, `context_window`, `inference_geo`, and `speed` dimensions — and the time bucket, when `bucket_width` is set — count toward `limit`. `cost_type` and `token_type` do not: `cost_type` returns one row per cost component (tokens, web search, code execution); `token_type` returns one row per token type, each with `cost_type: "tokens"`; combining both returns the per-token-type rows plus the web-search and code-execution rows. A page can therefore contain more rows than `limit` when `cost_type` or `token_type` is requested.446447  maxItems: 100448449  - `"claude_tag_category"`450451  - `"claude_tag_user_id"`452453  - `"context_window"`454455  - `"cost_type"`456457  - `"inference_geo"`458459  - `"model"`460461  - `"product"`462463  - `"rbac_group_id"`464465  - `"slack_channel_id"`466467  - `"speed"`468469  - `"token_type"`470471- `inference_geos: optional array of "global" or "not_available" or "us"`472473  Filter to specific inference regions. `not_available` matches rows where the region is unset. Use `group_by[]=inference_geo` to break out per-region values.474475  maxItems: 100476477  - `"global"`478479  - `"not_available"`480481  - `"us"`482483- `limit: optional number`484485  Number of rows per page (1-1000, default 20). One row per actor unless `group_by[]` or `bucket_width` splits an actor across rows; `cost_type`/`token_type` fan-out rows (cost endpoint only) are the exception — they do not count toward this limit, so `data` can exceed it.486487  default: 20, maximum: 1000, minimum: 1488489- `models: optional array of string`490491  Models to include. Defaults to all models. Use `group_by[]=model` to break out per-model values.492493  maxItems: 100494495- `order: optional "asc" or "desc"`496497  Sort direction. Defaults to `desc`.498499  default: desc500501  - `"asc"`502503  - `"desc"`504505- `order_by: optional "amount" or "list_amount"`506507  Metric to rank actors by. Defaults to `amount`.508509  default: amount510511  - `"amount"`512513  - `"list_amount"`514515- `page: optional string`516517  Opaque cursor from a previous response's `next_page` field.518519- `products: optional array of "chat" or "claude-tag" or "claude_code" or 4 more`520521  Product surfaces to include. Defaults to all products.522523  maxItems: 100524525  - `"chat"`526527  - `"claude-tag"`528529  - `"claude_code"`530531  - `"claude_design"`532533  - `"claude_in_chrome"`534535  - `"cowork"`536537  - `"office_agent"`538539- `rbac_group_ids: optional array of string`540541  Filter to usage attributed to specific RBAC groups. Accepts tagged RBAC group IDs (`rbac_group_...`) or bare group UUIDs. A row matches when the user belonged to any of the listed groups on the (UTC) day the usage occurred; usage with no group attribution never matches.542543  maxItems: 100544545- `slack_channel_ids: optional array of string`546547  Filter to usage originating from specific Slack channels. Use `group_by[]=slack_channel_id` to break out per-channel values.548549  maxItems: 100550551- `speeds: optional array of "fast" or "standard"`552553  Filter to fast or standard inference mode. Use `group_by[]=speed` to break out per-mode values.554555  maxItems: 100556557  - `"fast"`558559  - `"standard"`560561- `user_ids: optional array of string`562563  Filter to specific users by tagged user ID.564565  maxItems: 100566567### Returns568569- `BetaUserCost object`570571  - `data: array of object`572573    Rows for this page, ranked by `order_by` in the `order` direction. One row per user, or several per user when `group_by[]` or `bucket_width` breaks that user's usage or cost out across rows. Rows split out by `cost_type` or `token_type` (cost endpoint only) stay adjacent and are ranked as one unit.574575    - `actor: BetaAnalyticsUserActor`576577      The user this row's usage or cost is attributed to. Always a `user_actor`.578579      - `type: "user_actor"`580581        Actor type. Always `"user_actor"`.582583      - `deleted: boolean`584585        True when the account has been deleted, or when the user is no longer a member of the organization or its associated organizations (for example, their membership was removed or they were deprovisioned via your identity provider). `email` stays populated for removed users and is null when the account has been deleted. `name` follows the rules described on that field. The `user_id` is still populated for reconciliation.586587      - `email: string or null`588589        The user's email address, including for users who are no longer members of the organization or its associated organizations. Null when the account has been deleted (check `deleted`) and for system-minted service accounts, which have no person's mailbox behind them (check `name`).590591      - `name: string or null`592593        The user's full name. Null when the user has not set a name. Returns `"Deleted User"` when the account itself has been deleted, or when the user is no longer a member of the organization or its associated organizations and the organization has chosen to hide the names of removed users. Otherwise, the name stays populated for removed users. Rows for system-minted service accounts render the service name (for example, `"Claude Security"` for usage by Anthropic's security-patching service) or null.594595      - `user_id: string`596597        Tagged user ID.598599    - `amount: string`600601      Amount (post-discount, pre-credit) in fractional cents (minor units).602603    - `claude_tag_category: "dm" or "engaged" or "monitoring" or 2 more or null`604605      Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed Claude in a channel or thread), `proactive` (Claude responded without being addressed), `scheduled` (a scheduled routine ran), `monitoring` (Claude watching a channel it was asked to monitor), or `dm` (direct messages with Claude). Populated only when `claude_tag_category` is in `group_by[]`; null for usage that is not Claude Tag. Direct-message usage is billed to the individual user and is reported under that user's product, not under `claude-tag`. New categories may be added over time.606607      - `"dm"`608609      - `"engaged"`610611      - `"monitoring"`612613      - `"proactive"`614615      - `"scheduled"`616617    - `claude_tag_user_id: string or null`618619      Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude in Slack) usage is attributed to, not a claude.ai user ID. Populated only when `claude_tag_user_id` is in `group_by[]`; null for usage that is not Claude Tag and for Claude Tag usage that is not attributed to a single user (for example `monitoring`, and `proactive` usage Claude initiated), so per-user rows can sum to less than the Claude Tag total. Cannot be combined with `group_by[]=rbac_group_id` or the `rbac_group_ids[]` filter.620621    - `context_window: "0-200k" or "200k-1M" or null`622623      Context-window pricing tier of the usage or cost. Null unless `context_window` is in `group_by[]`; it can also be null on grouped rows with no context-window tier, such as code execution.624625      - `"0-200k"`626627      - `"200k-1M"`628629    - `cost_type: "code_execution" or "tokens" or "web_search" or null`630631      Cost component breakdown; null when returning the combined total.632633      - `"code_execution"`634635      - `"tokens"`636637      - `"web_search"`638639    - `currency: "USD"`640641      Currency code for the cost amount. Currently always `"USD"`.642643      default: USD644645    - `ending_at: string or null`646647      End of the row's UTC time bucket (exclusive), as an RFC 3339 timestamp; equal to `starting_at` plus one `bucket_width`. Null unless `bucket_width` is set.648649      format: date-time650651    - `inference_geo: "global" or "us" or null`652653      Inference region of the usage or cost. Null unless `inference_geo` is in `group_by[]`; it can also be null on grouped rows where the region is not set (the rows that `inference_geos[]=not_available` matches).654655      - `"global"`656657      - `"us"`658659    - `list_amount: string`660661      List-price amount (pre-discount) in fractional cents.662663    - `model: string or null`664665      Model that produced the usage or cost, as a model name in the form the `models[]` filter accepts (for example, `claude-opus-5`). Null unless `model` is in `group_by[]`; it can also be null on grouped rows whose usage or cost is not attributed to a specific model, such as code execution.666667    - `product: string or null`668669      Product surface that produced the usage or cost. Null unless product is in `group_by[]`; it can also be null on grouped rows whose usage cannot be attributed to a known surface. Values include `chat`, `claude_code`, `cowork`, `office_agent`, `claude_in_chrome`, `claude_design`, and `claude-tag`. `claude-tag` is Claude Tag, the Claude product in Slack. Some unattributed usage is reported as "other".670671    - `rbac_group_id: string or null`672673      RBAC group (team) the usage is attributed to, in the public tagged `rbac_group_...` spelling — the same spelling the activity resources use for this key, so the same team has one id across resources and it round-trips as an `rbac_group_ids[]` filter value. Populated only when `rbac_group_id` is in `group_by[]`. Any-membership semantics: a user in several groups contributes their full usage to each of those groups' rows, so the named-group rows overlap and their sum can exceed the org total. A null value is the single unassigned row: users in no group on that (UTC) day. For the true org total, run the same query without `group_by[]`.674675    - `requests: number or null`676677      Number of API requests in this row's scope. Null when `group_by` includes `cost_type` or `token_type` (the count has no per-component attribution; read it from the ungrouped response). For sandbox / code-execution events, this counts execution spans rather than HTTP requests (these rows surface with `product: null`).678679    - `slack_channel_id: string or null`680681      Slack channel the usage originated from. Populated only when `slack_channel_id` is in `group_by[]`; null for usage outside Slack (and for rows recorded before channel attribution was enabled).682683    - `speed: "fast" or "standard" or null`684685      Inference speed mode of the usage or cost: `fast` or `standard`. Null unless `speed` is in `group_by[]`.686687      - `"fast"`688689      - `"standard"`690691    - `starting_at: string or null`692693      Start of the row's UTC time bucket (inclusive), as an RFC 3339 timestamp. Null unless `bucket_width` is set; without `bucket_width`, each row aggregates the full requested range.694695      format: date-time696697    - `token_type: "cache_creation.ephemeral_1h_input_tokens" or "cache_creation.ephemeral_5m_input_tokens" or "cache_read_input_tokens" or 2 more or null`698699      Token type when `cost_type` is `tokens`; null otherwise.700701      - `"cache_creation.ephemeral_1h_input_tokens"`702703      - `"cache_creation.ephemeral_5m_input_tokens"`704705      - `"cache_read_input_tokens"`706707      - `"output_tokens"`708709      - `"uncached_input_tokens"`710711  - `data_refreshed_at: string or null`712713    RFC 3339 timestamp of the export this response was served from. Null when no export yet covers any part of the requested range, in which case `data` is empty. Data beyond this watermark is incomplete; for stable results, set `ending_at` to this value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days after the usage date (late-arriving events, reconciliation adjustments).714715    format: date-time716717  - `has_more: boolean`718719    Whether another page is available. When true, pass `next_page` as the `page` parameter to fetch it.720721  - `next_page: string or null`722723    Opaque cursor for the next page, or null when `has_more` is false. Pass it as the `page` parameter, keeping the other parameters unchanged. A cursor can expire after the underlying data refreshes; the request then returns HTTP 410 and pagination must restart from the first page.724725  - `organization_id: string`726727    ID of the Organization.728729### Example730731```bash732curl https://api.anthropic.com/v1/organizations/analytics/user_cost_report \733    -H 'anthropic-version: 2023-06-01' \734    -H "X-Api-Key: $ANTHROPIC_API_KEY"735```736737#### Response (200)738739```json740{741  "data": [742    {743      "actor": {744        "deleted": true,745        "email": "jane@example.com",746        "name": "Jane Smith",747        "type": "user_actor",748        "user_id": "user_01AbCdEfGhIjKlMnOpQrSt"749      },750      "amount": "41280.000000",751      "claude_tag_category": "dm",752      "claude_tag_user_id": "U0123ABCDEF",753      "context_window": "0-200k",754      "cost_type": "code_execution",755      "currency": "USD",756      "ending_at": "2019-12-27T18:11:19.117Z",757      "inference_geo": "global",758      "list_amount": "51600.000000",759      "model": "claude-opus-5",760      "product": "chat",761      "rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",762      "requests": 128,763      "slack_channel_id": "C0123ABCDEF",764      "speed": "fast",765      "starting_at": "2019-12-27T18:11:19.117Z",766      "token_type": "cache_creation.ephemeral_1h_input_tokens"767    }768  ],769  "data_refreshed_at": "2019-12-27T18:11:19.117Z",770  "has_more": true,771  "next_page": "next_page",772  "organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"773}774```775776## Domain types777778### Beta Cost Bucket779780- `BetaCostBucket object`781782  - `data: array of object`783784    Time buckets for this page, oldest first: one per `bucket_width` interval, including intervals with no data (their `results` list is empty). A page holds at most `limit` buckets.785786    - `ending_at: string`787788      End of the time bucket (exclusive) in RFC 3339 format.789790      format: date-time791792    - `results: array of object`793794      Rows for this time bucket. Empty when the bucket has no data; otherwise a single combined row when `group_by[]` is omitted, or one row per group (subject to the per-bucket group cap described on the `group_by[]` parameter).795796      - `amount: string`797798        Amount (post-discount, pre-credit) in fractional cents.799800      - `claude_tag_category: "dm" or "engaged" or "monitoring" or 2 more or null`801802        Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed Claude in a channel or thread), `proactive` (Claude responded without being addressed), `scheduled` (a scheduled routine ran), `monitoring` (Claude watching a channel it was asked to monitor), or `dm` (direct messages with Claude). Populated only when `claude_tag_category` is in `group_by[]`; null for usage that is not Claude Tag. Direct-message usage is billed to the individual user and is reported under that user's product, not under `claude-tag`. New categories may be added over time.803804        - `"dm"`805806        - `"engaged"`807808        - `"monitoring"`809810        - `"proactive"`811812        - `"scheduled"`813814      - `claude_tag_user_id: string or null`815816        Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude in Slack) usage is attributed to, not a claude.ai user ID. Populated only when `claude_tag_user_id` is in `group_by[]`; null for usage that is not Claude Tag and for Claude Tag usage that is not attributed to a single user (for example `monitoring`, and `proactive` usage Claude initiated), so per-user rows can sum to less than the Claude Tag total. Cannot be combined with `group_by[]=rbac_group_id` or the `rbac_group_ids[]` filter.817818      - `context_window: "0-200k" or "200k-1M" or null`819820        Context-window pricing tier of the usage or cost. Null unless `context_window` is in `group_by[]`; it can also be null on grouped rows with no context-window tier, such as code execution.821822        - `"0-200k"`823824        - `"200k-1M"`825826      - `cost_type: "code_execution" or "tokens" or "web_search" or null`827828        Cost component when `group_by[]=cost_type`; null otherwise (amount is the combined total).829830        - `"code_execution"`831832        - `"tokens"`833834        - `"web_search"`835836      - `currency: "USD"`837838        Currency code for the cost amount. Currently always `"USD"`.839840        default: USD841842      - `inference_geo: "global" or "us" or null`843844        Inference region of the usage or cost. Null unless `inference_geo` is in `group_by[]`; it can also be null on grouped rows where the region is not set (the rows that `inference_geos[]=not_available` matches).845846        - `"global"`847848        - `"us"`849850      - `list_amount: string`851852        List-price amount (pre-discount) in fractional cents.853854      - `model: string or null`855856        Model that produced the usage or cost, as a model name in the form the `models[]` filter accepts (for example, `claude-opus-5`). Null unless `model` is in `group_by[]`; it can also be null on grouped rows whose usage or cost is not attributed to a specific model, such as code execution.857858      - `product: string or null`859860        Product surface that produced the usage or cost. Null unless product is in `group_by[]`; it can also be null on grouped rows whose usage cannot be attributed to a known surface. Values include `chat`, `claude_code`, `cowork`, `office_agent`, `claude_in_chrome`, `claude_design`, and `claude-tag`. `claude-tag` is Claude Tag, the Claude product in Slack. Some unattributed usage is reported as "other".861862      - `rbac_group_id: string or null`863864        RBAC group (team) the usage is attributed to, in the public tagged `rbac_group_...` spelling — the same spelling the activity resources use for this key, so the same team has one id across resources and it round-trips as an `rbac_group_ids[]` filter value. Populated only when `rbac_group_id` is in `group_by[]`. Any-membership semantics: a user in several groups contributes their full usage to each of those groups' rows, so the named-group rows overlap and their sum can exceed the org total. A null value is the single unassigned row: users in no group on that (UTC) day. For the true org total, run the same query without `group_by[]`.865866      - `requests: number or null`867868        Number of API requests in this row's scope. Null when `group_by` includes `cost_type` or `token_type` (the count has no per-component attribution; read it from the ungrouped response). For sandbox / code-execution events, this counts execution spans rather than HTTP requests (these rows surface with `product: null`).869870      - `slack_channel_id: string or null`871872        Slack channel the usage originated from. Populated only when `slack_channel_id` is in `group_by[]`; null for usage outside Slack (and for rows recorded before channel attribution was enabled).873874      - `speed: "fast" or "standard" or null`875876        Inference speed mode of the usage or cost: `fast` or `standard`. Null unless `speed` is in `group_by[]`.877878        - `"fast"`879880        - `"standard"`881882      - `token_type: "cache_creation.ephemeral_1h_input_tokens" or "cache_creation.ephemeral_5m_input_tokens" or "cache_read_input_tokens" or 2 more or null`883884        Token type when `group_by[]=token_type` and `cost_type=tokens`; null otherwise.885886        - `"cache_creation.ephemeral_1h_input_tokens"`887888        - `"cache_creation.ephemeral_5m_input_tokens"`889890        - `"cache_read_input_tokens"`891892        - `"output_tokens"`893894        - `"uncached_input_tokens"`895896    - `starting_at: string`897898      Start of the time bucket (inclusive) in RFC 3339 format.899900      format: date-time901902  - `data_refreshed_at: string or null`903904    RFC 3339 timestamp of the export this response was served from. Null when no export yet covers any part of the requested range, in which case every bucket's `results` list is empty. Buckets beyond this watermark are incomplete; for stable results, set `ending_at` to this value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days after the usage date (late-arriving events, reconciliation adjustments).905906    format: date-time907908  - `has_more: boolean`909910    Whether another page is available. When true, pass `next_page` as the `page` parameter to fetch it.911912  - `next_page: string or null`913914    Opaque cursor for the next page, or null when `has_more` is false. Pass it as the `page` parameter, keeping the other parameters unchanged. A cursor can expire after the underlying data refreshes; the request then returns HTTP 410 and pagination must restart from the first page.915916  - `organization_id: string`917918    ID of the Organization.919920### Beta User Cost921922- `BetaUserCost object`923924  - `data: array of object`925926    Rows for this page, ranked by `order_by` in the `order` direction. One row per user, or several per user when `group_by[]` or `bucket_width` breaks that user's usage or cost out across rows. Rows split out by `cost_type` or `token_type` (cost endpoint only) stay adjacent and are ranked as one unit.927928    - `actor: BetaAnalyticsUserActor`929930      The user this row's usage or cost is attributed to. Always a `user_actor`.931932      - `type: "user_actor"`933934        Actor type. Always `"user_actor"`.935936      - `deleted: boolean`937938        True when the account has been deleted, or when the user is no longer a member of the organization or its associated organizations (for example, their membership was removed or they were deprovisioned via your identity provider). `email` stays populated for removed users and is null when the account has been deleted. `name` follows the rules described on that field. The `user_id` is still populated for reconciliation.939940      - `email: string or null`941942        The user's email address, including for users who are no longer members of the organization or its associated organizations. Null when the account has been deleted (check `deleted`) and for system-minted service accounts, which have no person's mailbox behind them (check `name`).943944      - `name: string or null`945946        The user's full name. Null when the user has not set a name. Returns `"Deleted User"` when the account itself has been deleted, or when the user is no longer a member of the organization or its associated organizations and the organization has chosen to hide the names of removed users. Otherwise, the name stays populated for removed users. Rows for system-minted service accounts render the service name (for example, `"Claude Security"` for usage by Anthropic's security-patching service) or null.947948      - `user_id: string`949950        Tagged user ID.951952    - `amount: string`953954      Amount (post-discount, pre-credit) in fractional cents (minor units).955956    - `claude_tag_category: "dm" or "engaged" or "monitoring" or 2 more or null`957958      Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed Claude in a channel or thread), `proactive` (Claude responded without being addressed), `scheduled` (a scheduled routine ran), `monitoring` (Claude watching a channel it was asked to monitor), or `dm` (direct messages with Claude). Populated only when `claude_tag_category` is in `group_by[]`; null for usage that is not Claude Tag. Direct-message usage is billed to the individual user and is reported under that user's product, not under `claude-tag`. New categories may be added over time.959960      - `"dm"`961962      - `"engaged"`963964      - `"monitoring"`965966      - `"proactive"`967968      - `"scheduled"`969970    - `claude_tag_user_id: string or null`971972      Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude in Slack) usage is attributed to, not a claude.ai user ID. Populated only when `claude_tag_user_id` is in `group_by[]`; null for usage that is not Claude Tag and for Claude Tag usage that is not attributed to a single user (for example `monitoring`, and `proactive` usage Claude initiated), so per-user rows can sum to less than the Claude Tag total. Cannot be combined with `group_by[]=rbac_group_id` or the `rbac_group_ids[]` filter.973974    - `context_window: "0-200k" or "200k-1M" or null`975976      Context-window pricing tier of the usage or cost. Null unless `context_window` is in `group_by[]`; it can also be null on grouped rows with no context-window tier, such as code execution.977978      - `"0-200k"`979980      - `"200k-1M"`981982    - `cost_type: "code_execution" or "tokens" or "web_search" or null`983984      Cost component breakdown; null when returning the combined total.985986      - `"code_execution"`987988      - `"tokens"`989990      - `"web_search"`991992    - `currency: "USD"`993994      Currency code for the cost amount. Currently always `"USD"`.995996      default: USD997998    - `ending_at: string or null`9991000      End of the row's UTC time bucket (exclusive), as an RFC 3339 timestamp; equal to `starting_at` plus one `bucket_width`. Null unless `bucket_width` is set.10011002      format: date-time10031004    - `inference_geo: "global" or "us" or null`10051006      Inference region of the usage or cost. Null unless `inference_geo` is in `group_by[]`; it can also be null on grouped rows where the region is not set (the rows that `inference_geos[]=not_available` matches).10071008      - `"global"`10091010      - `"us"`10111012    - `list_amount: string`10131014      List-price amount (pre-discount) in fractional cents.10151016    - `model: string or null`10171018      Model that produced the usage or cost, as a model name in the form the `models[]` filter accepts (for example, `claude-opus-5`). Null unless `model` is in `group_by[]`; it can also be null on grouped rows whose usage or cost is not attributed to a specific model, such as code execution.10191020    - `product: string or null`10211022      Product surface that produced the usage or cost. Null unless product is in `group_by[]`; it can also be null on grouped rows whose usage cannot be attributed to a known surface. Values include `chat`, `claude_code`, `cowork`, `office_agent`, `claude_in_chrome`, `claude_design`, and `claude-tag`. `claude-tag` is Claude Tag, the Claude product in Slack. Some unattributed usage is reported as "other".10231024    - `rbac_group_id: string or null`10251026      RBAC group (team) the usage is attributed to, in the public tagged `rbac_group_...` spelling — the same spelling the activity resources use for this key, so the same team has one id across resources and it round-trips as an `rbac_group_ids[]` filter value. Populated only when `rbac_group_id` is in `group_by[]`. Any-membership semantics: a user in several groups contributes their full usage to each of those groups' rows, so the named-group rows overlap and their sum can exceed the org total. A null value is the single unassigned row: users in no group on that (UTC) day. For the true org total, run the same query without `group_by[]`.10271028    - `requests: number or null`10291030      Number of API requests in this row's scope. Null when `group_by` includes `cost_type` or `token_type` (the count has no per-component attribution; read it from the ungrouped response). For sandbox / code-execution events, this counts execution spans rather than HTTP requests (these rows surface with `product: null`).10311032    - `slack_channel_id: string or null`10331034      Slack channel the usage originated from. Populated only when `slack_channel_id` is in `group_by[]`; null for usage outside Slack (and for rows recorded before channel attribution was enabled).10351036    - `speed: "fast" or "standard" or null`10371038      Inference speed mode of the usage or cost: `fast` or `standard`. Null unless `speed` is in `group_by[]`.10391040      - `"fast"`10411042      - `"standard"`10431044    - `starting_at: string or null`10451046      Start of the row's UTC time bucket (inclusive), as an RFC 3339 timestamp. Null unless `bucket_width` is set; without `bucket_width`, each row aggregates the full requested range.10471048      format: date-time10491050    - `token_type: "cache_creation.ephemeral_1h_input_tokens" or "cache_creation.ephemeral_5m_input_tokens" or "cache_read_input_tokens" or 2 more or null`10511052      Token type when `cost_type` is `tokens`; null otherwise.10531054      - `"cache_creation.ephemeral_1h_input_tokens"`10551056      - `"cache_creation.ephemeral_5m_input_tokens"`10571058      - `"cache_read_input_tokens"`10591060      - `"output_tokens"`10611062      - `"uncached_input_tokens"`10631064  - `data_refreshed_at: string or null`10651066    RFC 3339 timestamp of the export this response was served from. Null when no export yet covers any part of the requested range, in which case `data` is empty. Data beyond this watermark is incomplete; for stable results, set `ending_at` to this value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days after the usage date (late-arriving events, reconciliation adjustments).10671068    format: date-time10691070  - `has_more: boolean`10711072    Whether another page is available. When true, pass `next_page` as the `page` parameter to fetch it.10731074  - `next_page: string or null`10751076    Opaque cursor for the next page, or null when `has_more` is false. Pass it as the `page` parameter, keeping the other parameters unchanged. A cursor can expire after the underlying data refreshes; the request then returns HTTP 410 and pagination must restart from the first page.10771078  - `organization_id: string`10791080    ID of the Organization.1081
Files main
Menu

Theme