> 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/set-spend-controls-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. # Update billing spend controls PUT https://api.mixlayer.com/v1/billing_accounts/{billing_account_id}/spend_controls Content-Type: application/json When authenticated with an API key, this operation requires `api-admin`. Reference: https://docs.mixlayer.com/api-reference/platform-api/billing-accounts/set-spend-controls-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 ### Body (application/json) This endpoint expects a SetSpendControlsRequest. - `prepaid_low_balance_warning_threshold_cents` (long, required, nullable) — Low prepaid balance warning threshold in cents. Use null to disable this control. Non-null values must be positive and require a prepaid account. - `usage_spend_cutoff_threshold_cents` (long, required, nullable) — Usage spend cutoff threshold in cents. Use null to disable this control. Non-null values must be positive. - `usage_spend_warning_threshold_cents` (long, required, nullable) — Usage spend warning threshold in cents. Use null to disable this control. Non-null values must be positive and lower than the cutoff when both are set. ## Response ### 200 Updated billing spend controls - `data` (ApiDataResponseSpendControlsResponseData, required) — Spend controls configured for a billing account. ## Errors ### 400 Bad Request Error The request body contains malformed JSON or invalid values. - `error` (ApiErrorBody, required) — Structured error details. ### 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 The requested resource is not visible to the authenticated principal. - `error` (ApiErrorBody, required) — Structured error details. ### 409 Conflict Error The billing account state prevents the requested operation. - `error` (ApiErrorBody, required) — Structured error details. ### 413 Content Too Large Error The request body exceeds the configured size limit. - `error` (ApiErrorBody, required) — Structured error details. ### 415 Unsupported Media Type Error The request does not have a JSON content type. - `error` (ApiErrorBody, required) — Structured error details. ### 422 Unprocessable Entity Error The JSON body does not match the request schema or contains a rejected field value. - `error` (ApiErrorBody, required) — Structured error details. ### 500 Internal Server Error An unexpected server or database error occurred. - `error` (ApiErrorBody, required) — Structured error details. ## Types ### ApiDataResponseSpendControlsResponseData Spend controls configured for a billing account. - `billing_account_id` (string, required) — Billing account owning the controls. - `prepaid_low_balance_warning` (SpendControlAlert, optional, nullable) — Low prepaid balance warning, or null when disabled. - `usage_spend_cutoff` (UsageSpendCutoffControl, optional, nullable) — Usage-spend cutoff, or null when disabled. - `usage_spend_warning` (SpendControlAlert, optional, nullable) — Usage-spend warning, or null when disabled. ### 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. ### SpendControlAlert Spend-control warning threshold. - `threshold_cents` (long, required) — Configured threshold in cents. ### UsageSpendCutoffControl Usage-spend cutoff threshold and enforcement state. - `local_state` (enum, required) — Current local enforcement state. - Allowed values: `ok`, `blocked` - `threshold_cents` (long, required) — Configured cutoff threshold in cents. ## Examples **Request** ```json { "prepaid_low_balance_warning_threshold_cents": 1, "usage_spend_cutoff_threshold_cents": 1, "usage_spend_warning_threshold_cents": 1 } ``` **Response** ```json { "data": { "billing_account_id": "string", "prepaid_low_balance_warning": null, "usage_spend_cutoff": null, "usage_spend_warning": null } } ``` **SDK Code** ```python import requests url = "https://api.mixlayer.com/v1/billing_accounts/billing_account_id/spend_controls" payload = { "prepaid_low_balance_warning_threshold_cents": 1, "usage_spend_cutoff_threshold_cents": 1, "usage_spend_warning_threshold_cents": 1 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.mixlayer.com/v1/billing_accounts/billing_account_id/spend_controls'; const options = { method: 'PUT', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"prepaid_low_balance_warning_threshold_cents":1,"usage_spend_cutoff_threshold_cents":1,"usage_spend_warning_threshold_cents":1}' }; 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" "strings" "net/http" "io" ) func main() { url := "https://api.mixlayer.com/v1/billing_accounts/billing_account_id/spend_controls" payload := strings.NewReader("{\n \"prepaid_low_balance_warning_threshold_cents\": 1,\n \"usage_spend_cutoff_threshold_cents\": 1,\n \"usage_spend_warning_threshold_cents\": 1\n}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") 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/spend_controls") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"prepaid_low_balance_warning_threshold_cents\": 1,\n \"usage_spend_cutoff_threshold_cents\": 1,\n \"usage_spend_warning_threshold_cents\": 1\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.mixlayer.com/v1/billing_accounts/billing_account_id/spend_controls") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"prepaid_low_balance_warning_threshold_cents\": 1,\n \"usage_spend_cutoff_threshold_cents\": 1,\n \"usage_spend_warning_threshold_cents\": 1\n}") .asString(); ``` ```php request('PUT', 'https://api.mixlayer.com/v1/billing_accounts/billing_account_id/spend_controls', [ 'body' => '{ "prepaid_low_balance_warning_threshold_cents": 1, "usage_spend_cutoff_threshold_cents": 1, "usage_spend_warning_threshold_cents": 1 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ```