cost_reports
Creates, updates, deletes, gets or lists a cost_reports resource.
Overview
| Name | cost_reports |
| Type | Resource |
| Id | anthropic_admin.cost.cost_reports |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
ending_at | string | End of the time bucket (exclusive) in RFC 3339 format. |
results | array | List of cost items for this time bucket; multiple items when one or more `group_by[]` parameters are specified. |
starting_at | string | Start of the time bucket (inclusive) in RFC 3339 format. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | starting_at | ending_at, bucket_width, group_by[] | Get a cost report bucketed by day, optionally grouped by workspace_id and/or description. Costs are USD decimal strings in lowest currency units (cents). |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
starting_at | string | Time buckets that start on or after this RFC 3339 timestamp will be returned. Snapped to the start of the day in UTC. |
bucket_width | string | Time granularity of the response data. Only 1d is supported. |
ending_at | string | Time buckets that end before this RFC 3339 timestamp will be returned. |
group_by[] | array | Group by any subset of description and workspace_id. When grouping by description, responses include parsed fields like model and cost_type. |
SELECT examples
- list
Get a cost report bucketed by day, optionally grouped by workspace_id and/or description. Costs are USD decimal strings in lowest currency units (cents).
SELECT
ending_at,
results,
starting_at
FROM anthropic_admin.cost.cost_reports
WHERE starting_at = '{{ starting_at }}' -- required
AND ending_at = '{{ ending_at }}'
AND bucket_width = '{{ bucket_width }}'
AND "group_by[]" = '{{ group_by[] }}'
;