> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/behaviors/override-behavior-verdict/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Override a behavior verdict PATCH https://api.respan.ai/api/request-logs/{unique_id}/behaviors/{behavior_key}/ Content-Type: application/json Records whether a behavior happened on a span, replacing the model's score (Happened / Not happened in the app). The span must already have a verdict for the behavior. Span-level reads use it at once; rollup counts pick it up within 10 minutes for spans from the last 48 hours. Reference: https://respan.ai/docs/apis/behaviors/override-behavior-verdict ## Authentication - `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan\_params.credential\_override in the request body, not in this authentication field. ## Request ### Path parameters - `unique_id` (string, required) — Span ID. - `behavior_key` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. ### Body (application/json) This endpoint expects a BehaviorOverrideRequest. - `prob` (double, required) — The score to record in place of the model's. Send `1` for Happened and `0` for Not happened. The behavior fires when this is 0.65 or higher. ## Response ### 200 The span's new verdict. - `label` (enum, required) — `1` when the behavior fired (`prob` is 0.65 or higher), else `0`. - Allowed values: `0`, `1` - `prob` (double, required) — The score now on the span. - `source` (string, required) — `human` after an override. - `state` (enum, required) — `detected` at 0.65 or higher, `uncertain` from 0.35 up to 0.65, else `not_detected`. - Allowed values: `detected`, `uncertain`, `not_detected` - `polarity` (enum, required, nullable) — Whether the behavior firing is good or bad: `negative` (an Issue), `positive` (a Win) or `neutral` (Info). Display metadata only; it does not change how spans are scored. - Allowed values: `negative`, `positive`, `neutral` ## Errors ### 400 Bad Request Error `prob` is missing, not a number, or outside 0 to 1. - `prob` (list of string, optional) ### 403 Forbidden Error Forbidden: the API key is missing, invalid or expired; the key doesn't grant `logs:update` (Write access does); behaviors are turned off for the organization. - `detail` (string, required) ### 404 Not Found Error The span has no verdict for this behavior: it doesn't exist, hasn't been scored yet, or the behavior is turned off. - `detail` (string, required) ### 409 Conflict Error Another override of the same verdict is in progress. Retry. - `detail` (string, required) ### 429 Too Many Requests Error Rate limited. This endpoint allows 30 requests per minute per organization. - `detail` (string, required) ## Examples **Request** ```json { "prob": 0 } ``` **Response** ```json { "label": 0, "prob": 0, "source": "human", "state": "not_detected", "polarity": "neutral" } ``` **SDK Code** ```python Behaviors_overrideSpanBehavior_example import requests url = "https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/" payload = { "prob": 0 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Behaviors_overrideSpanBehavior_example const url = 'https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/'; const options = { method: 'PATCH', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"prob":0}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Behaviors_overrideSpanBehavior_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/" payload := strings.NewReader("{\n \"prob\": 0\n}") req, _ := http.NewRequest("PATCH", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Behaviors_overrideSpanBehavior_example require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"prob\": 0\n}" response = http.request(request) puts response.read_body ``` ```java Behaviors_overrideSpanBehavior_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.patch("https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"prob\": 0\n}") .asString(); ``` ```php Behaviors_overrideSpanBehavior_example request('PATCH', 'https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/', [ 'body' => '{ "prob": 0 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Behaviors_overrideSpanBehavior_example using RestSharp; var client = new RestClient("https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/"); var request = new RestRequest(Method.PATCH); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"prob\": 0\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Behaviors_overrideSpanBehavior_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["prob": 0] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/request-logs/c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b/behaviors/refusal/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```