curl --request PUT \
--url https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"disable_agent": true,
"enabled": true,
"multiplier": 123,
"recipients": [
"<string>"
],
"notify_admins": true
}
'import requests
url = "https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule"
payload = {
"disable_agent": True,
"enabled": True,
"multiplier": 123,
"recipients": ["<string>"],
"notify_admins": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
disable_agent: true,
enabled: true,
multiplier: 123,
recipients: ['<string>'],
notify_admins: true
})
};
fetch('https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule', 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.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule",
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([
'disable_agent' => true,
'enabled' => true,
'multiplier' => 123,
'recipients' => [
'<string>'
],
'notify_admins' => true
]),
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://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule"
payload := strings.NewReader("{\n \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\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://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule")
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 \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rule": {
"agent_disabled_at": "2023-11-07T05:31:56Z",
"agent_id": 123,
"cap": {
"backtest_alert_days": 123,
"backtest_days": 123,
"baseline_average": 123,
"baseline_days_used": 123,
"cap_credits": 123,
"computed_at": "2023-11-07T05:31:56Z"
},
"created_at": "2023-11-07T05:31:56Z",
"disable_agent": true,
"enabled": true,
"id": 123,
"multiplier": 123,
"recipients": [
"<string>"
],
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"notify_admins": true
}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"timings_ms": {},
"pagination": {
"has_more": true,
"next_cursor": "<string>"
},
"warnings": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Create or replace an agent's credit alert rule
Saves the rule in the body in place of any rule the agent has, computes its cap, and returns the saved rule. Send every field; a missing notify_admins means true. The alert goes to recipients, plus the account’s active owners and admins when notify_admins is true. A rule with notify_admins false and no address is refused with 400. The cap is multiplier (above 1, at most 100) times the agent’s average over its last 7 days with credits within the last 30 days, rounded up; 1.3 means 30% above the average. With disable_agent true, Neo also turns the agent off when it goes over the cap. When someone turns it back on that day, the count starts again from that moment, so a second crossing alerts and turns it off again. A rule Neo cannot save answers 400 with the reason. Call the preview first to see the cap.
curl --request PUT \
--url https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"disable_agent": true,
"enabled": true,
"multiplier": 123,
"recipients": [
"<string>"
],
"notify_admins": true
}
'import requests
url = "https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule"
payload = {
"disable_agent": True,
"enabled": True,
"multiplier": 123,
"recipients": ["<string>"],
"notify_admins": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
disable_agent: true,
enabled: true,
multiplier: 123,
recipients: ['<string>'],
notify_admins: true
})
};
fetch('https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule', 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.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule",
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([
'disable_agent' => true,
'enabled' => true,
'multiplier' => 123,
'recipients' => [
'<string>'
],
'notify_admins' => true
]),
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://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule"
payload := strings.NewReader("{\n \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\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://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neoagent.io/public-api/agents/{agent_id}/credit-alert-rule")
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 \"disable_agent\": true,\n \"enabled\": true,\n \"multiplier\": 123,\n \"recipients\": [\n \"<string>\"\n ],\n \"notify_admins\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rule": {
"agent_disabled_at": "2023-11-07T05:31:56Z",
"agent_id": 123,
"cap": {
"backtest_alert_days": 123,
"backtest_days": 123,
"baseline_average": 123,
"baseline_days_used": 123,
"cap_credits": 123,
"computed_at": "2023-11-07T05:31:56Z"
},
"created_at": "2023-11-07T05:31:56Z",
"disable_agent": true,
"enabled": true,
"id": 123,
"multiplier": 123,
"recipients": [
"<string>"
],
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"notify_admins": true
}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"timings_ms": {},
"pagination": {
"has_more": true,
"next_cursor": "<string>"
},
"warnings": [
"<string>"
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"meta": {
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Authorizations
Authorization: Bearer <token> where <token> is either a neo_sk_<env>_<secret> API key (service account) or a Microsoft Entra ID access token (dashboard user).
Path Parameters
Body
A daily credit alert rule for one agent.
Also turn the agent off when it goes over its cap.
Whether the rule is checked.
The daily cap as a multiple of the agent's average day, above 1 and at most 100. 1.3 means 30% above the average. The average covers the agent's last 7 days with credits within the last 30 days.
Email addresses that receive the alert.
Also send the alert to the account's active owners and admins. True when left out. Turn it off only when recipients names at least one address.
