# Events API overview

> Endpoint, authentication, headers, event categories and ID management of the Segmentify Events API.

This section covers the requests needed to integrate with the **Segmentify RESTful API**. It covers the full range of trackable user interactions on your website or app, enabling Segmentify to personalize recommendations, power search, and attribute campaign conversions.

---

## Authentication & Configuration

All requests require two account-specific variables, which you can find under **Settings > Integrations** in the Segmentify Panel:

| Variable | Description |
|---|---|
| `{apikey}` | Your unique Segmentify API key |
| `{dataCenterUrl}` | Your account's data center subdomain (e.g. `xxx` in `https://xxx.segmentify.com`) |

**Endpoint format:**
```
https://{dataCenterUrl}.segmentify.com/add/events/v1.json?apiKey={apikey}
```

**Required headers for all requests:**

| Header | Value |
|---|---|
| `Content-Type` | `application/json` |
| `Accept` | `application/json` |
| `Origin` | Your domain |

Request bodies must be valid **JSON arrays**, and multiple events can be batched in a single request.

---

## Event Categories

### 📄 Page View
Tracks user visits across key pages of your site: **Home**, **Category**, **Product Detail**, **Basket**, **Checkout Success**, and other custom pages. These events drive page-level personalization and behavioral analytics.

### 🛒 Basket Operations
Covers add-to-basket, remove-from-basket, and basket view actions, allowing Segmentify to track cart activity and trigger relevant recommendations.

### 🏁 Checkout
Tracks the **View Basket** and **Checkout Success** steps to measure conversions and attribute revenue.

### 🔍 Search
A comprehensive set of events covering the full search lifecycle — queries, results, impressions (including after-search), clicks, and Searchandising interactions — enabling Segmentify's intelligent search and merchandising features.

### 👁️ Product View
Captures product detail page views to feed product-level recommendation engines.

### ❤️ Wishlist Events
Tracks when users add, remove, or view items in their wishlist/favorites.

### 🖱️ Widget Interaction
Records user interactions with Segmentify recommendation widgets (impressions, clicks, and conversions).

### 📲 Push
Handles push notification campaign attribution, including subscription, unsubscription, and interaction tracking for notifications triggered by Segmentify.

### 📧 Email
Tracks email campaign attribution — open, click, and conversion events for emails sent through Segmentify.

### ⚙️ Custom Event
Allows sending fully custom events for any interaction not covered by the standard event types.

---

> **Tip:** You can send multiple events in a single request by including them as elements in the JSON array body.

---

## API Errors

If the response body contains a `statusCode` field, your request encountered an error. The table below describes all possible error codes:

| Error Code | Description |
|---|---|
| `NO_API_KEY` | Your request is missing the `apiKey` parameter. Provide your account's unique API key as a query parameter. |
| `NO_ACCOUNT` | The given API key is not associated with any Segmentify account. Check that your `{apikey}` value is correct. |
| `FAILED_ACCOUNT` | The account associated with the API key is inactive. Contact the Segmentify support team to re-activate your account. |
| `NO_DOMAIN_APIKEY_MATCH` | Each Segmentify account is tied to a specific domain. Ensure you are sending the correct `Origin` header matching your registered domain. |
| `NO_EVENT` | The request body contains no events. At least one event must be included in the JSON array. |
| `INVALID_EVENT` | The event format is not acceptable. Check the structure of your event objects against the expected schema. |
| `NO_USERID` | Every event must include a `userId` parameter. At least one event in the request is missing this field. |
| `NO_SESSIONID` | Every event must include a `sessionId` parameter. At least one event in the request is missing this field. |
| `BAD_INPUT` | The request body is not a valid JSON array of Segmentify events. Validate your JSON for syntax errors. |

---

## User & Session Management

Every Segmentify event must include a `userId` and a `sessionId` to uniquely identify the user and their current visit session.

### Generating IDs via Segmentify

You can generate IDs by making a `GET` request to the following endpoint:

```
GET https://{dataCenterUrl}.segmentify.com/get/key?count=<NUMBER_OF_KEYS>
```

| `count` value | Use case |
|---|---|
| `1` | Generate a `sessionId` only |
| `2` | Generate both `userId` and `sessionId` |

**Example requests:**
```
GET https://{dataCenterUrl}.segmentify.com/get/key?count=1
GET https://{dataCenterUrl}.segmentify.com/get/key?count=2
```

**Example response** (for `count=2`):
```json
["XXXXXXXXXXXXXXXXXXXXXXX", "YYYYYYYYYYYYYYYYYYYY"]
```

The response is a plain JSON array. The first element can be used as the `userId` and the second as the `sessionId`.

### Using Your Own IDs

Alternatively, you can generate and manage your own unique IDs. These can be any string value, as long as they are:
- **Unique per user** for `userId`
- **Unique per visit/session** for `sessionId`

> **Tip:** A common approach is to persist `userId` in a long-lived cookie and generate a fresh `sessionId` at the start of each browser session.

## API reference

Every request on these pages can be sent from the [Events API reference](/reference/events/).
