# Server-Side Events

## How It Works

Server-side events are sent via an API endpoint. The endpoint supports two types of events: `track` and `identify`. These events allow you to either update user attributes (`identify`) or register user actions (`track`).

## API Endpoint

**URL:**

```
https://karabor-harbour.usejimo.com/sse/webhook
```

**Authentication:** Pass your API key in the request headers under `x-api-key`. You can find your API key in the Jimo dashboard under [Integrations > Server-Side Events](https://i.usejimo.com/settings/integrations/sse).

## Event Types

### Identify Events

Identify events allow you to update user traits and attributes.

**Required Fields:**

* **`userId`** *(string)* – The user’s unique identifier (same as `identifyToken` used in Jimo).
* **`type`** *(string)* – Must be set to `identify`.
* **`timestamp`** *(string, ISO-8601 UTC)* – Timestamp of the event.
* **`traits`** *(object)* – Key-value pairs of attributes to update for the user.

**Example Request:**

```json
{
  "userId": "12345",
  "type": "identify",
  "timestamp": "2024-01-01T12:00:00Z",
  "traits": {
    "plan": "premium",
    "signup_date": "2023-06-15"
  }
}
```

***

### Track Events

Track events allow you to register user interactions and custom events.

**Required Fields:**

* **`userId`** *(string)* – The user’s unique identifier (same as `identifyToken` used in Jimo).
* **`type`** *(string)* – Must be set to `track`.
* **`timestamp`** *(string, ISO-8601 UTC)* – Timestamp of the event.
* **`event`** *(string)* – The name of the event being tracked.
* **`properties`** *(object, optional)* – Key-value pairs containing additional event metadata.

**Example Request:**

```json
{
  "userId": "12345",
  "type": "track",
  "timestamp": "2024-01-01T12:05:00Z",
  "event": "button_clicked",
  "properties": {
    "button_name": "Subscribe",
    "page": "pricing"
  }
}
```

## Implementation Notes

* Ensure your `userId` matches the value used in Jimo for consistent tracking.
* Use ISO-8601 UTC timestamps to avoid timezone inconsistencies.
* The `properties` field in `track` events is optional but recommended for better insights.

#### Need Help?

If you encounter any issues or have questions about integrating server-side events, feel free to contact our support team. We’ll be happy to assist you in setting up and optimizing your event tracking!
