billing.costs.lines

The usage lines behind a bar, a group or a resource

POST /billing/api/cost-explorer/linesIAM billing:GetCostAndUsageRead

One line per (resource, usage type, unit price): quantity, unit, rate, amount, first and last metered. Pass `bucket` (the ISO start of a bar) with its `granularity` to see one bar.

Request syntax

POST /billing/api/cost-explorer/lines
{
  "start": "string",
  "end": "string",
  "filters": "array of json",
  "bucket": "string",
  "granularity": "enum",
  "limit": "number"
}

Request body

  • startRequired

    string

    First day of the window, YYYY-MM-DD, UTC, inclusive

    Constraints: /^\d{4}-\d{2}-\d{2}$/

  • endRequired

    string

    Last day of the window, YYYY-MM-DD, UTC, inclusive

    Constraints: /^\d{4}-\d{2}-\d{2}$/

  • filtersOptional

    array of json

    Narrow to rows matching every filter, at most 20, as in cost-explorer/query; default none

    Default: []

  • bucketOptional

    string

    Only the bar starting at this ISO 8601 instant (a `series` point’s start), one granularity wide; default the whole window

    Constraints: datetime

  • granularityOptional

    enum

    How wide `bucket` is: hour, day (default) or month; ignored without bucket

    One of: hour, day, month

    Default: "day"

  • limitOptional

    number

    At most this many lines, 1–2000 (default 200), largest amount first; `truncated` says when more exist

    Constraints: integer, 1-2000

    Default: 200

Response

200 with { from, to, total, capSaving, notCharged, lines, truncated }: total covers every matching line (not only those returned); each line has resourceLabel, resourceType, resourceId, service, usageType, skuCode, region, zone, unit, unitPrice, quantity, amount, capSaving, notCharged, monthlyCap, records, firstAt, lastAt, tags, projects, creator. 403 when filtering by provider without iam:UpdateOrganization.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow billing:GetCostAndUsage on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud billing costs lines --start example --end example

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_billing_costs_lines.