/api/v1/smart-routingUpdate smart-routing
Creates a new routing rule for a project — it appends, it never updates an existing rule (there is no rule id parameter). Body: projectId (1-200, required) and strategy (1-200, required) — 400 if either is missing — plus optional rules, trafficSplit and canaryConfig, which are passed through. The inserted row is always enabled with priority 0. Mass-assignment-safe: only project_id, strategy, rules, traffic_split, canary_config, enabled, priority and created_at are written. Requires the admin role (mirroring the owner/admin routing_rules write policy, which the service-role client bypasses on API-key auth) and gateway:create. Returns 201 with the created rule. Audit-logged.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Request body required
Example
{
"projectId": "string",
"strategy": "string"
}Schema
{
"application/json": {
"schema": {
"type": "object",
"properties": {
"projectId": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"strategy": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
},
"required": [
"projectId",
"strategy"
],
"additionalProperties": {}
}
}
}Response
200 example
{
"success": true
}All status codes
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/smart-routing \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "projectId": "string", "strategy": "string" }'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/smart-routing", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"projectId": "string",
"strategy": "string"
}),
});
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/smart-routing",
headers=headers,
json={
"projectId": "string",
"strategy": "string"
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"projectId":"string","strategy":"string"}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/smart-routing", 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)
}