# Event format

> The wire format of one analytics event, the naming and property rules, and every reserved $ event with the properties it requires.

Every item in the `events` array of [`POST /v1/ingest`](https://docs.bloxlytics.app/api/ingest/send-events) is one event in this format. Events are checked twice: once when the batch arrives (the [field rules](#fields), where a failure counts towards `rejected` in the response), and again while the batch is processed (the [reserved event](#reserved-events) and [custom event](#custom-events) rules, where a failure is listed under **Recent problems** in the project's SDK debugger).

If you use the Luau SDK you never build events by hand. [Event reference](https://docs.bloxlytics.app/sdk/event-reference) shows which SDK call sends each one.

## Fields

```json
{
  "id": "A2B3C4D5-E6F7-4890-A1B2-C3D4E5F60718",
  "name": "PetHatched",
  "ts": 1767225612.5,
  "userId": 1,
  "sessionId": "0B7E4D2A-1C3F-4A5B-8D9E-6F7A8B9C0D1E",
  "props": { "PetName": "Dragon", "EggCost": 500, "Shiny": false }
}
```

| Field | Type | Required | Rules |
| --- | --- | --- | --- |
| `id` | string | Yes | 8 to 64 characters. Unique per event; used to [deduplicate retries](https://docs.bloxlytics.app/api/ingest/send-events#deduplication) for 48 hours. |
| `name` | string | Yes | 1 to 64 characters on the wire. Must then be a [reserved name](#reserved-events) or a valid [custom name](#custom-events). |
| `ts` | number | Yes | Unix time in seconds, greater than `0`. Fractions allowed. |
| `userId` | integer | Depends | The player's Roblox user id: a positive whole number no larger than 9,007,199,254,740,991. Required for reserved player events. |
| `sessionId` | string | No | Up to 64 characters. Ties a player's events to one visit to one server. |
| `props` | object | No | Flat properties; see [Properties](#properties). |

### Time

- `ts` more than 5 minutes ahead of Bloxlytics' clock is replaced with the time the batch arrived. The event is kept.
- `ts` more than 30 days in the past is rejected with `timestamp older than 30 days`.
- Times are stored to the millisecond, in UTC.

### Sessions

A session is one player's visit to one server. The SDK creates a `sessionId` when a player joins, sends `$session_start`, puts the same `sessionId` on that player's events, and sends `$session_end` with the same id when they leave. Session length is computed from these pairs. When `$session_end` arrives without a known start, the start is worked out from its `duration`.

Events without a `sessionId` are still stored; they just aren't tied to a visit.

## Properties

`props` is a flat JSON object.

| Rule | Limit |
| --- | --- |
| Number of keys | At most 32 |
| Key | Starts with a letter or `_`, then letters, digits, spaces, `_`, `.` or `-`. 1 to 40 characters. |
| Value | A string, a finite number, `true`/`false`, or `null` |
| String length on the wire | Up to 4,096 characters |
| String length stored, custom events | Up to 256 characters. Longer strings are cut, not rejected. |
| Nesting | Not allowed. Objects and arrays as values are rejected. |

An empty array (`[]`) as `props` is treated as no properties, because `HttpService:JSONEncode` encodes an empty Luau table as `[]`.

A key that breaks the rules fails the whole event at the wire stage (message `Invalid key in record`), as does a 33rd key (`At most 32 properties per event`). The Luau SDK drops bad keys and keeps the first 32 before sending, with a warning in the output, so its events don't fail this way.

## Custom events

Any name that doesn't start with `$` is a custom event. The name must match:

```text
^[A-Za-z][A-Za-z0-9_ .:\-]{0,63}$
```

That is: start with a letter, then up to 63 more letters, digits, spaces, `_`, `.`, `:` or `-`. Names are case-sensitive: `PetHatched` and `pethatched` are different events.

A custom event is discarded while processing if:

- the name doesn't match (`Invalid event name "<name>"`),
- custom events are turned off in the project's SDK configuration (`custom events disabled`), or
- the name is listed under **Blocked events** (`blocked`).

`userId` is optional on custom events. Without it, the event counts towards totals but not towards any player.

## Reserved events

Names starting with `$` are reserved. Only the names below are accepted; any other `$` name is discarded with `Unknown reserved event <name>`.

Each reserved event's `props` are checked against its definition. Properties the definition doesn't list are dropped (except on `$server_stop`, which keeps whatever it's sent). All reserved events except the three `$server_*` events also need `userId`; without it the event is discarded with `<name> requires userId`.

| Event | Shown as | Category | Needs `userId` |
| --- | --- | --- | --- |
| `$session_start` | Joined game | session | Yes |
| `$session_end` | Left game | session | Yes |
| `$server_start` | Server started | server | No |
| `$server_heartbeat` | Server heartbeat | server | No |
| `$server_stop` | Server stopped | server | No |
| `$economy` | Currency changed | economy | Yes |
| `$economy_transfer` | Currency transferred | economy | Yes |
| `$balance` | Balance snapshot | economy | Yes |
| `$purchase` | Purchase | purchase | Yes |
| `$funnel` | Funnel step | funnel | Yes |
| `$progression` | Progression | progression | Yes |
| `$property` | Property set | property | Yes |
| `$experiment_exposure` | Experiment exposure | experiment | Yes |

Turning off **session**, **economy** or **purchase** tracking in the project's SDK configuration discards every event in that category.

### $session_start

A player joined the server.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `username` | string | Yes | Up to 40 characters. Used as the player's name across Bloxlytics. |
| `displayName` | string | No | Up to 40 characters |
| `accountAge` | integer | No | Account age in days, `0` or more |
| `premium` | boolean | No | Whether the player has Roblox Premium |
| `locale` | string | No | Up to 16 characters, for example `en-us` |
| `country` | string | No | Up to 8 characters. ISO 3166-1 alpha-2 country or region, as Roblox reports it. |
| `teleported` | boolean | No | Whether the player arrived by teleport from another place |

### $session_end

A player left the server.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `duration` | number | Yes | Seconds in the session, `0` or more |

### $server_start

A server started. Sent once per server, without `userId`.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `maxPlayers` | integer | No | `0` or more |
| `tags` | string | No | Up to 2,048 characters. A JSON object of [server tags](#server-tags), encoded as a string. |
| `studio` | boolean | No | `true` for a Studio session |

### $server_heartbeat

A live server reporting in. The SDK sends one every 30 seconds. A server counts as online for 90 seconds after the last heartbeat (or bridge poll).

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `playerCount` | integer | Yes | Players in the server, `0` or more |
| `maxPlayers` | integer | No | `0` or more |
| `players` | string | No | Up to 4,096 characters. The user ids in the server, separated by commas, for example `"1,2,3"`. Properties are flat, so this is a string, not an array. |
| `bridge` | boolean | No | `true` when the Cmdr bridge is running on this server |
| `tags` | string | No | Up to 2,048 characters. JSON object of [server tags](#server-tags), as a string. |
| `studio` | boolean | No | `true` for a Studio session |

Heartbeats aren't shown in the live event feed.

### $server_stop

The server is shutting down. Takes no required properties and keeps any it's sent. The server is removed from the live server list.

### $economy

A player gained (source) or spent (sink) an amount of an in-game currency.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `currency` | string | Yes | 1 to 32 characters. If the project lists currencies, it must be one of them (case-insensitive). |
| `amount` | number | Yes | Finite number |
| `flow` | string | Yes | `source` or `sink` |
| `category` | string | No | Up to 64 characters. Where it came from or went, for example `Quest` or `Shop`. |
| `item` | string | No | Up to 64 characters. What was bought or earned. |
| `balance` | number | No | The player's balance afterwards, finite |

If the project lists currencies under **Currencies** and this one isn't among them, the event is discarded with `Unknown currency "<currency>" — add it in SDK settings`. With no currencies listed, any currency is accepted. The same rule applies to `$economy_transfer` and `$balance`.

### $economy_transfer

A player gave currency to another player.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `currency` | string | Yes | 1 to 32 characters |
| `amount` | number | Yes | Greater than `0` |
| `toUserId` | integer | Yes | The receiving player's user id, a positive whole number |
| `reason` | string | No | Up to 64 characters |

The event's own `userId` is the sender.

### $balance

A snapshot of a player's balance. Not shown in the live event feed.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `currency` | string | Yes | 1 to 32 characters |
| `balance` | number | Yes | Finite number |

### $purchase

A Robux purchase attempt or completion.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `kind` | string | Yes | `developer_product`, `gamepass` or `premium` |
| `productId` | integer | Yes | `0` or more. The developer product or game pass id. |
| `productName` | string | No | Up to 64 characters |
| `robux` | integer | No | Price paid in Robux, `0` or more |
| `status` | string | Yes | `attempted`, `completed` or `failed` |
| `receiptId` | string | No | Up to 64 characters. The `PurchaseId` from `ProcessReceipt`. |

A `completed` purchase of a developer product or game pass also adds that product to the project's product list, if it isn't there already, using `productName` (or `Product <id>` / `Game pass <id>`) and `robux` as the price.

### $funnel

A player reached a step in a funnel.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `funnel` | string | Yes | 1 to 64 characters, for example `Tutorial` |
| `step` | string | Yes | 1 to 64 characters, for example `Opened shop` |
| `stepIndex` | integer | No | `0` or more. Keeps steps in order in the funnel builder. |

### $progression

A player started, completed or failed a piece of progression.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `status` | string | Yes | `start`, `complete` or `fail` |
| `path` | string | Yes | 1 to 128 characters, for example `World1/Level3` |
| `score` | number | No | Finite number |

### $property

Sets a property on the player, such as `Level`, `VIP` or `Role`.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `key` | string | Yes | The property name. Same rule as a `props` key: a letter or `_`, then letters, digits, spaces, `_ . -`, up to 40 characters. |
| `value` | string, number, boolean or null | Yes | Strings up to 256 characters |

### $experiment_exposure

A player was shown a variant of an experiment. The SDK sends it once per experiment per session, the first time `GetVariant` returns a variant.

| Property | Type | Required | Rules |
| --- | --- | --- | --- |
| `experiment` | string | Yes | Up to 64 characters. The experiment key. |
| `variant` | string | Yes | Up to 64 characters. The variant key. |

## Server tags

The `tags` property on `$server_start` and `$server_heartbeat` is a JSON object encoded as a string, for example `"{\"map\":\"Forest\",\"mode\":\"Ranked\"}"`.

| Rule | Limit |
| --- | --- |
| Number of tags | At most 16 |
| Tag name | Starts with a letter, then letters, digits, spaces, `_`, `.` or `-`. 1 to 32 characters. |
| Tag value | A string, up to 64 characters |

If the string isn't valid JSON or breaks any of these rules, the event is still accepted and the server is treated as having no tags. The Cmdr bridge sends the same tags as a plain object; see [Poll for commands](https://docs.bloxlytics.app/api/bridge/poll).
