/api/v1/monitoring/slaCreate an SLA target
Adds an SLA target. Requires an org — `orgId` as a query param or body field, or an org-pinned `eg_` key (400 MISSING_ORG_ID when none resolves) plus `name`, `modelOrEndpoint`, `metric` and `target`; `metric` must be one of availability, latency_p95, latency_p99, error_rate, throughput. Optional `operator` (defaults to `gte` for availability/throughput, `lte` otherwise), `windowMinutes` (default 60) and `severity` (critical|warning|info, default warning). The target is stamped with the caller's org so the sibling GET and DELETE can only see and remove it. Returns 201. SLA targets live in a process-local in-memory store, not the database: they do not survive a restart and are not shared across server instances.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Request body required
Example
{
"name": "string",
"modelOrEndpoint": "string",
"metric": "availability",
"target": 0,
"operator": "lte",
"windowMinutes": 60,
"severity": "warning"
}Schema
{
"application/json": {
"schema": {
"type": "object",
"required": [
"name",
"modelOrEndpoint",
"metric",
"target"
],
"properties": {
"name": {
"type": "string"
},
"modelOrEndpoint": {
"type": "string"
},
"metric": {
"type": "string",
"enum": [
"availability",
"latency_p95",
"latency_p99",
"error_rate",
"throughput"
]
},
"target": {
"type": "number"
},
"operator": {
"type": "string",
"enum": [
"lte",
"gte"
],
"description": "Defaults to gte for availability/throughput, lte otherwise."
},
"windowMinutes": {
"type": "number",
"default": 60
},
"severity": {
"type": "string",
"enum": [
"critical",
"warning",
"info"
],
"default": "warning"
}
}
}
}
}Response
201 example
{
"success": true
}All status codes
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/monitoring/sla \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "string", "modelOrEndpoint": "string", "metric": "availability", "target": 0, "operator": "lte", "windowMinutes": 60, "severity": "warning" }'TypeScript
// The TypeScript SDK (@evalguard/sdk) exposes TYPED methods — runEval,
// getEval, runSecurityScan, checkFirewall, … — not a generic request().
// For an arbitrary endpoint, call it directly:
const res = await fetch("https://evalguard.ai/api/v1/monitoring/sla", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "string",
"modelOrEndpoint": "string",
"metric": "availability",
"target": 0,
"operator": "lte",
"windowMinutes": 60,
"severity": "warning"
}),
});
console.log(res.status, await res.json());Python
# The Python SDK (pip install evalguardai) exposes TYPED methods on
# EvalGuardClient — run_eval, get_eval, … — not a generic request().
# For an arbitrary endpoint, call it directly:
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['EVALGUARD_API_KEY']}"}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://evalguard.ai/api/v1/monitoring/sla",
headers=headers,
json={
"name": "string",
"modelOrEndpoint": "string",
"metric": "availability",
"target": 0,
"operator": "lte",
"windowMinutes": 60,
"severity": "warning"
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"name":"string","modelOrEndpoint":"string","metric":"availability","target":0,"operator":"lte","windowMinutes":60,"severity":"warning"}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/monitoring/sla", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("EVALGUARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
fmt.Println(resp.Status)
}