> 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-counts-by-dimension/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Get behavior counts by dimension POST https://api.respan.ai/api/pulses/behaviors/grouped/ Content-Type: application/json Splits the spans where one behavior fired by a span field, such as model or customer. The signals panel uses it for its "By model" and "By customer" splits. Reference: https://respan.ai/docs/apis/behaviors/get-behavior-counts-by-dimension ## 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 BehaviorBreakdownRequest. - `behavior` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. - `group_by` (enum, required) — Span field to split by. `status` is the span status, such as `success` or `failed`. - Allowed values: `customer_identifier`, `deployment_name`, `environment`, `model`, `prompt_id`, `prompt_name`, `provider_id`, `status` - `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. - `limit` (integer, optional, default: 100) — Maximum groups to return. Values above 100 are capped at 100. ## Response ### 200 Fired counts per group. - `behavior` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. - `group_by` (enum, required) - Allowed values: `customer_identifier`, `deployment_name`, `environment`, `model`, `prompt_id`, `prompt_name`, `provider_id`, `status` - `groups` (list of BehaviorBreakdownGroup, required) — Groups ordered by `fired_spans`, highest first. Empty when the behavior is turned off. ## Errors ### 400 Bad Request Error `behavior` is missing or `group_by` is not supported. - `error` (string, required) ### 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 ### BehaviorBreakdownGroup - `group_value` (string, required) — Value of the `group_by` field. Spans with no value are grouped under an empty string. - `fired_spans` (integer, required) — Spans with this value where the behavior fired. ## Examples **Request** ```json { "behavior": "instruction_miss", "group_by": "model", "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "limit": 10 } ``` **Response** ```json { "behavior": "instruction_miss", "group_by": "model", "groups": [ { "group_value": "gpt-4o-mini", "fired_spans": 61 }, { "group_value": "claude-sonnet-4-5", "fired_spans": 38 } ] } ``` **SDK Code** ```python Behaviors_getBehaviorBreakdown_example import requests url = "https://api.respan.ai/api/pulses/behaviors/grouped/" payload = { "behavior": "instruction_miss", "group_by": "model", "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "limit": 10 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Behaviors_getBehaviorBreakdown_example const url = 'https://api.respan.ai/api/pulses/behaviors/grouped/'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"behavior":"instruction_miss","group_by":"model","start_time":"2026-09-24T00:00:00Z","end_time":"2026-10-01T00:00:00Z","limit":10}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Behaviors_getBehaviorBreakdown_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/pulses/behaviors/grouped/" payload := strings.NewReader("{\n \"behavior\": \"instruction_miss\",\n \"group_by\": \"model\",\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"limit\": 10\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_getBehaviorBreakdown_example require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/pulses/behaviors/grouped/") 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 \"behavior\": \"instruction_miss\",\n \"group_by\": \"model\",\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"limit\": 10\n}" response = http.request(request) puts response.read_body ``` ```java Behaviors_getBehaviorBreakdown_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/pulses/behaviors/grouped/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"behavior\": \"instruction_miss\",\n \"group_by\": \"model\",\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"limit\": 10\n}") .asString(); ``` ```php Behaviors_getBehaviorBreakdown_example request('POST', 'https://api.respan.ai/api/pulses/behaviors/grouped/', [ 'body' => '{ "behavior": "instruction_miss", "group_by": "model", "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "limit": 10 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Behaviors_getBehaviorBreakdown_example using RestSharp; var client = new RestClient("https://api.respan.ai/api/pulses/behaviors/grouped/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"behavior\": \"instruction_miss\",\n \"group_by\": \"model\",\n \"start_time\": \"2026-09-24T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"limit\": 10\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Behaviors_getBehaviorBreakdown_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "behavior": "instruction_miss", "group_by": "model", "start_time": "2026-09-24T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "limit": 10 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/pulses/behaviors/grouped/")! 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() ```