basePath: /v1beta1
definitions:
  billing_errors.BaseError:
    properties:
      code:
        type: string
      error: {}
      msgPrefix:
        type: string
      status:
        type: integer
    type: object
  forms.BillsCostExplorer:
    properties:
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      elements:
        items:
          $ref: '#/definitions/forms.BillsCostExplorerElements'
        type: array
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsCostExplorerBreakdown:
    properties:
      billedDate:
        type: string
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      detailKey:
        type: string
      detailName:
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsCostExplorerElements:
    properties:
      billedDate:
        type: string
      breakdown:
        items:
          $ref: '#/definitions/forms.BillsCostExplorerBreakdown'
        type: array
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsDetail:
    properties:
      billedDate:
        description: The date when this bill happens.
        type: string
      clusterName:
        description: Name of the cluster.
        type: string
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      projectName:
        description: Name of the project.
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      servicePathName:
        description: Name of the service.
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsDetails:
    properties:
      details:
        items:
          $ref: '#/definitions/forms.BillsDetail'
        type: array
    type: object
  forms.BillsExplorer:
    properties:
      overview:
        allOf:
          - $ref: '#/definitions/forms.BillsOverview'
        description: The overall information for a bill in the specified organization.
      summaryByProject:
        allOf:
          - $ref: '#/definitions/forms.SummaryByProject'
        description: A breakdown of the bill by project.
      summaryByService:
        description: A breakdown of the bill by service.
        items:
          $ref: '#/definitions/forms.BillsServiceCosts'
        type: array
    type: object
  forms.BillsOtherName:
    properties:
      chargeName:
        example: Support Plan
        type: string
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsOverview:
    properties:
      billedMonth:
        description: The month in which this bill is generated for the specified organization.
        example: 2023-09
        type: string
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsProjects:
    properties:
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      projectName:
        description: The name of a project in the specified organization.
        example: prod-project
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.BillsServiceCosts:
    properties:
      credits:
        description: The total credits held by the organization in this bill. The
          value of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      discounts:
        description: The total amount of discounts applied to this bill. The value
          of this field is expressed in cents (100ths of one US Dollar).
        example: "0.00"
        type: string
      runningTotal:
        description: The sum of services that the specified organization has consumed
          during this bill period. The value of this field is expressed in cents (100ths
          of one US Dollar).
        example: "0.00"
        type: string
      serviceCosts:
        items:
          $ref: '#/definitions/forms.BillsServiceCosts'
        type: array
      serviceName:
        description: The name of services provided by TiDB Cloud.
        example: TiDB Dedicated
        type: string
      totalCost:
        description: |-
          The total amount that the specified organization should pay for this bill. The value of this field is expressed in cents (100ths of one US Dollar).
          `total_cost` = `running_total` - `discounts` - `credits`.
        example: "0.00"
        type: string
    type: object
  forms.ClusterOpenAPI:
    properties:
      ProjectID:
        example: "0"
        type: string
      id:
        example: "0"
        type: string
      name:
        type: string
      regionName:
        type: string
      status:
        type: string
    type: object
  forms.CostExplorerProvider:
    properties:
      name:
        description: Name of Cloud provider.
        type: string
      regions:
        description: Name of region.
        items:
          type: string
        type: array
    type: object
  forms.CostExplorerService:
    properties:
      category:
        description: 2nd level of service.
        type: string
      component:
        description: 3rd level of service.
        type: string
      product:
        description: 1st level of service.
        type: string
      service:
        type: string
    type: object
  forms.CostExplorerTrendsBreakdownKey:
    enum:
      - service
      - product
      - project
      - cluster
      - provider
      - region
    type: string
    x-enum-varnames:
      - CostExploreTrendsBreakdownKeyService
      - CostExploreTrendsBreakdownKeyProduct
      - CostExploreTrendsBreakdownKeyProject
      - CostExploreTrendsBreakdownKeyCluster
      - CostExploreTrendsBreakdownKeyProvider
      - CostExploreTrendsBreakdownKeyRegion
  forms.CostExplorerTrendsTimeGroup:
    enum:
      - day
      - month
      - total
    type: string
    x-enum-varnames:
      - CostExploreTrendsTimeGroupDay
      - CostExploreTrendsTimeGroupMonth
      - CostExploreTrendsTimeGroupTotal
  forms.Groups:
    properties:
      groupBy:
        description: |-
          Group cost explorer query results by category. The category includes:
           1. "service": Group query results by service type
           2. "product": Group query results by product type (TiDB Dedicated, TiDB Serverless, or Support Plan)
           3. "project": Group query results by Project IDs
           4. "cluster": Group query results by Cluster IDs
           5. "provider": Group query results by Cloud Provider
           6. "region": Group query results by cloud provider region
        items:
          $ref: '#/definitions/forms.CostExplorerTrendsBreakdownKey'
        type: array
      timeGranularity:
        allOf:
          - $ref: '#/definitions/forms.CostExplorerTrendsTimeGroup'
        description: |-
          Time Granularity determines how the cost explorer query results are organized: daily, monthly, or in total.
           1. "day": Query results are organized daily
           2. "month": Query results are organized monthly
           3. "total": Query results are organized in total
    type: object
  forms.ProjectOpenAPI:
    properties:
      id:
        example: "0"
        type: string
      name:
        type: string
      status:
        type: string
    type: object
  forms.Provider:
    properties:
      name:
        description: Name of the cloud provider
        type: string
      regions:
        description: Name of the region
        items:
          type: string
        type: array
    type: object
  forms.SummaryByProject:
    properties:
      otherCharges:
        description: These charges occur not only within a project but also across
          the entire organization.
        items:
          $ref: '#/definitions/forms.BillsOtherName'
        type: array
      projects:
        description: The projects in the specified organization.
        items:
          $ref: '#/definitions/forms.BillsProjects'
        type: array
    type: object
  forms.TimeRange:
    properties:
      endDate:
        description: End date of the time range.
        type: string
      startDate:
        description: Start date of the time range.
        type: string
    type: object
  forms.TrendsArgs:
    properties:
      clusters:
        items:
          $ref: '#/definitions/forms.ClusterOpenAPI'
        type: array
      projects:
        items:
          $ref: '#/definitions/forms.ProjectOpenAPI'
        type: array
      providers:
        items:
          $ref: '#/definitions/forms.Provider'
        type: array
      services:
        description: 'The Identifier of TiDB Cloud services consists of 3 levels.
          For example, "service": "TiDB Dedicated - Node Compute - TiFlash" consists
          of the following 3 levels.'
        items:
          $ref: '#/definitions/forms.CostExplorerService'
        type: array
    type: object
  forms.TrendsFilter:
    properties:
      clusters:
        items:
          type: string
        type: array
      projects:
        items:
          type: string
        type: array
      providers:
        items:
          $ref: '#/definitions/forms.CostExplorerProvider'
        type: array
      services:
        items:
          $ref: '#/definitions/forms.CostExplorerService'
        type: array
      timeRange:
        $ref: '#/definitions/forms.TimeRange'
    type: object
  forms.TrendsInput:
    properties:
      filter:
        $ref: '#/definitions/forms.TrendsFilter'
      groups:
        $ref: '#/definitions/forms.Groups'
    type: object
