> ## Documentation Index
> Fetch the complete documentation index at: https://graine.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Export Batch CSV

> Download all contacts and call outcomes as a CSV file

## Endpoint

**GET** `https://api.graine.ai/api/v1/batches/{batch_id}/export.csv`

Downloads all contacts in a batch as a CSV file. The file includes every `call_variables` key from the uploaded contact data plus operational result columns.

## Path Parameters

| Parameter  | Type   | Required | Description     |
| ---------- | ------ | -------- | --------------- |
| `batch_id` | string | Yes      | Batch to export |

## Headers

| Header          | Required | Description          |
| --------------- | -------- | -------------------- |
| `Authorization` | Yes      | `Bearer gat_<token>` |

## Response

**Content-Type:** `text/csv`

The CSV columns are dynamic — the contact data columns come from the `call_variables` keys you uploaded.

### Fixed columns (always present)

| Column                  | Description                               |
| ----------------------- | ----------------------------------------- |
| `phone_number`          | E.164 phone number                        |
| `status`                | Final contact status                      |
| `retry_count`           | Number of retry attempts                  |
| `follow_up_count`       | Number of follow-up calls                 |
| `last_attempted_at`     | Timestamp of last call attempt            |
| `next_retry_at`         | When next retry fires (empty if terminal) |
| `last_call_status`      | Outcome of the most recent call attempt   |
| `last_execution_id`     | Execution ID of the most recent call      |
| `last_completed_at`     | Completion timestamp of most recent call  |
| `last_duration_seconds` | Call duration in seconds                  |
| `last_recording_url`    | Recording URL (if available)              |
| `last_hangup_by`        | Who ended the call: `assistant` or `user` |
| `last_hangup_reason`    | Hangup reason string                      |
| `last_total_cost`       | Cost in USD                               |
| `last_summary`          | AI-generated call summary                 |

### Dynamic columns (from your data)

The columns from `call_variables` of your contacts are also included. For example, if your contacts have `callee_name`, `current_plan`, `renewal_date`, and `premium` in their `call_variables`, those four columns appear in the CSV as well.

### Example CSV

```csv theme={null}
phone_number,callee_name,current_plan,renewal_date,premium,status,retry_count,last_call_status,last_duration_seconds,last_summary
+919876543210,Rajesh Sharma,Basic Health,2026-07-01,12000,completed,1,completed,142,"Customer interested in Family Floater upgrade"
+919876543211,Priya Mehta,Family Floater,2026-06-15,28000,no_answer,3,no-answer,0,
```

## Example Request

```bash theme={null}
curl "https://api.graine.ai/api/v1/batches/btc_xyz001/export.csv" \
  -H "Authorization: Bearer gat_your_token" \
  --output batch_results.csv
```

```python theme={null}
import requests

url = "https://api.graine.ai/api/v1/batches/btc_xyz001/export.csv"
headers = { "Authorization": "Bearer gat_your_token" }

response = requests.get(url, headers=headers)
with open("batch_results.csv", "wb") as f:
    f.write(response.content)
print("Downloaded batch_results.csv")
```

<Tip>
  Export is available at any time — even mid-batch. Contacts still in-flight will show their current status (e.g. `pending`, `dispatched`).
</Tip>
