Create Tier
curl --request POST \
--url https://api.example.com/api/rate-limits/tiers \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"tier": "<string>",
"allowed_limit": 123,
"window_seconds": 123,
"is_active": true
}
'import requests
url = "https://api.example.com/api/rate-limits/tiers"
payload = {
"tier": "<string>",
"allowed_limit": 123,
"window_seconds": 123,
"is_active": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({tier: '<string>', allowed_limit: 123, window_seconds: 123, is_active: true})
};
fetch('https://api.example.com/api/rate-limits/tiers', 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.example.com/api/rate-limits/tiers",
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([
'tier' => '<string>',
'allowed_limit' => 123,
'window_seconds' => 123,
'is_active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/api/rate-limits/tiers"
payload := strings.NewReader("{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/api/rate-limits/tiers")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/rate-limits/tiers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}"
response = http.request(request)
puts response.read_bodyRate Limits
Create Tier
Create a new rate limit tier (admin only)
POST
/
api
/
rate-limits
/
tiers
Create Tier
curl --request POST \
--url https://api.example.com/api/rate-limits/tiers \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"tier": "<string>",
"allowed_limit": 123,
"window_seconds": 123,
"is_active": true
}
'import requests
url = "https://api.example.com/api/rate-limits/tiers"
payload = {
"tier": "<string>",
"allowed_limit": 123,
"window_seconds": 123,
"is_active": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({tier: '<string>', allowed_limit: 123, window_seconds: 123, is_active: true})
};
fetch('https://api.example.com/api/rate-limits/tiers', 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.example.com/api/rate-limits/tiers",
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([
'tier' => '<string>',
'allowed_limit' => 123,
'window_seconds' => 123,
'is_active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/api/rate-limits/tiers"
payload := strings.NewReader("{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/api/rate-limits/tiers")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/rate-limits/tiers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tier\": \"<string>\",\n \"allowed_limit\": 123,\n \"window_seconds\": 123,\n \"is_active\": true\n}"
response = http.request(request)
puts response.read_bodyAuthentication
string
required
Bearer token:
Bearer <admin_token>Request Body
string
required
Tier name (e.g., “client”, “server”, “premium”)
integer
required
Maximum requests allowed per window
integer
required
Time window in seconds
boolean
default:"false"
Whether this tier is active
Example Request
curl -X POST https://api.sari-platform.com/api/rate-limits/tiers \
-H "Authorization: Bearer <admin_token>" \
-H "Content-Type: application/json" \
-d '{
"tier": "premium",
"allowed_limit": 5000,
"window_seconds": 3600,
"is_active": true
}'
Response
{
"tier": "premium",
"allowed_limit": 5000,
"window_seconds": 3600,
"is_active": true,
"created_at": "2024-01-15T10:00:00Z"
}
Only one tier of each name can be active at a time. Activating a new tier may deactivate existing ones.
Errors
| Status | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Invalid or expired token |
| 403 | Admin access required |
| 409 | Tier already exists |
⌘I

