Skip to main content
POST
/
v1
/
organizations
/
billing
/
spending-caps
Update Spending Caps
curl --request POST \
  --url https://api.mixpeek.com/v1/organizations/billing/spending-caps \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "monthly_spending_budget": 10000,
  "spending_alert_thresholds": [
    50,
    75,
    90,
    100
  ],
  "spending_alerts_enabled": true,
  "hard_spending_cap": 50000,
  "hard_cap_enabled": true
}
'
import requests

url = "https://api.mixpeek.com/v1/organizations/billing/spending-caps"

payload = {
"monthly_spending_budget": 10000,
"spending_alert_thresholds": [50, 75, 90, 100],
"spending_alerts_enabled": True,
"hard_spending_cap": 50000,
"hard_cap_enabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
monthly_spending_budget: 10000,
spending_alert_thresholds: [50, 75, 90, 100],
spending_alerts_enabled: true,
hard_spending_cap: 50000,
hard_cap_enabled: true
})
};

fetch('https://api.mixpeek.com/v1/organizations/billing/spending-caps', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixpeek.com/v1/organizations/billing/spending-caps",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'monthly_spending_budget' => 10000,
'spending_alert_thresholds' => [
50,
75,
90,
100
],
'spending_alerts_enabled' => true,
'hard_spending_cap' => 50000,
'hard_cap_enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.mixpeek.com/v1/organizations/billing/spending-caps"

payload := strings.NewReader("{\n \"monthly_spending_budget\": 10000,\n \"spending_alert_thresholds\": [\n 50,\n 75,\n 90,\n 100\n ],\n \"spending_alerts_enabled\": true,\n \"hard_spending_cap\": 50000,\n \"hard_cap_enabled\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.mixpeek.com/v1/organizations/billing/spending-caps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"monthly_spending_budget\": 10000,\n \"spending_alert_thresholds\": [\n 50,\n 75,\n 90,\n 100\n ],\n \"spending_alerts_enabled\": true,\n \"hard_spending_cap\": 50000,\n \"hard_cap_enabled\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.mixpeek.com/v1/organizations/billing/spending-caps")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"monthly_spending_budget\": 10000,\n \"spending_alert_thresholds\": [\n 50,\n 75,\n 90,\n 100\n ],\n \"spending_alerts_enabled\": true,\n \"hard_spending_cap\": 50000,\n \"hard_cap_enabled\": true\n}"

response = http.request(request)
puts response.read_body
{
  "current_spending_cents": 123,
  "current_spending_usd": 123,
  "monthly_spending_budget": 10000,
  "monthly_spending_budget_usd": 100,
  "spending_alert_thresholds": [
    123
  ],
  "spending_alerts_enabled": true,
  "spending_alerts_sent": [
    123
  ],
  "hard_spending_cap": 50000,
  "hard_spending_cap_usd": 500,
  "hard_cap_enabled": false,
  "budget_percentage_used": 46.9
}
{
"status": 123,
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"details": {}
},
"success": false
}
{
"status": 123,
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"details": {}
},
"success": false
}
{
"status": 123,
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"details": {}
},
"success": false
}
{
"status": 123,
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"details": {}
},
"success": false
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"status": 123,
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"details": {}
},
"success": false
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Spending cap configuration

monthly_spending_budget
integer | null

Soft spending limit in USD cents. Triggers alerts but doesn't block API access. Set to null to remove budget limit.

Required range: x >= 0
Example:

10000

spending_alert_thresholds
integer[] | null

Percentage thresholds for spending alerts (0-100). When current spending reaches each threshold, an alert is sent.

Example:
[50, 75, 90, 100]
spending_alerts_enabled
boolean | null

Whether to send spending alerts when thresholds are crossed.

hard_spending_cap
integer | null

Hard spending limit in USD cents. When reached, API access is blocked. Set to null to remove hard cap.

Required range: x >= 0
Example:

50000

hard_cap_enabled
boolean | null

Whether to enforce the hard spending cap.

Response

Successful Response

Response with spending cap configuration.

current_spending_cents
integer
required

Current spending in current billing cycle (cents)

Example:

23450

current_spending_usd
number
required

Current spending in current billing cycle (USD)

Example:

234.5

monthly_spending_budget
integer | null

Soft spending limit in USD cents (null = unlimited)

Example:

10000

monthly_spending_budget_usd
number | null

Soft spending limit in USD

Example:

100

spending_alert_thresholds
integer[]

Percentage thresholds for spending alerts

Example:
[50, 75, 90, 100]
spending_alerts_enabled
boolean
default:true

Whether spending alerts are enabled

spending_alerts_sent
integer[]

Alert thresholds triggered in current billing cycle

Example:
[50, 75]
hard_spending_cap
integer | null

Hard spending limit in USD cents (null = no hard cap)

Example:

50000

hard_spending_cap_usd
number | null

Hard spending limit in USD

Example:

500

hard_cap_enabled
boolean
default:false

Whether hard spending cap is enforced

budget_percentage_used
number | null

Percentage of budget used (null if no budget set)

Example:

46.9