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

# Waited To Finish Events

> Track whether users leave before the LLM response completes to identify UX issues that affect downstream agent evaluations.

Waited to finish events are used to determine if users are waiting for the LLM application to finish generating a response or if they leave before it's completed. This is useful for capturing user impatience with regards to the response generation.

Since the user can simply close the window, to track this behavior, you need to send two requests: first with `finished` set as `0` to identify the output has started, and another one with `finished` set as `1` when the output finishes at client side. If `"finished": 1` is never received, LangWatch assumes the user didn't let the AI finish.

## REST API Specification

### Endpoint

`POST /api/track_event`

### Headers

* `X-Auth-Token`: Your LangWatch API key.

### Request Body

```javascript theme={null}
{
  "trace_id": "id of the message the user gave the feedback on",
  "event_type": "waited_to_finish",
  "metrics": {
    "finished": 0 // Call it with 0 on the first request, then with 1 after the messages finishes rendering
  },
  "timestamp": 1617981376000 // Unix timestamp in milliseconds
}
```

### Example

```bash theme={null}
curl -X POST "https://app.langwatch.ai/api/track_event" \\
     -H "X-Auth-Token: your_api_key" \\
     -H "Content-Type: application/json" \\
     -d '{
       "trace_id": "trace_Yy0XWu6BOwwnrkLtQh9Ji",
       "event_type": "waited_to_finish",
       "metrics": {
         "finished": 0
       },
       "timestamp": 1617981376000
     }'

curl -X POST "https://app.langwatch.ai/api/track_event" \\
     -H "X-Auth-Token: your_api_key" \\
     -H "Content-Type: application/json" \\
     -d '{
       "trace_id": "trace_Yy0XWu6BOwwnrkLtQh9Ji",
       "event_type": "waited_to_finish",
       "metrics": {
         "finished": 1
       },
       "timestamp": 1617981378000
     }'
```
