> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> Named events a game reports through the OpenGame SDK, such as level_complete, totaled for the creator in Stats with no personal data in them.

Events are named moments a game reports, such as `level_complete`. You see the totals in Stats. An event has no personal data in it. A game sends events with the SDK's `og.track`.

[Authentication](https://docs.opengame.io/api-reference/authentication.md) covers each credential, and [errors](https://docs.opengame.io/api-reference/errors.md) covers the JSON error body.

## Record the game's own events

`POST https://api.opengame.gg/v1/events`

**Authentication:** A game session token.

A batch of named events with allowlisted properties. At most 200 events a request. Each event counts against per-session (600 a minute), per-player (1200) and per-address (3000) budgets; events over budget are counted in `limited` and not stored. String values that look like contact details are dropped. A malformed event is counted in `refused` without failing the rest. Traffic from datacenters and known bots is answered with `filtered: true` and not stored. A private preview's events are accepted and marked, and no rollup counts them. While OpenGame is not taking analytics events, a batch whose events include `eventId` gets 503 `analytics_unavailable` and should be kept.

### Body

Sent as `application/json`.

**events** `array of objects` *required*

At most 200 items.

**fields of each item**

**name** `string` *required*

At most 48 characters. Matches `^[a-z][a-z0-9_]*$`. Example: `level_complete`.

**props** `object`

Keys outside `level`, `mode`, `difficulty`, `score`, `duration_ms`, `result`, `step`, `board`, `fps`, `heap_mb`, `sample_rate` are dropped.

**eventId** `string (uuid)`

Send with `occurredAt`, or leave both out: an event with only one of them is rejected. The fourth group must start with 8, 9, `a` or `b`, as `crypto.randomUUID()` writes it. An ID repeated within one batch is rejected. Sending the same ID in a later batch is a retry, and the event is stored once. Example: `6c1e8a3f-5b7d-4f29-a0e4-3d9b2c7f1e85`.

**occurredAt** `string (date-time)`

At most 72 hours in the past and 60000 ms in the future. Example: `2026-10-21T14:32:08Z`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://api.opengame.gg/v1/events' \
  --header "Authorization: Bearer $OPENGAME_SESSION" \
  --header 'Content-Type: application/json' \
  --data '{
  "events": [
    {
      "name": "level_complete",
      "props": {
        "level": 3
      }
    }
  ]
}'
```

### Response 200

Accepted. `acceptedIds` names each event stored; retry the others with the same IDs. Also the answer to a batch with no valid events, and to filtered traffic with `filtered: true`.

```json theme={"system"}
{
  "accepted": 0,
  "refused": 1,
  "limited": 0,
  "acceptedIds": [],
  "filtered": true
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_body`: not a JSON object with only `events`, too many events, or too large. |
| 401 | `token_rejected`: `reason` names why. On a public game, `mint` names where a new session comes from; on a private preview, ask the page for a new session. |
| 403 | `origin_not_allowed`, `origin_mismatch`, `host_not_live`, `preview_session_mismatch` or `embed_not_allowed`, or `preview_unavailable` on a private preview. |
| 405 | `method_not_allowed`. `Allow` lists the methods this path takes, except on a private preview, which sends no `Allow`. |
| 429 | `rate_limited` with counters and `Retry-After: 60`, before anything was read. Or a body with counters and no `error`: no event fit the budgets. Wait and send the same batch again. |
| 500 | `internal_error`, sent without CORS headers, so a frame sees a failed request. Retry later. |
| 503 | `analytics_unavailable`, `rate_limit_unavailable`, `embed_unavailable`, or `not_configured` on a private preview. Nothing in the batch was accepted. Keep the events and send them again later with the same IDs. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.