> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.mixlayer.com/api-reference/platform-api/billing-accounts/get-open-invoices-for-billing-account/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mixlayer.com/_mcp/server. # Get current draft invoice usage GET https://api.mixlayer.com/v1/billing_accounts/{billing_account_id}/usage/current When authenticated with an API key, this operation requires `api-read`. Reference: https://docs.mixlayer.com/api-reference/platform-api/billing-accounts/get-open-invoices-for-billing-account ## Authentication - `Authorization` header (bearer token, required) — Console user session or Mixlayer API key supplied as a Bearer token. ## Request ### Path parameters - `billing_account_id` (string, required) — Billing account ID ## Response ### 200 Current draft invoices - `data` (list of ApiDataResponseVecSimpleInvoiceDataItems, required) — Response payload. ## Errors ### 401 Unauthorized Error Authentication is missing or invalid. - `error` (ApiErrorBody, required) — Structured error details. ### 403 Forbidden Error The authenticated principal cannot perform this operation. - `error` (ApiErrorBody, required) — Structured error details. ### 404 Not Found Error Billing account not found - `error` (ApiErrorBody, required) — Structured error details. ### 500 Internal Server Error An unexpected server or database error occurred. - `error` (ApiErrorBody, required) — Structured error details. ## Types ### ApiDataResponseVecSimpleInvoiceDataItems Current draft invoice with charges grouped by model. - `end_date` (string, required) — Last date covered by the invoice, formatted as `YYYY-MM-DD`. - `line_item_groups` (list of SimpleInvoiceLineItemGroup, required) — Invoice line items grouped by model. - `start_date` (string, required) — First date covered by the invoice, formatted as `YYYY-MM-DD`. - `subtotal_cents` (double, required) — Usage charges before credits, in cents. - `total_amount_cents` (double, required) — Net invoice total after credits, in cents. - `total_applied_credits_cents` (double, required) — Credits applied to the invoice, represented as a negative cent amount. ### ApiErrorBody Structured error details returned by the platform API. - `message` (string, required) — Human-readable error message. - `code` (string, optional, nullable) — Stable machine-readable error code, when available. - `details` (any, optional) — Error-specific structured context, when available. ### SimpleInvoiceLineItemGroup Invoice line items for one model. - `line_items` (list of SimpleInvoiceLineItem, required) — Charges and credits in the group. - `total_cents` (double, required) — Net group total in cents. - `model` (string, optional, nullable) — Model SKU, or null for charges not attributed to a model. ### SimpleInvoiceLineItem One usage charge or credit on an invoice. - `credit_applied_cents` (double, required) — Credit applied by this line, in cents. - `description` (string, required) — Human-readable line item name. - `quantity` (double, required) — Billed usage quantity. - `total_price_cents` (double, required) — Line total in cents. - `unit_price_cents` (double, required) — Unit price in cents. ## Examples **Response** ```json { "data": [ { "end_date": "string", "line_item_groups": [ { "line_items": [ { "credit_applied_cents": 1.1, "description": "string", "quantity": 1.1, "total_price_cents": 1.1, "unit_price_cents": 1.1 } ], "total_cents": 1.1, "model": "string" } ], "start_date": "string", "subtotal_cents": 1.1, "total_amount_cents": 1.1, "total_applied_credits_cents": 1.1 } ] } ``` **SDK Code** ```python import requests url = "https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current") .header("Authorization", "Bearer ") .asString(); ``` ```php request('GET', 'https://api.mixlayer.com/v1/billing_accounts/billing_account_id/usage/current', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ```