Class CostListParams

  • All Implemented Interfaces:
    com.anthropic.core.Params

    
    public final class CostListParams
     implements Params
                        

    Get cost in USD across a date range, broken out by dimension.

    Returns one row per combination of the requested group_by[] dimensions (and time bucket, when time_bucket_width is set) that has cost in the range, ranked by spend or ordered by time bucket; every combination is returned across pages. With no group_by[] and no time_bucket_width, a single row aggregates the whole range. Includes all cost, whether or not it is attributable to a seat user. Requires an API key with the read:analytics scope, or an Admin API key.

    • Constructor Detail

    • Method Detail

      • startingAt

         final OffsetDateTime startingAt()

        Start of range, inclusive. RFC 3339 tz-aware. Must be within the last 365 days and no earlier than 2026-01-01T00:00:00Z.

      • actorIds

         final Optional<List<String>> actorIds()

        Filter to usage attributed to specific identities, by tagged ID: a user_..., svac_... (service account), or apikey_... ID. An apikey_ entry matches only usage attributed to the key itself, not usage on that key attributed to a user or service account (use api_key_ids[] for every request a key authenticated). Federated identities have no tagged ID; select them with actor_types[]. Use group_by[]=actor to break out per-identity values.

      • agentIds

         final Optional<List<String>> agentIds()

        Filter to usage incurred by sessions of specific Claude Managed Agents agents. Use group_by[]=agent_id to break out per-agent values. Claude Platform organizations only.

      • apiKeyIds

         final Optional<List<String>> apiKeyIds()

        Filter to usage authenticated by specific API keys, by tagged API key ID (apikey_...), whichever identity the usage is attributed to. Include an empty entry (api_key_ids[]=) to also match usage that no API key authenticated. Use group_by[]=api_key_id to break out per-key values; usage without a key has a null api_key_id. Claude Platform organizations only.

      • claudeTagUserIds

         final Optional<List<String>> claudeTagUserIds()

        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.

      • deploymentIds

         final Optional<List<String>> deploymentIds()

        Filter to usage incurred by Claude Managed Agents sessions that specific deployments started. Use group_by[]=deployment_id to break out per-deployment values. Claude Platform organizations only.

      • endingAt

         final Optional<OffsetDateTime> endingAt()

        End of range, exclusive. Required when time_bucket_width is set. Without time_bucket_width, defaults to the earlier of now and starting_at + 31 days. The range may span at most 31 days.

      • environmentIds

         final Optional<List<String>> environmentIds()

        Filter to usage incurred by Claude Managed Agents sessions that ran in specific environments. Use group_by[]=environment_id to break out per-environment values. Claude Platform organizations only.

      • excludeDeletedUsers

         final Optional<Boolean> excludeDeletedUsers()

        If true, omit rows whose actor is a user_actor with deleted: true. Requires group_by[]=actor. Rows for other actor types, and rows whose actor is null, are always kept. A page may contain fewer than limit rows; use has_more and next_page to paginate as usual.

      • groupBy

         final Optional<List<BetaAnalyticsCostGroupBy>> groupBy()

        Dimensions to break cost out by (at most 5, not counting cost_type and token_type): one row per combination of their values with cost in the range (and per time bucket, when time_bucket_width is set), every combination returned across pages rather than a capped top set. cost_type and token_type do not count toward limit: cost_type returns one row per cost component (tokens, web search, code execution, and session_usage, Claude Managed Agents session time); 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, code-execution and session-usage rows. When omitted, a single row aggregates the whole range.

      • limit

         final Optional<Long> limit()

        Number of rows per page (1-1000, default 20). cost_type/token_type fan-out rows (cost endpoint only) do not count toward this limit, so data can exceed it.

      • models

         final Optional<List<String>> models()

        Models to include. Defaults to all models. Use group_by[]=model to break out per-model values.

      • orderBy

         final Optional<BetaAnalyticsCostOrderBy> orderBy()

        Row order. A metric ranks rows by that metric in the order direction. time orders rows by time bucket in the order direction (newest first by default) and, within a bucket, by amount, highest first. time takes effect only with time_bucket_width; without it, time is the same as amount. Defaults to amount.

      • organizationIds

         final Optional<List<String>> organizationIds()

        Filter a parent organization's report to specific child organizations, by organization UUID or org_ ID; an ID that is not one of its child organizations matches nothing. Requires an API key created at the parent organization level. Use group_by[]=organization_id to break out per-organization values.

      • page

         final Optional<String> page()

        Opaque cursor from a previous response's next_page field.

      • rbacGroupIds

         final Optional<List<String>> rbacGroupIds()

        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.

      • serviceTiers

         final Optional<List<BetaAnalyticsServiceTier>> serviceTiers()

        Filter to specific service tiers. Use group_by[]=service_tier to break out per-tier values. Claude Platform organizations only; matches nothing for a Claude Enterprise organization.

      • sessionIds

         final Optional<List<String>> sessionIds()

        Filter to usage incurred by specific Claude Managed Agents sessions, by tagged session ID (sesn_...). Use group_by[]=session_id to break out per-session values. Claude Platform organizations only.

      • slackChannelIds

         final Optional<List<String>> slackChannelIds()

        Filter to usage originating from specific Slack channels. Use group_by[]=slack_channel_id to break out per-channel values.

      • timeBucketWidth

         final Optional<BetaAnalyticsTimeBucketWidth> timeBucketWidth()

        Time-bucket granularity. When set, rows are returned per time bucket (one per bucket and dimension combination with usage) and each row's starting_at and ending_at are that bucket's bounds; the time bucket counts toward limit. ending_at is required when time_bucket_width is set, and with time_bucket_width="1m" the range may span at most 24 hours. When omitted, each row aggregates the requested range with starting_at and ending_at each rounded down to the hour.

      • userProfileIds

         final Optional<List<String>> userProfileIds()

        Filter to usage attributed to specific user profiles, by tagged user profile ID (uprof_...). Use group_by[]=user_profile_id to break out per-profile values. Claude Platform organizations only.

      • workspaceIds

         final Optional<List<String>> workspaceIds()

        Filter to usage in specific workspaces, by tagged workspace ID (wrkspc_...). Use group_by[]=workspace_id to break out per-workspace values. Claude Platform organizations only; matches nothing for a Claude Enterprise organization.

      • _headers

         Headers _headers()

        The full set of headers in the parameters, including both fixed and additional headers.

      • _queryParams

         QueryParams _queryParams()

        The full set of query params in the parameters, including both fixed and additional query params.

      • _spanData

         SpanData _spanData()

        The data for the OpenTelemetry span of a call to the method with these parameters.