billing.cost-views.create

Save a cost explorer view

POST /billing/api/cost-viewsIAM billing:CreateCostViewChanges state

`state.range` is relative ({type: relative, preset: last-month | month-to-date | last-30-days | …}) so the view keeps its meaning, or fixed ({type: fixed, start, end}). `report: {enabled, recipients}` mails the view on the 2nd for the month before, with its CSV. Names are unique per organization (409).

Request syntax

POST /billing/api/cost-views
{
  "name": "string",
  "description": "string",
  "state": "object",
  "shared": "boolean",
  "report": "object"
}

Request body

  • nameRequired

    string

    1–100 characters, trimmed; unique in the organization (409 when taken)

    Constraints: 1-100 chars

  • descriptionOptional

    string

    Free text shown with the view, at most 500 characters; default none

    Constraints: max 500 chars

  • stateRequired

    object

    The explorer question: range (relative preset or fixed dates), granularity, groupBy, filters — the same shapes as cost-explorer/query. Grouping or filtering by provider needs iam:UpdateOrganization (403)

    Constraints: JSON

  • sharedOptional

    boolean

    true (default): visible to everyone with billing:GetCostAndUsage; false: only to its creator, and not found for everyone else

  • reportOptional

    object

    Mail this view monthly, on the 2nd, for the month before: {enabled, recipients (at most 20 addresses)}; default off

    Constraints: JSON

Response

201 with the new view as `list` shows it. 409 when the name is taken, or QuotaExceeded past the saved-view quota (100 standard, 20 trial); 403 when the state groups or filters 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:CreateCostView 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 cost-views create --name example --state '{}'

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