API Keys
Set API Key Credit Limit
Cap how many credits an API key can spend, or remove the cap.
POST
/
api
/
agent
/
keys
/
limit
Set API Key Credit Limit
curl --request POST \
--url https://encrata.com/api/agent/keys/limit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "<string>",
"credit_limit": 123
}
'import requests
url = "https://encrata.com/api/agent/keys/limit"
payload = {
"id": "<string>",
"credit_limit": 123
}
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({id: '<string>', credit_limit: 123})
};
fetch('https://encrata.com/api/agent/keys/limit', 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://encrata.com/api/agent/keys/limit",
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([
'id' => '<string>',
'credit_limit' => 123
]),
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://encrata.com/api/agent/keys/limit"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"credit_limit\": 123\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://encrata.com/api/agent/keys/limit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"credit_limit\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://encrata.com/api/agent/keys/limit")
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 \"id\": \"<string>\",\n \"credit_limit\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"error": "Credit limit must be a positive number"
}
{
"error": "Unauthorized"
}
{
"error": "Insufficient permissions"
}
{
"error": "API key not found"
}
Authentication
Requires an API key in theAuthorization header.
Authorization: Bearer YOUR_API_KEY
Request
string
required
The ID of the API key to update.
integer
The maximum number of credits this key may spend. Must be
>= 0. Send null
to remove the cap (unlimited usage).Set a limit
curl -X POST https://encrata.com/api/agent/keys/limit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"id": "key_abc123", "credit_limit": 5000}'
Remove the limit (unlimited)
curl -X POST https://encrata.com/api/agent/keys/limit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"id": "key_abc123", "credit_limit": null}'
Response
string
Confirmation message.
integer
The newly-applied credit cap, or
null when the cap was removed.{
"message": "Credit limit updated",
"credit_limit": 5000
}
Setting a limit requires a non-
readonly role in the active workspace.{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"error": "Credit limit must be a positive number"
}
{
"error": "Unauthorized"
}
{
"error": "Insufficient permissions"
}
{
"error": "API key not found"
}
Was this page helpful?
⌘I
Set API Key Credit Limit
curl --request POST \
--url https://encrata.com/api/agent/keys/limit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "<string>",
"credit_limit": 123
}
'import requests
url = "https://encrata.com/api/agent/keys/limit"
payload = {
"id": "<string>",
"credit_limit": 123
}
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({id: '<string>', credit_limit: 123})
};
fetch('https://encrata.com/api/agent/keys/limit', 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://encrata.com/api/agent/keys/limit",
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([
'id' => '<string>',
'credit_limit' => 123
]),
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://encrata.com/api/agent/keys/limit"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"credit_limit\": 123\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://encrata.com/api/agent/keys/limit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"credit_limit\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://encrata.com/api/agent/keys/limit")
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 \"id\": \"<string>\",\n \"credit_limit\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"error": "Credit limit must be a positive number"
}
{
"error": "Unauthorized"
}
{
"error": "Insufficient permissions"
}
{
"error": "API key not found"
}