# Search calls

> POST https://api.nabrah.ai/api/ext/call/search

Group: Calls. Page: https://www.nabrah.ai/en/docs/api-reference/calls/search-calls

Search historical call records with filtering and pagination. Returns a page of matching calls plus the total count. This is the primary way to discover call_ids for use with GET /api/ext/call/{call_id} and the download-link endpoint. Send only the filter fields you need; all supplied filters are combined with AND. Results describe past calls, not live ones.

## Filtering

Omit any filter you don't want to apply.

- **Time windows**: call_started_at_start / call_started_at_end filter on call start time; created_at_start / created_at_end filter on record creation time. ISO-8601 timestamps. Fields: `call_started_at_start`, `call_started_at_end`, `created_at_start`, `created_at_end`.
- **Scope**: agent_id restricts to one agent (from GET /api/ext/agent); call_from / call_to filter by number; status filters by lifecycle state (queued, ringing, in-progress, completed, failed); call_type filters inbound vs outbound; call_id fetches a specific record. Fields: `agent_id`, `call_from`, `call_to`, `status`, `call_type`, `call_id`.
- **Tags and free text**: tags matches any of the listed tags; tag is a single-tag shortcut; q is a free-text search over call content. Fields: `tags`, `tag`, `q`.
- **Analysis filters**: analysis_filters narrows by post-call analysis values; each entry is { name, op, value } with op such as ==, !=, >, <. Fields: `name`, `op`, `value`.

## Pagination

- **limit / offset**: limit caps the number of returned rows; offset skips that many. Page through by increasing offset until offset reaches total_count. Fields: `limit`, `offset`.

## Response shape (SearchCallsResponse)

The 200 body contains a page of summary rows plus paging metadata.

- **calls[]**: Summary rows (id, call_from, call_to, call_type, status, timing, agent_id, agent_name, tags). For the full transcript/analysis of a row, call GET /api/ext/call/{call_id} with its id. Fields: `id`, `call_from`, `call_to`, `call_type`, `status`, `duration`, `call_started_at`, `call_ended_at`, `agent_id`, `agent_name`, `tags`.
- **total_count / limit / offset**: total_count is the count of all matching calls; limit and offset echo the applied paging. Fields: `total_count`, `limit`, `offset`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (application/json)

### Example: Recent calls

First page of the most recent calls.

```json
{
  "limit": 25,
  "offset": 0
}
```

### Example: Full filter

All filters for one agent's completed outbound calls in a date range.

```json
{
  "agent_id": "00000000-0000-4000-8000-000000000000",
  "call_to": "+966500000000",
  "call_from": "+966510000000",
  "call_started_at_start": "2026-06-01T00:00:00.000Z",
  "call_started_at_end": "2026-06-23T23:59:59.000Z",
  "status": "completed",
  "call_type": "outbound",
  "created_at_start": "2026-06-01T00:00:00.000Z",
  "created_at_end": "2026-06-23T23:59:59.000Z",
  "tags": [
    "sales"
  ],
  "analysis_filters": [
    {
      "name": "sentiment",
      "op": "==",
      "value": "positive"
    }
  ],
  "tag": "sales",
  "q": "appointment",
  "limit": 50,
  "offset": 0
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "calls": [
    {
      "id": "00000000-0000-4000-8000-000000000000",
      "created_at": "2026-01-15T12:00:00.000Z",
      "call_from": "string",
      "call_to": "string",
      "call_type": "inbound",
      "status": "queued",
      "updated_at": "2026-01-15T12:00:00.000Z",
      "duration": 0,
      "call_started_at": "2026-01-15T12:00:00.000Z",
      "call_ended_at": "2026-01-15T12:00:00.000Z",
      "agent_id": "00000000-0000-4000-8000-000000000000",
      "agent_name": "string",
      "tags": [
        "string"
      ]
    }
  ],
  "total_count": 0,
  "limit": 0,
  "offset": 0
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/call/search' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "limit": 25,
  "offset": 0
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/call/search"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "limit": 25,
    "offset": 0
}

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/call/search", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "limit": 25,
    "offset": 0
  }),
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "limit": 25,
  "offset": 0
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/call/search", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