host: billing.tidbapi.com
info:
  contact: {}
  description: This is a billing system server
  title: Billing System OPENAPI
  version: v1beta1
paths:
  /bills/{billedMonth}:
    get:
      consumes:
        - application/json
      description: This endpoint retrieves the bill for the given month of a specific
        organization. You can query a bill up to 6 months prior to the current month.
        The bill is returned in JSON format. To use this resource, the requesting API
        Key must have the Organization Billing Admin or Organization Owner role.
      parameters:
        - description: The month of this bill happens for the specified organization. The format is `YYYY-MM`, for example '2024-05'.
          in: path
          name: billedMonth
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/forms.BillsExplorer'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/billing_errors.BaseError'
      summary: Return organization monthly bills
      tags:
        - Billing
  /billsCostExplorer:
    post:
      consumes:
        - application/json
      description: 'This endpoint executes a cost explorer query and returns the usage
        details. Cost Explorer query:'
      parameters:
        - description: args
          in: body
          name: args
          required: true
          schema:
            $ref: '#/definitions/forms.TrendsInput'
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/forms.BillsCostExplorer'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/billing_errors.BaseError'
      summary: Return the usage details according to a cost explorer query
      tags:
        - Billing
  /billsCostExplorer/args:
    get:
      consumes:
        - application/json
      description: This endpoint retrieves the basic info for a specific organization,
        including service info, cloud provider info, project info, and cluster info.
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/forms.TrendsArgs'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/billing_errors.BaseError'
      summary: Return basic info of a specific organization, which contains the key
        info to execute a cost explorer query
      tags:
        - Billing
  /billsDetails/{billedMonth}:
    get:
      consumes:
        - application/json
      description: This endpoint retrieves the bill for the given month of a specific
        organization with daily usage details. You can query a bill up to 6 months
        prior to the current month. The bill is returned in JSON format. To use this
        resource, the requesting API Key must have the Organization Billing Admin
        or Organization Owner role.
      parameters:
        - description: The month of this bill happens for the specified organization.
            The format is `YYYY-MM`, for example '2024-05'.
          in: path
          name: billedMonth
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/forms.BillsDetails'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/billing_errors.BaseError'
      summary: Return the monthly bill of the organization with daily usage details
      tags:
        - Billing
swagger: "2.0"