{
    "swagger": "2.0",
    "info": {
        "description": "This is a billing system server",
        "title": "Billing System OPENAPI",
        "contact": {},
        "version": "v1beta1"
    },
    "x-tagGroups": [
        {
            "name": "Endpoints",
            "tags": [
                "Billing"
            ]
        }
    ],
    "host": "billing.tidbapi.com",
    "basePath": "/v1beta1",
    "paths": {
        "/bills/{billedMonth}": {
            "get": {
                "x-code-samples": [
                    {
                        "lang": "curl",
                        "source": "curl --digest \\\n  --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n  --request GET \\\n  --url 'https://billing.tidbapi.com/v1beta1/bills/{billedMonth}'"
                    }
                ],
                "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.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return organization monthly bills",
                "parameters": [
                    {
                        "type": "string",
                        "description": "The month of this bill happens for the specified organization, format is YYYY-MM, for example '2023-08'.",
                        "name": "billedMonth",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsExplorer"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsCostExplorer": {
            "post": {
                "x-code-samples": [
                    {
                        "lang": "curl",
                        "source": "curl --digest \\\n  --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n  --request POST \\\n  --url 'https://billing.tidbapi.com/v1beta1/billsCostExplorer'"
                    }
                ],
                "description": "This endpoint executes a cost explorer query and returns the usage details. Cost Explorer query:",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return the usage details according to a cost explorer query",
                "parameters": [
                    {
                        "description": "args",
                        "name": "args",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/forms.TrendsInput"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsCostExplorer"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsCostExplorer/args": {
            "get": {
                "x-code-samples": [
                    {
                        "lang": "curl",
                        "source": "curl --digest \\\n  --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n  --request GET \\\n  --url 'https://billing.tidbapi.com/v1beta1/billsCostExplorer/args'"
                    }
                ],
                "description": "This endpoint retrieves the basic info for a specific organization, including service info, cloud provider info, project info, and cluster info.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return basic info of a specific organization, which contains the key info to execute a cost explorer query",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.TrendsArgs"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        },
        "/billsDetails/{billedMonth}": {
            "get": {
                "x-code-samples": [
                    {
                        "lang": "curl",
                        "source": "curl --digest \\\n  --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n  --request GET \\\n  --url 'https://billing.tidbapi.com/v1beta1/billsDetails/{billedMonth}'"
                    }
                ],
                "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.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Billing"
                ],
                "summary": "Return the monthly bill of the organization with daily usage details",
                "parameters": [
                    {
                        "type": "string",
                        "description": "The month of this bill happens for the specified organization. The format is `YYYY-MM`, for example '2024-05'.",
                        "name": "billedMonth",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/forms.BillsDetails"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/billing_errors.BaseError"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "billing_errors.BaseError": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string"
                },
                "error": {},
                "msgPrefix": {
                    "type": "string"
                },
                "status": {
                    "type": "integer"
                }
            }
        },
        "forms.BillsCostExplorer": {
            "type": "object",
            "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "elements": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsCostExplorerElements"
                    }
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsCostExplorerBreakdown": {
            "type": "object",
            "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsCostExplorerElements": {
            "type": "object",
            "properties": {
                "billedDate": {
                    "type": "string"
                },
                "breakdown": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsCostExplorerBreakdown"
                    }
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsDetail": {
            "type": "object",
            "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsDetails": {
            "type": "object",
            "properties": {
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsDetail"
                    }
                }
            }
        },
        "forms.BillsExplorer": {
            "type": "object",
            "properties": {
                "overview": {
                    "description": "The overall information for a bill in the specified organization.",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.BillsOverview"
                        }
                    ]
                },
                "summaryByProject": {
                    "description": "A breakdown of the bill by project.",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.SummaryByProject"
                        }
                    ]
                },
                "summaryByService": {
                    "description": "A breakdown of the bill by service.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsServiceCosts"
                    }
                }
            }
        },
        "forms.BillsOtherName": {
            "type": "object",
            "properties": {
                "chargeName": {
                    "type": "string",
                    "example": "Support Plan"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsOverview": {
            "type": "object",
            "properties": {
                "billedMonth": {
                    "description": "The month in which this bill is generated for the specified organization.",
                    "type": "string",
                    "example": "2023-09"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsProjects": {
            "type": "object",
            "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "projectName": {
                    "description": "The name of a project in the specified organization.",
                    "type": "string",
                    "example": "prod-project"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.BillsServiceCosts": {
            "type": "object",
            "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "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).",
                    "type": "string",
                    "example": "0.00"
                },
                "serviceCosts": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsServiceCosts"
                    }
                },
                "serviceName": {
                    "description": "The name of services provided by TiDB Cloud.",
                    "type": "string",
                    "example": "TiDB Dedicated"
                },
                "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).\n`total_cost` = `running_total` - `discounts` - `credits`.",
                    "type": "string",
                    "example": "0.00"
                }
            }
        },
        "forms.ClusterOpenAPI": {
            "type": "object",
            "properties": {
                "ProjectID": {
                    "type": "string",
                    "example": "0"
                },
                "id": {
                    "type": "string",
                    "example": "0"
                },
                "name": {
                    "type": "string"
                },
                "regionName": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                }
            }
        },
        "forms.CostExplorerProvider": {
            "type": "object",
            "properties": {
                "name": {
                    "description": "Name of Cloud provider.",
                    "type": "string"
                },
                "regions": {
                    "description": "Name of region.",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "forms.CostExplorerService": {
            "type": "object",
            "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"
                }
            }
        },
        "forms.CostExplorerTrendsBreakdownKey": {
            "type": "string",
            "enum": [
                "service",
                "product",
                "project",
                "cluster",
                "provider",
                "region"
            ],
            "x-enum-varnames": [
                "CostExploreTrendsBreakdownKeyService",
                "CostExploreTrendsBreakdownKeyProduct",
                "CostExploreTrendsBreakdownKeyProject",
                "CostExploreTrendsBreakdownKeyCluster",
                "CostExploreTrendsBreakdownKeyProvider",
                "CostExploreTrendsBreakdownKeyRegion"
            ]
        },
        "forms.CostExplorerTrendsTimeGroup": {
            "type": "string",
            "enum": [
                "day",
                "month",
                "total"
            ],
            "x-enum-varnames": [
                "CostExploreTrendsTimeGroupDay",
                "CostExploreTrendsTimeGroupMonth",
                "CostExploreTrendsTimeGroupTotal"
            ]
        },
        "forms.Groups": {
            "type": "object",
            "properties": {
                "groupBy": {
                    "description": "Group cost explorer query results by category. The category includes:\n 1. \"service\": Group query results by service type\n 2. \"product\": Group query results by product type (TiDB Dedicated, TiDB Cloud Starter, or TiDB Cloud Essential)\n 3. \"project\": Group query results by Project IDs\n 4. \"cluster\": Group query results by Cluster IDs\n 5. \"provider\": Group query results by Cloud Provider\n 6. \"region\": Group query results by cloud provider region",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerTrendsBreakdownKey"
                    }
                },
                "timeGranularity": {
                    "description": "Time Granularity determines how the cost explorer query results are organized daily, monthly, or in total.\n 1. \"day\": Query results are organized daily\n 2. \"month\": Query results are organized monthly\n 3. \"total\": Query results are organized in total",
                    "allOf": [
                        {
                            "$ref": "#/definitions/forms.CostExplorerTrendsTimeGroup"
                        }
                    ]
                }
            }
        },
        "forms.ProjectOpenAPI": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string",
                    "example": "0"
                },
                "name": {
                    "type": "string"
                },
                "status": {
                    "type": "string"
                }
            }
        },
        "forms.Provider": {
            "type": "object",
            "properties": {
                "name": {
                    "description": "Name of the cloud provider",
                    "type": "string"
                },
                "regions": {
                    "description": "Name of the region",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "forms.SummaryByProject": {
            "type": "object",
            "properties": {
                "otherCharges": {
                    "description": "These charges occur not only within a project but also across the entire organization.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsOtherName"
                    }
                },
                "projects": {
                    "description": "The projects in the specified organization.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.BillsProjects"
                    }
                }
            }
        },
        "forms.TimeRange": {
            "type": "object",
            "properties": {
                "endDate": {
                    "description": "End date of the time range.",
                    "type": "string"
                },
                "startDate": {
                    "description": "Start date of the time range.",
                    "type": "string"
                }
            }
        },
        "forms.TrendsArgs": {
            "type": "object",
            "properties": {
                "clusters": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.ClusterOpenAPI"
                    }
                },
                "projects": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.ProjectOpenAPI"
                    }
                },
                "providers": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.Provider"
                    }
                },
                "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.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerService"
                    }
                }
            }
        },
        "forms.TrendsFilter": {
            "type": "object",
            "properties": {
                "clusters": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "projects": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "providers": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerProvider"
                    }
                },
                "services": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/forms.CostExplorerService"
                    }
                },
                "timeRange": {
                    "$ref": "#/definitions/forms.TimeRange"
                }
            }
        },
        "forms.TrendsInput": {
            "type": "object",
            "properties": {
                "filter": {
                    "$ref": "#/definitions/forms.TrendsFilter"
                },
                "groups": {
                    "$ref": "#/definitions/forms.Groups"
                }
            }
        }
    }
}
