Create Budget
curl --request POST \
--url https://api.wistx.ai/v1/budgets \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"scope": {},
"monthly_limit_usd": 123,
"alert_threshold_percent": 123,
"critical_threshold_percent": 123,
"enforcement_mode": "<string>",
"organization_id": "<string>"
}
'import requests
url = "https://api.wistx.ai/v1/budgets"
payload = {
"name": "<string>",
"description": "<string>",
"scope": {},
"monthly_limit_usd": 123,
"alert_threshold_percent": 123,
"critical_threshold_percent": 123,
"enforcement_mode": "<string>",
"organization_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
scope: {},
monthly_limit_usd: 123,
alert_threshold_percent: 123,
critical_threshold_percent: 123,
enforcement_mode: '<string>',
organization_id: '<string>'
})
};
fetch('https://api.wistx.ai/v1/budgets', 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.wistx.ai/v1/budgets",
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([
'name' => '<string>',
'description' => '<string>',
'scope' => [
],
'monthly_limit_usd' => 123,
'alert_threshold_percent' => 123,
'critical_threshold_percent' => 123,
'enforcement_mode' => '<string>',
'organization_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.wistx.ai/v1/budgets"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.wistx.ai/v1/budgets")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wistx.ai/v1/budgets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"budget_id": "bud_abc123",
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": {
"type": "cloud_provider",
"cloud_provider": "aws"
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"status": "active",
"enforcement_mode": "alert",
"current_period_start": "2024-01-01T00:00:00Z",
"current_period_end": "2024-02-01T00:00:00Z",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "cloud_provider is required for cloud_provider scope",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found in authentication token"
}
{
"error": {
"code": "BUDGET_CREATION_ERROR",
"message": "Failed to create budget",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Infrastructure Budget
Create Budget
Create a new infrastructure budget for tracking spending
POST
/
v1
/
budgets
Create Budget
curl --request POST \
--url https://api.wistx.ai/v1/budgets \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"scope": {},
"monthly_limit_usd": 123,
"alert_threshold_percent": 123,
"critical_threshold_percent": 123,
"enforcement_mode": "<string>",
"organization_id": "<string>"
}
'import requests
url = "https://api.wistx.ai/v1/budgets"
payload = {
"name": "<string>",
"description": "<string>",
"scope": {},
"monthly_limit_usd": 123,
"alert_threshold_percent": 123,
"critical_threshold_percent": 123,
"enforcement_mode": "<string>",
"organization_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
scope: {},
monthly_limit_usd: 123,
alert_threshold_percent: 123,
critical_threshold_percent: 123,
enforcement_mode: '<string>',
organization_id: '<string>'
})
};
fetch('https://api.wistx.ai/v1/budgets', 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.wistx.ai/v1/budgets",
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([
'name' => '<string>',
'description' => '<string>',
'scope' => [
],
'monthly_limit_usd' => 123,
'alert_threshold_percent' => 123,
'critical_threshold_percent' => 123,
'enforcement_mode' => '<string>',
'organization_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.wistx.ai/v1/budgets"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.wistx.ai/v1/budgets")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wistx.ai/v1/budgets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"scope\": {},\n \"monthly_limit_usd\": 123,\n \"alert_threshold_percent\": 123,\n \"critical_threshold_percent\": 123,\n \"enforcement_mode\": \"<string>\",\n \"organization_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"budget_id": "bud_abc123",
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": {
"type": "cloud_provider",
"cloud_provider": "aws"
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"status": "active",
"enforcement_mode": "alert",
"current_period_start": "2024-01-01T00:00:00Z",
"current_period_end": "2024-02-01T00:00:00Z",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "cloud_provider is required for cloud_provider scope",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found in authentication token"
}
{
"error": {
"code": "BUDGET_CREATION_ERROR",
"message": "Failed to create budget",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Create a new infrastructure budget for tracking spending
curl --request POST \
--url https://api.wistx.ai/v1/budgets \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": {
"type": "cloud_provider",
"cloud_provider": "aws"
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"enforcement_mode": "alert"
}'
import requests
api_key = "YOUR_API_KEY"
url = "https://api.wistx.ai/v1/budgets"
response = requests.post(
url,
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": {
"type": "cloud_provider",
"cloud_provider": "aws"
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"enforcement_mode": "alert"
}
)
budget = response.json()
print(f"Budget created: {budget['budget_id']}")
const apiKey = "YOUR_API_KEY";
const url = "https://api.wistx.ai/v1/budgets";
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
name: "Production Infrastructure Budget",
description: "Monthly budget for production AWS infrastructure",
scope: {
type: "cloud_provider",
cloud_provider: "aws"
},
monthly_limit_usd: 5000.0,
alert_threshold_percent: 80.0,
critical_threshold_percent: 95.0,
enforcement_mode: "alert"
})
});
const budget = await response.json();
console.log(`Budget created: ${budget.budget_id}`);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
apiKey := "YOUR_API_KEY"
url := "https://api.wistx.ai/v1/budgets"
payload := map[string]interface{}{
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": map[string]interface{}{
"type": "cloud_provider",
"cloud_provider": "aws",
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"enforcement_mode": "alert",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var budget map[string]interface{}
json.NewDecoder(resp.Body).Decode(&budget)
fmt.Printf("Budget created: %v\n", budget["budget_id"])
}
require 'net/http'
require 'json'
require 'uri'
api_key = "YOUR_API_KEY"
url = URI("https://api.wistx.ai/v1/budgets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = {
name: "Production Infrastructure Budget",
description: "Monthly budget for production AWS infrastructure",
scope: {
type: "cloud_provider",
cloud_provider: "aws"
},
monthly_limit_usd: 5000.0,
alert_threshold_percent: 80.0,
critical_threshold_percent: 95.0,
enforcement_mode: "alert"
}.to_json
response = http.request(request)
budget = JSON.parse(response.body)
puts "Budget created: #{budget['budget_id']}"
<?php
$apiKey = "YOUR_API_KEY";
$url = "https://api.wistx.ai/v1/budgets";
$data = [
"name" => "Production Infrastructure Budget",
"description" => "Monthly budget for production AWS infrastructure",
"scope" => [
"type" => "cloud_provider",
"cloud_provider" => "aws"
],
"monthly_limit_usd" => 5000.0,
"alert_threshold_percent" => 80.0,
"critical_threshold_percent" => 95.0,
"enforcement_mode" => "alert"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
$budget = json_decode($response, true);
echo "Budget created: " . $budget['budget_id'];
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
public class CreateBudget {
public static void main(String[] args) throws Exception {
String apiKey = "YOUR_API_KEY";
URL url = new URL("https://api.wistx.ai/v1/budgets");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "Bearer " + apiKey);
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
JsonObject scope = new JsonObject();
scope.addProperty("type", "cloud_provider");
scope.addProperty("cloud_provider", "aws");
JsonObject payload = new JsonObject();
payload.addProperty("name", "Production Infrastructure Budget");
payload.addProperty("description", "Monthly budget for production AWS infrastructure");
payload.add("scope", scope);
payload.addProperty("monthly_limit_usd", 5000.0);
payload.addProperty("alert_threshold_percent", 80.0);
payload.addProperty("critical_threshold_percent", 95.0);
payload.addProperty("enforcement_mode", "alert");
Gson gson = new Gson();
try (OutputStream os = conn.getOutputStream()) {
byte[] input = gson.toJson(payload).getBytes("utf-8");
os.write(input, 0, input.length);
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
Request Parameters
string
required
Budget name.Minimum: 1 character
Maximum: 200 characters
Maximum: 200 characters
string
Budget description.Maximum: 1000 characters
object
required
Budget scope definition.Scope Types:
overall- Track all infrastructure spendingcloud_provider- Track spending for a specific cloud provider (requirescloud_providerfield)environment- Track spending for a specific environment (requiresenvironment_namefield)
- Overall:
{"type": "overall"} - Cloud Provider:
{"type": "cloud_provider", "cloud_provider": "aws"} - Environment:
{"type": "environment", "environment_name": "production"} - Combined:
{"type": "environment", "cloud_provider": "aws", "environment_name": "production"}
number
required
Monthly budget limit in USD.Minimum: Greater than 0
number
Alert threshold percentage. Alerts are sent when spending reaches this percentage of the budget.Default:
Minimum: 0
Maximum: 100
80.0Minimum: 0
Maximum: 100
number
Critical alert threshold percentage. Critical alerts are sent when spending reaches this percentage.Default:
Minimum: 0
Maximum: 100
95.0Minimum: 0
Maximum: 100
string
Budget enforcement mode.Options:
Default:
alert, warn, blockDefault:
alertstring
Organization ID if budget is shared within an organization.
Response
{
"budget_id": "bud_abc123",
"name": "Production Infrastructure Budget",
"description": "Monthly budget for production AWS infrastructure",
"scope": {
"type": "cloud_provider",
"cloud_provider": "aws"
},
"monthly_limit_usd": 5000.0,
"alert_threshold_percent": 80.0,
"critical_threshold_percent": 95.0,
"status": "active",
"enforcement_mode": "alert",
"current_period_start": "2024-01-01T00:00:00Z",
"current_period_end": "2024-02-01T00:00:00Z",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "cloud_provider is required for cloud_provider scope",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found in authentication token"
}
{
"error": {
"code": "BUDGET_CREATION_ERROR",
"message": "Failed to create budget",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Related Endpoints
- List Budgets - List all budgets
- Get Budget - Get budget details
- Get Budget Status - Get budget status and spending