/api/v1/prompts/{promptVersionId}/labelsAttach or detach labels on a prompt version (role-gated)
Add and/or remove labels on a prompt version via `{add?: string[], remove?: string[]}` (at least one non-empty, max 20 each, 60 chars per label). The gate covers BOTH directions: attaching OR detaching a label in the project's `prompt_protected_labels` registry requires at least that entry's `min_required_role` on the project's org. Violations from both directions are reported together in one 403 `PROTECTED_LABEL`, and the patch is all-or-nothing — nothing is written if any label is refused. Requires the Pro plan tier. Returns the merged `{id, labels, added, removed}` with `Cache-Control: no-store`; audit-logged as an update.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Parameters
promptVersionId in pathrequiredstringRequest body required
Example
{
"add": [
"string"
],
"remove": [
"string"
]
}Schema
{
"application/json": {
"schema": {
"type": "object",
"properties": {
"add": {
"type": "array",
"maxItems": 20,
"items": {
"type": "string",
"maxLength": 60
}
},
"remove": {
"type": "array",
"maxItems": 20,
"items": {
"type": "string",
"maxLength": 60
}
}
}
}
}
}Response
All status codes
Code samples
cURL
# {promptVersionId} is shown with an EXAMPLE value — replace it with real values.
curl -X POST \
https://evalguard.ai/api/v1/prompts/00000000-0000-0000-0000-000000000000/labels \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "add": [ "string" ], "remove": [ "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:
// {promptVersionId} is shown with an EXAMPLE value — replace it with real values.
const res = await fetch("https://evalguard.ai/api/v1/prompts/00000000-0000-0000-0000-000000000000/labels", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"add": [
"string"
],
"remove": [
"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:
# {promptVersionId} is shown with an EXAMPLE value — replace it with real values.
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/prompts/00000000-0000-0000-0000-000000000000/labels",
headers=headers,
json={
"add": [
"string"
],
"remove": [
"string"
]
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
// {promptVersionId} is shown with an EXAMPLE value — replace it with real values.
func main() {
body := strings.NewReader(`{"add":["string"],"remove":["string"]}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/prompts/00000000-0000-0000-0000-000000000000/labels", 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)
}