curl --request POST \
--url https://api.limitguard.ai/v1/keys/upgrade/{tier} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.limitguard.ai/v1/keys/upgrade/{tier}"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.limitguard.ai/v1/keys/upgrade/{tier}', 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.limitguard.ai/v1/keys/upgrade/{tier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.limitguard.ai/v1/keys/upgrade/{tier}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.limitguard.ai/v1/keys/upgrade/{tier}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.limitguard.ai/v1/keys/upgrade/{tier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"key_id": "<string>",
"previous_tier": "<string>",
"new_tier": "<string>",
"monthly_limit": 123,
"payment_amount_usdc": 123,
"credited_usd": 123,
"balance_usd": 123,
"tier_expires_at": "2023-11-07T05:31:56Z",
"queued_terms": [
{
"tier": "<string>",
"starts_at": "2023-11-07T05:31:56Z"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Upgrade Key
Buy prepaid balance via x402 USDC payment.
The x402 price is credited 1:1 to the key’s prepaid balance and the tier label is set to the higher of the current and purchased tier (the label selects burst limits in rate_limit.py; it never downgrades). Repeat purchases are allowed. Each priced call is then debited at the price in the pricing table.
The x402 middleware verifies the payment signature before this handler runs. The handler then checks the funds on chain and settles the payment with a mined receipt before it applies the upgrade or the credit. The credit is the amount paid, capped at the tier price. Send X-API-Key header to identify which key to credit.
Ladder prices: indie $29, starter $99, growth $299, pro $999.
curl --request POST \
--url https://api.limitguard.ai/v1/keys/upgrade/{tier} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.limitguard.ai/v1/keys/upgrade/{tier}"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.limitguard.ai/v1/keys/upgrade/{tier}', 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.limitguard.ai/v1/keys/upgrade/{tier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.limitguard.ai/v1/keys/upgrade/{tier}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.limitguard.ai/v1/keys/upgrade/{tier}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.limitguard.ai/v1/keys/upgrade/{tier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"key_id": "<string>",
"previous_tier": "<string>",
"new_tier": "<string>",
"monthly_limit": 123,
"payment_amount_usdc": 123,
"credited_usd": 123,
"balance_usd": 123,
"tier_expires_at": "2023-11-07T05:31:56Z",
"queued_terms": [
{
"tier": "<string>",
"starts_at": "2023-11-07T05:31:56Z"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Response
Successful Response
Response after buying prepaid balance via x402 on POST /v1/keys/upgrade/{tier}.