> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true

# Algolia Insights Events

POST https://acme.captain.dev/1/events
Content-Type: application/json

Algolia Insights-compatible click, conversion and view events.

Reference: https://docs.captain.dev/reference/product-search/algolia-compatibility/algolia-insights-events

## Authentication

- `x-algolia-api-key` header (required) — A Captain key, as Algolia clients send it: a search key for queries, a write key for writes.
- `x-algolia-application-id` header (required) — Any value; the hostname selects the tenant.

## Request

### Body (application/json)

This endpoint expects an object.

- `events` (list of Event, optional)

## Response

### 200

OK

- `status` (integer, optional)
- `message` (string, optional)

## Types

### Event

- `eventType` (enum, required)
  - Allowed values: `click`, `conversion`, `view`
- `eventName` (string, required)
- `index` (string, required)
- `userToken` (string, required)
- `objectIDs` (list of string, required)
- `queryID` (string, optional)
- `positions` (list of integer, optional)
- `timestamp` (integer, optional)
- `eventSubtype` (enum, optional) — conversions only (Algolia Insights): a purchase counts toward GET .../analytics/revenue
  - Allowed values: `addToCart`, `purchase`
- `value` (EventValue, optional) — conversions only: the event's total, price times quantity summed; a number or a number as a string
- `currency` (string, optional) — conversions only: ISO 4217, such as USD
- `objectData` (list of EventObjectDataItems, optional) — conversions only: one entry per objectID, in the same order

### EventValue

conversions only: the event's total, price times quantity summed; a number or a number as a string

### EventObjectDataItems

- `price` (EventObjectDataItemsPrice, optional) — the final unit price, after any discount
- `quantity` (integer, optional)
- `discount` (EventObjectDataItemsDiscount, optional) — the discount in effect per unit, in currency (recorded, not subtracted)
- `queryID` (string, optional) — the search this item was found in, when it differs from the event's queryID

### EventObjectDataItemsPrice

the final unit price, after any discount

### EventObjectDataItemsDiscount

the discount in effect per unit, in currency (recorded, not subtracted)

## Examples

**Request**

```json
{
  "events": [
    {
      "eventType": "click",
      "eventName": "Result clicked",
      "index": "products",
      "userToken": "user-481",
      "objectIDs": [
        "sku-10482"
      ],
      "queryID": "c97e0b2a4f6d41e3a58b1c7d2e9f0a36",
      "positions": [
        1
      ]
    }
  ]
}
```

**Response**

```json
{
  "status": 200,
  "message": "OK"
}
```

**SDK Code**

```python Python REST
import json
import requests

BASE_URL = "https://acme.captain.dev"
API_KEY = "your_search_key"

headers = {
    "x-algolia-api-key": API_KEY,
    "x-algolia-application-id": "acme",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/1/events",
    headers=headers,
    json={
        "events": [
            {
                "eventType": "click",
                "eventName": "Result clicked",
                "index": "products",
                "userToken": "user-481",
                "queryID": "c97e0b2a4f6d41e3a58b1c7d2e9f0a36",
                "objectIDs": ["sku-10482"],
                "positions": [1],
            },
        ],
    },
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
```

```typescript TypeScript REST
const BASE_URL = "https://acme.captain.dev";
const API_KEY = "your_search_key";

const response = await fetch(`${BASE_URL}/1/events`, {
  method: "POST",
  headers: {
    "x-algolia-api-key": API_KEY,
    "x-algolia-application-id": "acme",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    events: [
      {
        eventType: "click",
        eventName: "Result clicked",
        index: "products",
        userToken: "user-481",
        queryID: "c97e0b2a4f6d41e3a58b1c7d2e9f0a36",
        objectIDs: ["sku-10482"],
        positions: [1],
      },
    ],
  }),
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```