Get behavior counts by dimension
https://api.respan.ai/api/pulses/behaviors/grouped/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.
Servers
https://api.respan.ai: Respan API Server
Authentication
RespanApiKey
Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. 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.
HTTP scheme: bearer; format: Respan API key.
Authorization: Bearer $RESPAN_API_KEYRequest body
A request body is required.
application/json
$ object Required body
#/components/schemas/BehaviorBreakdownRequestbehavior string Required in parentrefusal) or a custom behavior’s id.Example:
"instruction_miss"group_by string Required in parentstatus is the span status, such as success or failed.Allowed:
"customer_identifier", "deployment_name", "environment", "model", "prompt_id", "prompt_name", "provider_id", "status"Example:
"model"start_time string OptionalFormat:
date-timeExample:
"2026-09-24T00:00:00Z"end_time string OptionalFormat:
date-timeExample:
"2026-10-01T00:00:00Z"environment string Optionalprod or test. Omit it to include every environment.Example:
"prod"limit integer OptionalDefault:
100Minimum:
1Maximum:
100Example:
10OpenAPI request schema
{
"$ref": "#/components/schemas/BehaviorBreakdownRequest"
}Example
{
"behavior": "instruction_miss",
"group_by": "model",
"start_time": "2026-09-24T00:00:00Z",
"end_time": "2026-10-01T00:00:00Z",
"limit": 10
}Responses
200
Fired counts per group.
application/json
$ object Body
#/components/schemas/BehaviorBreakdownbehavior string Required in parentrefusal) or a custom behavior’s id.Example:
"instruction_miss"group_by string Required in parent"customer_identifier", "deployment_name", "environment", "model", "prompt_id", "prompt_name", "provider_id", "status"Example:
"model"groups array<object> Required in parent
fired_spans, highest first. Empty when the behavior is turned off.groups[] object Array item
#/components/schemas/BehaviorBreakdownGroupgroups[].group_value string Required in parentgroup_by field. Spans with no value are grouped under an empty string.Example:
"gpt-4o-mini"groups[].fired_spans integer Required in parentExample:
61OpenAPI response schema
{
"$ref": "#/components/schemas/BehaviorBreakdown"
}Example
{
"behavior": "instruction_miss",
"group_by": "model",
"groups": [
{
"group_value": "gpt-4o-mini",
"fired_spans": 61
},
{
"group_value": "claude-sonnet-4-5",
"fired_spans": 38
}
]
}400
behavior is missing or group_by is not supported.
application/json
$ object Body
error string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
}Example
{
"error": "'behavior' is required"
}403
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.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Missing or invalid API key
{
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}Key lacks the permission
{
"detail": "This API key does not have the 'logs:read' permission."
}Behaviors are off for the organization
{
"detail": "Span Behaviors is not enabled for this organization."
}429
Rate limited. This endpoint allows 60 requests per minute per organization.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Request was throttled."
}OpenAPI source
The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.
OpenAPI operation
{
"summary": "Get behavior counts by dimension",
"operationId": "getBehaviorBreakdown",
"tags": [
"Behaviors"
],
"description": "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.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BehaviorBreakdownRequest"
},
"example": {
"behavior": "instruction_miss",
"group_by": "model",
"start_time": "2026-09-24T00:00:00Z",
"end_time": "2026-10-01T00:00:00Z",
"limit": 10
}
}
}
},
"responses": {
"200": {
"description": "Fired counts per group.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BehaviorBreakdown"
},
"example": {
"behavior": "instruction_miss",
"group_by": "model",
"groups": [
{
"group_value": "gpt-4o-mini",
"fired_spans": 61
},
{
"group_value": "claude-sonnet-4-5",
"fired_spans": 38
}
]
}
}
}
},
"400": {
"description": "`behavior` is missing or `group_by` is not supported.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "'behavior' is required"
}
}
}
},
"403": {
"description": "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.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"examples": {
"invalidKey": {
"summary": "Missing or invalid API key",
"value": {
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
},
"missingPermission": {
"summary": "Key lacks the permission",
"value": {
"detail": "This API key does not have the 'logs:read' permission."
}
},
"behaviorsOff": {
"summary": "Behaviors are off for the organization",
"value": {
"detail": "Span Behaviors is not enabled for this organization."
}
}
}
}
}
},
"429": {
"description": "Rate limited. This endpoint allows 60 requests per minute per organization.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Request was throttled."
}
}
}
}
},
"security": [
{
"RespanApiKey": []
}
]
}OpenAPI path metadata
{}Referenced OpenAPI components
{
"schemas": {
"BehaviorBreakdown": {
"type": "object",
"required": [
"behavior",
"group_by",
"groups"
],
"properties": {
"behavior": {
"type": "string",
"description": "Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`.",
"example": "instruction_miss"
},
"group_by": {
"type": "string",
"enum": [
"customer_identifier",
"deployment_name",
"environment",
"model",
"prompt_id",
"prompt_name",
"provider_id",
"status"
],
"example": "model"
},
"groups": {
"type": "array",
"description": "Groups ordered by `fired_spans`, highest first. Empty when the behavior is turned off.",
"items": {
"$ref": "#/components/schemas/BehaviorBreakdownGroup"
}
}
}
},
"BehaviorBreakdownGroup": {
"type": "object",
"required": [
"group_value",
"fired_spans"
],
"properties": {
"group_value": {
"type": "string",
"description": "Value of the `group_by` field. Spans with no value are grouped under an empty string.",
"example": "gpt-4o-mini"
},
"fired_spans": {
"type": "integer",
"description": "Spans with this value where the behavior fired.",
"example": 61
}
}
},
"BehaviorBreakdownRequest": {
"type": "object",
"required": [
"behavior",
"group_by"
],
"properties": {
"behavior": {
"type": "string",
"description": "Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`.",
"example": "instruction_miss"
},
"group_by": {
"type": "string",
"enum": [
"customer_identifier",
"deployment_name",
"environment",
"model",
"prompt_id",
"prompt_name",
"provider_id",
"status"
],
"description": "Span field to split by. `status` is the span status, such as `success` or `failed`.",
"example": "model"
},
"start_time": {
"type": "string",
"format": "date-time",
"description": "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.",
"example": "2026-09-24T00:00:00Z"
},
"end_time": {
"type": "string",
"format": "date-time",
"description": "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.",
"example": "2026-10-01T00:00:00Z"
},
"environment": {
"type": "string",
"description": "Only count spans from this environment, such as `prod` or `test`. Omit it to include every environment.",
"example": "prod"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 100,
"description": "Maximum groups to return. Values above 100 are capped at 100.",
"example": 10
}
}
}
},
"securitySchemes": {
"RespanApiKey": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Respan API key",
"description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. 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.",
"x-fern-bearer": {
"name": "respanApiKey",
"env": "RESPAN_API_KEY"
}
}
}
}