# Export calls

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

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

Export the historical calls matching a filter as a downloadable CSV file. The response is a complete CSV encoded with a UTF-8 BOM so Arabic and other non-ASCII text render correctly in Excel. Accepts the same SearchCallsRequest filter body as the search and analytics endpoints. Use it to extract call data for offline reporting or import into spreadsheets and BI tools.

## Filtering

The body is a SearchCallsRequest; send only the fields you want to constrain. Everything matching the filter is exported.

- **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. Fields: `call_started_at_start`, `call_started_at_end`, `created_at_start`, `created_at_end`.
- **Scope**: agent_id, call_from, call_to, status, call_type, tags/tag, and q work exactly as in POST /api/ext/call/search. Fields: `agent_id`, `call_from`, `call_to`, `status`, `call_type`, `tags`, `tag`, `q`.
- **Analysis filters**: analysis_filters restricts by analysis values; each entry is { name, op, value }. Fields: `name`, `op`, `value`.

The endpoint returns the full filtered set as one CSV; limit/offset are not used for row windowing here. The file is UTF-8 with a BOM — open it directly in Excel for correct Arabic display.

## Authorization

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

## Body (application/json)

### Example: Minimal

Export every call created in a date range.

```json
{
  "created_at_start": "2026-06-01T00:00:00.000Z",
  "created_at_end": "2026-06-23T23:59:59.000Z"
}
```

### Example: Full

Export completed outbound calls for one agent, filtered by tag and analysis.

```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": "resolved",
      "op": "==",
      "value": "true"
    }
  ],
  "tag": "sales",
  "q": "refund"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

### 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/export' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "created_at_start": "2026-06-01T00:00:00.000Z",
  "created_at_end": "2026-06-23T23:59:59.000Z"
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/call/export"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "created_at_start": "2026-06-01T00:00:00.000Z",
    "created_at_end": "2026-06-23T23:59:59.000Z"
}

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/export", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "created_at_start": "2026-06-01T00:00:00.000Z",
    "created_at_end": "2026-06-23T23:59:59.000Z"
  }),
});

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

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "created_at_start": "2026-06-01T00:00:00.000Z",
  "created_at_end": "2026-06-23T23:59:59.000Z"
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/call/export", 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))
}
```
