SPB Git

Repository Public

get-cost-report.md 6.8 KB 294 lines markdown

1---2title: Get Cost Report3url: https://platform.claude.com/docs/en/api/beta/organization/cost_report/retrieve4---56# Get Cost Report78**GET** `/v1/organizations/cost_report`910Get Cost Report1112## Query parameters1314- `starting_at: string`1516  Time buckets that start on or after this RFC 3339 timestamp will be returned.17  Each time bucket will be snapped to the start of the minute/hour/day in UTC.1819  format: date-time2021- `bucket_width: optional "1d"`2223  Time granularity of the response data.2425  default: 1d2627- `ending_at: optional string`2829  Time buckets that end before this RFC 3339 timestamp will be returned.3031  format: date-time3233- `group_by: optional array of "description" or "workspace_id"`3435  Group by any subset of the available options.3637  - `"description"`3839  - `"workspace_id"`4041- `limit: optional number`4243  Maximum number of time buckets to return in the response.4445  default: 7, maximum: 31, minimum: 14647- `page: optional string`4849  Optionally set to the `next_page` token from the previous response.5051## Headers5253- `"anthropic-beta": optional array of AnthropicBeta`5455  Optional header to specify the beta version(s) you want to use.5657  - `string`5859  - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`6061    - `"message-batches-2024-09-24"`6263    - `"prompt-caching-2024-07-31"`6465    - `"computer-use-2024-10-22"`6667    - `"computer-use-2025-01-24"`6869    - `"pdfs-2024-09-25"`7071    - `"token-counting-2024-11-01"`7273    - `"token-efficient-tools-2025-02-19"`7475    - `"output-128k-2025-02-19"`7677    - `"files-api-2025-04-14"`7879    - `"mcp-client-2025-04-04"`8081    - `"mcp-client-2025-11-20"`8283    - `"dev-full-thinking-2025-05-14"`8485    - `"interleaved-thinking-2025-05-14"`8687    - `"code-execution-2025-05-22"`8889    - `"extended-cache-ttl-2025-04-11"`9091    - `"context-1m-2025-08-07"`9293    - `"context-management-2025-06-27"`9495    - `"model-context-window-exceeded-2025-08-26"`9697    - `"skills-2025-10-02"`9899    - `"fast-mode-2026-02-01"`100101    - `"output-300k-2026-03-24"`102103    - `"user-profiles-2026-03-24"`104105    - `"user-profiles-2026-08-18"`106107    - `"user-profiles-2026-09-04"`108109    - `"advisor-tool-2026-03-01"`110111    - `"managed-agents-2026-04-01"`112113    - `"cache-diagnosis-2026-04-07"`114115    - `"dreaming-2026-04-21"`116117    - `"thinking-token-count-2026-05-13"`118119    - `"server-side-fallback-2026-06-01"`120121    - `"server-side-fallback-2026-07-01"`122123    - `"fallback-credit-2026-06-01"`124125    - `"fallback-credit-2026-07-01"`126127    - `"agent-memory-2026-07-22"`128129    - `"mid-conversation-tool-changes-2026-07-01"`130131    - `"compact-2026-01-12"`132133    - `"computer-use-2025-11-24"`134135    - `"mcp-tunnels-2026-06-22"`136137    - `"structured-outputs-2025-11-13"`138139    - `"task-budgets-2026-03-13"`140141    - `"thinking-display-updates-2026-08-18"`142143    - `"ce-user-management-2026-07-13"`144145    - `"mid-conversation-output-config-2026-07-01"`146147    - `"thinking-binding-controls-2026-08-01"`148149    - `"mid-conversation-system-clear-at-2026-08-21"`150151    - `"compact-2026-09-04"`152153## Returns154155- `BetaCostReport object`156157  - `data: array of object`158159    List of time buckets for this page, oldest first: one per `bucket_width` interval, including intervals with no costs (their `results` list is empty). A page holds at most `limit` buckets.160161    - `ending_at: string`162163      End of the time bucket (exclusive) in RFC 3339 format.164165      format: date-time166167    - `results: array of object`168169      List of cost items for this time bucket. There may be multiple items if one or more `group_by[]` parameters are specified.170171      - `amount: string`172173        Cost amount in lowest currency units (e.g. cents) as a decimal string. For example, `"123.45"` in `"USD"` represents `$1.23`.174175      - `context_window: "0-200k" or "200k-1M" or null`176177        Input context window used. `null` if not grouping by description or for non-token costs.178179        - `"0-200k"`180181        - `"200k-1M"`182183      - `cost_type: "code_execution" or "session_usage" or "tokens" or "web_search" or null`184185        Type of cost. `null` if not grouping by description.186187        - `"code_execution"`188189        - `"session_usage"`190191        - `"tokens"`192193        - `"web_search"`194195      - `currency: string`196197        Currency code for the cost amount. Currently always `"USD"`.198199      - `description: string or null`200201        Description of the cost item. `null` if not grouping by description.202203      - `inference_geo: "global" or "not_available" or "us" or null`204205        Inference geo used matching requests' `inference_geo` parameter if set, otherwise the workspace's `default_inference_geo`.206        For models that do not support specifying `inference_geo` the value is `"not_available"`. Always `null` if not grouping by inference geo.207208        - `"global"`209210        - `"not_available"`211212        - `"us"`213214      - `model: string or null`215216        Model name used. `null` if not grouping by description or for non-token costs.217218      - `service_tier: "batch" or "standard" or null`219220        Service tier used. `null` if not grouping by description or for non-token costs.221222        - `"batch"`223224        - `"standard"`225226      - `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`227228        Type of token. `null` if not grouping by description or for non-token costs.229230        - `"cache_creation.ephemeral_1h_input_tokens"`231232        - `"cache_creation.ephemeral_5m_input_tokens"`233234        - `"cache_read_input_tokens"`235236        - `"output_tokens"`237238        - `"uncached_input_tokens"`239240      - `workspace_id: string or null`241242        ID of the Workspace this cost is associated with. `null` if not grouping by workspace or for the default workspace.243244    - `starting_at: string`245246      Start of the time bucket (inclusive) in RFC 3339 format.247248      format: date-time249250  - `has_more: boolean`251252    Indicates if there are more results.253254  - `next_page: string or null`255256    Opaque cursor for the next page, or `null` when `has_more` is false. Pass it as the `page` parameter in the next request.257258## Example259260```bash261curl https://api.anthropic.com/v1/organizations/cost_report \262    -H 'anthropic-version: 2023-06-01' \263    -H "X-Api-Key: $ANTHROPIC_API_KEY"264```265266### Response (200)267268```json269{270  "data": [271    {272      "ending_at": "2025-08-02T00:00:00Z",273      "results": [274        {275          "amount": "123.78912",276          "context_window": "0-200k",277          "cost_type": "tokens",278          "currency": "USD",279          "description": "Claude Opus 5 Usage - Input Tokens",280          "inference_geo": "global",281          "model": "claude-opus-5",282          "service_tier": "standard",283          "token_type": "uncached_input_tokens",284          "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"285        }286      ],287      "starting_at": "2025-08-01T00:00:00Z"288    }289  ],290  "has_more": true,291  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="292}293```294
Files main
Menu

Theme