> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/behaviors/get-behavior-summary/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Get behavior summary POST https://api.respan.ai/api/pulses/behaviors/ Content-Type: application/json Returns how often each behavior fired in a time range, with totals and a rollup by polarity. Counts come from an hourly rollup refreshed every 10 minutes, so the range is widened to whole hours. Reference: https://respan.ai/docs/apis/behaviors/get-behavior-summary ## 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 ### Body (application/json) This endpoint expects a BehaviorWindowRequest. - `start_time` (datetime, optional) — Start of the range, ISO 8601. A time without an offset is read as UTC. Defaults to 7 days ago, which is also used if the value can't be parsed. - `end_time` (datetime, optional) — End of the range, ISO 8601. A time without an offset is read as UTC. Defaults to now, which is also used if the value can't be parsed. - `environment` (string, optional) — Only count spans from this environment, such as `prod` or `test`. Omit it to include every environment. ## Response ### 200 Behavior counts for the range. - `behaviors` (list of BehaviorSummaryItem, required) — One row per behavior scored in the range, most fired first. Turned-off behaviors are left out. - `total_behaviors_tracked` (integer, required) — Behaviors in `behaviors` that fired at least once. - `total_classified_spans` (integer, required) — Distinct spans scored in the range. A span scored for several behaviors counts once. - `total_fired_spans` (integer, required) — Distinct spans where at least one behavior fired. - `polarity_totals` (BehaviorPolarityCounts, required) — Fired verdicts per polarity. A span that fires several behaviors counts once per behavior. - `net_sentiment` (integer, required) — `polarity_totals.positive` minus `polarity_totals.negative`. ## Errors ### 403 Forbidden Error Forbidden: the API key is missing, invalid or expired; the key doesn't grant `logs:read` (Read access does); behaviors are turned off for the organization. - `detail` (string, required) ### 429 Too Many Requests Error Rate limited. This endpoint allows 60 requests per minute per organization. - `detail` (string, required) ## Types ### BehaviorSummaryItem - `behavior` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. - `fired_spans` (integer, required) — Spans where the behavior fired (latest score at or above 0.65). - `classified_spans` (integer, required) — Spans scored for this behavior in the range. - `polarity` (enum, required) — 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` - `is_builtin` (boolean, required) — `true` for a built-in behavior, `false` for one of your custom behaviors. ### BehaviorPolarityCounts Fired verdicts per polarity. A span that fires several behaviors counts once per behavior. - `positive` (integer, required) — Fired verdicts of `positive` behaviors (Wins). - `negative` (integer, required) — Fired verdicts of `negative` behaviors (Issues). - `neutral` (integer, required) — Fired verdicts of `neutral` behaviors (Info). ## Examples **Request** ```json { "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "environment": "prod" } ``` **Response** ```json { "behaviors": [ { "behavior": "task_complete", "fired_spans": 412, "classified_spans": 5210, "polarity": "positive", "is_builtin": true }, { "behavior": "structured_output", "fired_spans": 388, "classified_spans": 5210, "polarity": "neutral", "is_builtin": true }, { "behavior": "instruction_miss", "fired_spans": 143, "classified_spans": 5210, "polarity": "negative", "is_builtin": true }, { "behavior": "6f1c2a9e-3b7d-4c55-9a0e-2d8f4b1c7e93", "fired_spans": 44, "classified_spans": 5210, "polarity": "negative", "is_builtin": false } ], "total_behaviors_tracked": 4, "total_classified_spans": 5210, "total_fired_spans": 902, "polarity_totals": { "positive": 412, "negative": 187, "neutral": 388 }, "net_sentiment": 225 } ``` **SDK Code** ```python Behaviors_getBehaviorSummary_example import requests url = "https://api.respan.ai/api/pulses/behaviors/" payload = { "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "environment": "prod" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Behaviors_getBehaviorSummary_example const url = 'https://api.respan.ai/api/pulses/behaviors/'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"start_time":"2026-09-24T00:00:00Z","end_time":"2026-10-01T00:00:00Z","environment":"prod"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Behaviors_getBehaviorSummary_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/pulses/behaviors/" payload := strings.NewReader("{\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"environment\": \"prod\"\n}") req, _ := http.NewRequest("POST", 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_getBehaviorSummary_example require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/pulses/behaviors/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"environment\": \"prod\"\n}" response = http.request(request) puts response.read_body ``` ```java Behaviors_getBehaviorSummary_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/pulses/behaviors/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"environment\": \"prod\"\n}") .asString(); ``` ```php Behaviors_getBehaviorSummary_example request('POST', 'https://api.respan.ai/api/pulses/behaviors/', [ 'body' => '{ "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "environment": "prod" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Behaviors_getBehaviorSummary_example using RestSharp; var client = new RestClient("https://api.respan.ai/api/pulses/behaviors/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"environment\": \"prod\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Behaviors_getBehaviorSummary_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "environment": "prod" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/pulses/behaviors/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ```