Python (SDK)
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.budgets.set_api_key(api_key_id="<id>", period="weekly", limit=3281.35, thresholds=[
{
"pct": 793338,
"action": "alert",
},
], owner="org")
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.budgets.setApiKey({
apiKeyId: "<id>",
requestBody: {
period: "weekly",
limit: 3281.35,
thresholds: [
{
pct: 793338,
action: "alert",
},
],
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Budgets.SetApiKeyAsync(
apiKeyId: "<id>",
body: new SetApiKeyBudgetRequestBody() {
Period = SetApiKeyBudgetPeriodRequest.Weekly,
Limit = 3281.35D,
Thresholds = new List<SetApiKeyBudgetThresholdRequest>() {
new SetApiKeyBudgetThresholdRequest() {
Pct = 793338,
Action = SetApiKeyBudgetActionRequest.Alert,
},
},
}
);
// handle responsecurl --request PUT \
--url https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit": 123,
"thresholds": [
{
"pct": 50
}
],
"owner": "org",
"webhook_url": "<string>",
"webhook_secret": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
limit: 123,
thresholds: [{pct: 50}],
owner: 'org',
webhook_url: '<string>',
webhook_secret: '<string>'
})
};
fetch('https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}', 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://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'limit' => 123,
'thresholds' => [
[
'pct' => 50
]
],
'owner' => 'org',
'webhook_url' => '<string>',
'webhook_secret' => '<string>'
]),
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://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}"
payload := strings.NewReader("{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"scope_id": "<string>",
"scope_org_id": "<string>",
"limit": 123,
"thresholds": [
{
"pct": 50
}
],
"alert_webhook_url": "<string>",
"spend": {
"window": "<string>",
"cost_spent": 123,
"limit": 123,
"pct": 0
}
}Budgets
Set an apikey budget
Creates or updates a budget for the apikey. One budget per (scope, owner); editing re-evaluates against live spend. Callable by cluster admins, or org admins for API keys in their own organization.
PUT
/
api
/
v1
/
budgeting
/
budgets
/
apikey
/
{apiKeyId}
Python (SDK)
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.budgets.set_api_key(api_key_id="<id>", period="weekly", limit=3281.35, thresholds=[
{
"pct": 793338,
"action": "alert",
},
], owner="org")
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.budgets.setApiKey({
apiKeyId: "<id>",
requestBody: {
period: "weekly",
limit: 3281.35,
thresholds: [
{
pct: 793338,
action: "alert",
},
],
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Budgets.SetApiKeyAsync(
apiKeyId: "<id>",
body: new SetApiKeyBudgetRequestBody() {
Period = SetApiKeyBudgetPeriodRequest.Weekly,
Limit = 3281.35D,
Thresholds = new List<SetApiKeyBudgetThresholdRequest>() {
new SetApiKeyBudgetThresholdRequest() {
Pct = 793338,
Action = SetApiKeyBudgetActionRequest.Alert,
},
},
}
);
// handle responsecurl --request PUT \
--url https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit": 123,
"thresholds": [
{
"pct": 50
}
],
"owner": "org",
"webhook_url": "<string>",
"webhook_secret": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
limit: 123,
thresholds: [{pct: 50}],
owner: 'org',
webhook_url: '<string>',
webhook_secret: '<string>'
})
};
fetch('https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}', 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://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'limit' => 123,
'thresholds' => [
[
'pct' => 50
]
],
'owner' => 'org',
'webhook_url' => '<string>',
'webhook_secret' => '<string>'
]),
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://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}"
payload := strings.NewReader("{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/budgeting/budgets/apikey/{apiKeyId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit\": 123,\n \"thresholds\": [\n {\n \"pct\": 50\n }\n ],\n \"owner\": \"org\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"scope_id": "<string>",
"scope_org_id": "<string>",
"limit": 123,
"thresholds": [
{
"pct": 50
}
],
"alert_webhook_url": "<string>",
"spend": {
"window": "<string>",
"cost_spent": 123,
"limit": 123,
"pct": 0
}
}Authorizations
Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.
Path Parameters
Minimum string length:
1Body
application/json
Available options:
daily, weekly, monthly Spend limit in major currency units
Minimum array length:
1Show child attributes
Show child attributes
cluster = operator ceiling (org-admin read-only); org = self-budget
Available options:
cluster, org Minimum string length:
1Response
200 - application/json
OK
Available options:
org, apikey Available options:
cluster, org Available options:
daily, weekly, monthly Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I