> For the complete documentation index, see [llms.txt](https://docs.wonderchat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wonderchat.io/api-reference/export-chatlogs.md).

# Export Chatlogs

Export conversation data from your chatbot(s) for analysis, reporting, or compliance purposes.

## Steps:

1. Go to chatlogs

<figure><img src="/files/obsx7xA8D184NCG8SPW4" alt=""><figcaption></figcaption></figure>

2. Select the chatbot you want to export the information.

<figure><img src="/files/as1ZOeIxR4gq9YEFhw3c" alt=""><figcaption></figcaption></figure>

3. Click export, select the fields you want to export and click export again.

<figure><img src="/files/5Tp3DvEjscPHlbb9GVHH" alt=""><figcaption></figcaption></figure>

## Export via API

You can also export chatlogs programmatically.

### Endpoint

```
POST https://app.wonderchat.io/api/v1/export-chatlogs
```

{% hint style="info" %}
Your API key goes in the **request body**, not in an `Authorization` header.
{% endhint %}

### Request Parameters

| Parameter         | Type    | Required | Default | Description                                                                   |
| ----------------- | ------- | -------- | ------- | ----------------------------------------------------------------------------- |
| `apiKey`          | string  | ✅ Yes    | —       | Your API key                                                                  |
| `chatbotId`       | string  | No       | —       | Restrict to one chatbot. Omit to export from every chatbot the key can access |
| `startDate`       | string  | No       | —       | Inclusive lower bound, e.g. `2026-01-01`                                      |
| `endDate`         | string  | No       | —       | Inclusive upper bound                                                         |
| `limit`           | integer | No       | `500`   | Chatlogs per page. Must be between 1 and 1000                                 |
| `cursor`          | string  | No       | —       | The `nextCursor` from the previous response. Omit for the first page          |
| `includeMessages` | boolean | No       | `true`  | Set to `false` to omit message transcripts and return metadata only           |

Date filtering matches a chatlog if **either** its `createdAt` **or** its `lastMessageAt` falls within the range — so a conversation that started before `startDate` but was still active during the window is included.

### Example Request

```bash
curl --location --request POST 'https://app.wonderchat.io/api/v1/export-chatlogs' \
--header 'Content-Type: application/json' \
--data-raw '{
  "apiKey": "YOUR_API_KEY",
  "chatbotId": "YOUR_CHATBOT_ID",
  "limit": 500
}'
```

### Response Format

```json
{
  "chatlogs": [
    {
      "id": "clx...",
      "createdAt": "2026-07-17T13:48:53.741Z",
      "chatbotId": "cmr...",
      "userEmail": null,
      "userPhoneNumber": null,
      "userName": null,
      "countryCode": "SG",
      "userFeedback": null,
      "averageConfidence": 0.92,
      "aiResolutionState": "RESOLVED",
      "isEscalatedToLiveSupport": false,
      "initialPageUrl": "https://example.com/pricing",
      "mostRecentPageUrl": "https://example.com/contact",
      "type": "WEBAPP",
      "messages": [
        {
          "userMessage": "Do you offer annual billing?",
          "botMessage": "Yes — annual plans save 20%.",
          "createdAt": "2026-07-17T13:49:02.113Z"
        }
      ]
    }
  ],
  "hasMore": true,
  "nextCursor": "clx..."
}
```

Chatlogs are returned newest first, and messages within a chatlog oldest first. The `messages` field is absent when `includeMessages` is `false`.

| Field        | Description                                                                 |
| ------------ | --------------------------------------------------------------------------- |
| `chatlogs`   | Up to `limit` chatlogs                                                      |
| `hasMore`    | `true` if more chatlogs match beyond this page                              |
| `nextCursor` | Pass this as `cursor` on the next request. `null` when `hasMore` is `false` |

### Paging Through a Full Export

A single response returns at most `limit` chatlogs. To retrieve everything, keep requesting with the previous response's `nextCursor` until `hasMore` is `false`.

```javascript
const all = [];
let cursor;

do {
  const res = await fetch("https://app.wonderchat.io/api/v1/export-chatlogs", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ apiKey, chatbotId, limit: 500, cursor }),
  });
  const page = await res.json();
  all.push(...page.chatlogs);
  cursor = page.nextCursor;
} while (cursor);
```

Do not assume a fixed number of pages — always loop until `nextCursor` is `null`.

### Errors

Errors are returned as `{"error": "<message>"}`.

| Status | Cause                                                                      |
| ------ | -------------------------------------------------------------------------- |
| `400`  | `limit` out of range, or the request failed. The `error` field has details |
| `403`  | Missing or invalid `apiKey`, or the key lacks access to the `chatbotId`    |
| `405`  | A method other than `POST` was used                                        |

### Access Requirements

* The chatbot owner must be on a **paid plan (Lite or above)**. Free and Mini accounts receive `403`.
* The key must belong to the chatbot's owner, its workspace/team, or a team member with the **ADMIN** role.
* Keys scoped to selected chatbots can only reach those chatbots.

### Troubleshooting

**`error code: 1010`** — Cloudflare blocked the request before it reached the API, usually because of a default library `User-Agent`. Set a normal browser or application User-Agent on your HTTP client. (`curl` and browser `fetch` work as-is; bare `python-urllib` does not.)

## Use Cases

* **Analytics**: Analyze conversation patterns and user behavior
* **Compliance**: Export data for regulatory requirements
* **Training**: Use conversations to improve chatbot responses
* **Reporting**: Generate customer service reports
* **Integration**: Sync conversation data with CRM systems
