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

# Export experiment logs

Exports experiment logs to CSV/Excel format. The export is processed asynchronously and a download link is sent to your email.

## Authentication

* API key: `Authorization: Bearer <API key>`

## Path Parameters

<ParamField path="experiment_id" type="string" required>
  The ID of the experiment to export logs from.
</ParamField>

## Query Parameters

<ParamField query="export" type="string" required>
  Set to `1` or `true` to trigger export.
</ParamField>

<ParamField query="page" type="integer" required={false}>
  Page number (default: 1).
</ParamField>

<ParamField query="page_size" type="integer" required={false}>
  Number of results per page (default: 100).
</ParamField>

<ParamField query="sort_by" type="string" required={false}>
  Sort field (e.g., "-cost", "-start\_time", "name").
</ParamField>

<ParamField query="start_time" type="string" required={false}>
  Filter start time (ISO format).
</ParamField>

<ParamField query="end_time" type="string" required={false}>
  Filter end time (ISO format).
</ParamField>

## POST Request Body (Optional)

For advanced filtering, you can send a POST request with filters in the body:

<RequestExample>
  ```json Request theme={"system"}
  {
    "filters": [
      {
        "field": "status",
        "operator": "=",
        "value": "completed"
      },
      {
        "field": "comparison_key",
        "operator": "in",
        "value": ["key1", "key2"]
      }
    ]
  }
  ```
</RequestExample>

## Examples

<CodeGroup>
  ```python Python theme={"system"}
  import requests

  experiment_id = "experiment_id_123"
  url = f"https://api.keywordsai.co/api/v2/experiments/{experiment_id}/logs/"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  # GET request with export parameter
  params = {
      "export": "1",
      "start_time": "2025-01-01T00:00:00Z",
      "end_time": "2025-01-31T23:59:59Z"
  }
  response = requests.get(url, headers=headers, params=params)
  print(response.json())
  ```

  ```bash cURL theme={"system"}
  curl -X GET "https://api.keywordsai.co/api/v2/experiments/{experiment_id}/logs/?export=1&start_time=2025-01-01T00:00:00Z&end_time=2025-01-31T23:59:59Z" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```
</CodeGroup>

## Response

<ResponseExample>
  ```json 202 Accepted theme={"system"}
  {
    "message": "Exporting experiment logs. Check your email for the download link."
  }
  ```
</ResponseExample>

**Export Features:**

* Supports all filtering options (query params and POST body filters)
* Includes all trace data: input, output, metrics, metadata
* Async processing for large datasets
* Email notification with download link
* CSV and Excel format options

**Notes:**

* Export is processed asynchronously
* You will receive an email with the download link when the export is ready
* Large datasets may take several minutes to process
* All standard filtering parameters are supported
