> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/behaviors/list-spans-where-behavior-fired/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # List spans where a behavior fired POST https://api.respan.ai/api/pulses/behaviors/logs/ Content-Type: application/json Lists the spans in a time range where one behavior fired, newest first. Use the span IDs with Get a span for the full request and response. Reference: https://respan.ai/docs/apis/behaviors/list-spans-where-behavior-fired ## 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 BehaviorSpansRequest. - `behavior` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. - `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. - `page` (integer, optional, default: 1) — Page number, starting at 1. - `page_size` (integer, optional, default: 100) — Spans per page. Values above 1000 are capped at 1000. ## Response ### 200 A page of spans. - `behavior` (string, required) — Behavior key: a built-in behavior's name (for example `refusal`) or a custom behavior's `id`. - `page` (integer, required) - `page_size` (integer, required) - `logs` (list of BehaviorSpan, required) — Spans where the behavior fired, newest first. Fewer than `page_size` items means this is the last page. Empty when the behavior is turned off. ## Errors ### 400 Bad Request Error `behavior` is missing. - `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 ### BehaviorSpan - `unique_id` (string, required) — Span ID. Pass it to Get a span (`GET /api/request-logs/{unique_id}/`). - `model` (string, required) — Model the span used. - `status` (string, required) — Span status, such as `success` or `failed`. - `environment` (string, required) — Span environment. - `timestamp` (string, required) — Span timestamp. UTC, ISO 8601 without a timezone suffix. ## Examples **Request** ```json { "behavior": "refusal", "start_time": "2026-09-30T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "page": 1, "page_size": 50 } ``` **Response** ```json { "behavior": "refusal", "page": 1, "page_size": 50, "logs": [ { "unique_id": "c3a1f8e2b9d04e6f8a7b5c4d3e2f1a0b", "model": "gpt-4o-mini", "status": "success", "environment": "prod", "timestamp": "2026-09-30T14:22:05.381204" } ] } ``` **SDK Code** ```python Behaviors_listBehaviorSpans_example import requests url = "https://api.respan.ai/api/pulses/behaviors/logs/" payload = { "behavior": "refusal", "start_time": "2026-09-30T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "page": 1, "page_size": 50 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Behaviors_listBehaviorSpans_example const url = 'https://api.respan.ai/api/pulses/behaviors/logs/'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"behavior":"refusal","start_time":"2026-09-30T00:00:00Z","end_time":"2026-10-01T00:00:00Z","page":1,"page_size":50}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Behaviors_listBehaviorSpans_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/pulses/behaviors/logs/" payload := strings.NewReader("{\n \"behavior\": \"refusal\",\n \"start_time\": \"2026-09-30T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"page\": 1,\n \"page_size\": 50\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_listBehaviorSpans_example require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/pulses/behaviors/logs/") 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\": \"refusal\",\n \"start_time\": \"2026-09-30T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"page\": 1,\n \"page_size\": 50\n}" response = http.request(request) puts response.read_body ``` ```java Behaviors_listBehaviorSpans_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/pulses/behaviors/logs/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"behavior\": \"refusal\",\n \"start_time\": \"2026-09-30T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"page\": 1,\n \"page_size\": 50\n}") .asString(); ``` ```php Behaviors_listBehaviorSpans_example request('POST', 'https://api.respan.ai/api/pulses/behaviors/logs/', [ 'body' => '{ "behavior": "refusal", "start_time": "2026-09-30T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "page": 1, "page_size": 50 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Behaviors_listBehaviorSpans_example using RestSharp; var client = new RestClient("https://api.respan.ai/api/pulses/behaviors/logs/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"behavior\": \"refusal\",\n \"start_time\": \"2026-09-30T00:00:00Z\",\n \"end_time\": \"2026-10-01T00:00:00Z\",\n \"page\": 1,\n \"page_size\": 50\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Behaviors_listBehaviorSpans_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "behavior": "refusal", "start_time": "2026-09-30T00:00:00Z", "end_time": "2026-10-01T00:00:00Z", "page": 1, "page_size": 50 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/pulses/behaviors/logs/")! 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() ```