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

# Track with the HTTP API

> Send events to Audience from your game server, your backend or a game on any engine.

Send events to Audience over HTTP from your game server, your backend, or a game built on an engine without an SDK.

## Before you start

* Your project's publishable key, from **Game Analytics** > **Connect your game** or **Settings** > **General** in Audience. It starts with `pk_imapik-`.
* The player's consent, recorded before you send their events. The HTTP API doesn't check consent for you. See [Consent](#consent).

## Send events

Send `POST` requests to `https://api.immutable.com/v1/audience/messages`, with your key in the `x-immutable-publishable-key` header. Each request carries up to 100 messages.

```bash theme={null}
curl -X POST https://api.immutable.com/v1/audience/messages \
  -H "Content-Type: application/json" \
  -H "x-immutable-publishable-key: YOUR_PUBLISHABLE_KEY" \
  -d '{
    "messages": [{
      "type": "track",
      "messageId": "550e8400-e29b-41d4-a716-446655440000",
      "eventTimestamp": "2026-12-04T12:00:00Z",
      "eventName": "purchase",
      "userId": "user-123",
      "anonymousId": "anon-device-abc123",
      "surface": "unity",
      "properties": { "currency": "USD", "value": "9.99" },
      "context": { "library": "YOUR_SYSTEM_NAME", "libraryVersion": "1.0.0" }
    }]
  }'
```

* `messageId` is a UUID you generate for each message. Audience uses it to drop duplicates, so reuse it when you retry.
* `anonymousId` identifies the device. Use the same one across a player's requests to join up their activity.
* `userId` identifies the player. Send it only at `full` consent.
* `surface` says where the event came from: `unity` or `unreal` for events from a game, `web` for website traffic. **Game Analytics** counts only `unity` and `unreal`, so an event sent as `web`, or with no `surface`, is stored but doesn't show there.
* `context.library` names your system, such as `my-game-server`. Don't use `@imtbl/audience` or `com.immutable.audience`: those belong to the SDKs.

## Read the response

```json theme={null}
{
  "success": true,
  "accepted": 1,
  "rejected": 0,
  "rejections": []
}
```

Each rejected message is listed in `rejections` with its `messageId` and the field that failed. When every message in a request fails, the response is `400` with the same shape.

| Status | What it means |
| - | - |
| `200` | Audience accepted the batch. Check `rejections` for any messages it refused. |
| `400` | The request was malformed, or every message failed. |
| `401` | The publishable key is missing or wrong. |
| `429` | You're sending too fast. Wait and retry with the same `messageId` values. |

## Consent

At `none`, send nothing. At `anonymous`, leave out `userId` and anything that identifies the player. At `full`, send everything.

To record a player's choice with Audience:

```bash theme={null}
curl -X PUT https://api.immutable.com/v1/audience/tracking-consent \
  -H "Content-Type: application/json" \
  -H "x-immutable-publishable-key: YOUR_PUBLISHABLE_KEY" \
  -d '{ "anonymousId": "anon-device-abc123", "status": "full", "source": "in-game-prompt" }'
```

## Test your setup

Add `"test": true` to a message while you build. Test events show in the event log but stay out of your boards.

## Check it's working

A `200` with `"accepted": 1` means Audience has the event. In Audience, **Game Analytics** > **Connect your game** shows **First event received** within a few minutes. See [Check your events arrive](https://docs.immutable.com/audience/track/check-events.md).

## Related

* [Consent](https://docs.immutable.com/audience/track/consent.md)
* [Check your events arrive](https://docs.immutable.com/audience/track/check-events.md)
* [HTTP API reference](https://docs.immutable.com/docs/products/audience/analytics/rest-api.md): every field, event type and the data deletion endpoint


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