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

# Send Events

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

Send click, conversion and view events, up to 1,000 per request.

Reference: https://docs.captain.dev/reference/product-search/analytics/send-events

## Authentication

- `Authorization` header (bearer token, required) — A search key, issued by Captain. Sent as Authorization: Bearer \<key>.
- `Authorization` header (bearer token, required) — A scoped key for one end user, minted from an issuer key that Captain issues. Sent as Authorization: Bearer \<key>.

## Request

### Body (application/json)

This endpoint expects an object.

- `events` (list of Event, optional)

## Response

### 200

accepted

- `accepted` (integer, optional) — events recorded

## 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": "7f3a9c2e4b1d48e6a0c5d2f18b93e470",
      "positions": [
        1
      ]
    }
  ]
}
```

**Response**

```json
{
  "accepted": 1
}
```

**SDK Code**

```python Python REST
import json
import requests

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

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/v1/events",
    headers=headers,
    json={
        "events": [
            {
                "eventType": "click",
                "eventName": "Result clicked",
                "index": "products",
                "userToken": "user-481",
                "queryID": "7f3a9c2e4b1d48e6a0c5d2f18b93e470",
                "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}/v1/events`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    events: [
      {
        eventType: "click",
        eventName: "Result clicked",
        index: "products",
        userToken: "user-481",
        queryID: "7f3a9c2e4b1d48e6a0c5d2f18b93e470",
        objectIDs: ["sku-10482"],
        positions: [1],
      },
    ],
  }),
});

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