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

# Track

> Record one event that a person or an anonymous visitor did.

Track records one event, and a journey can start on it. Send `event`, `channel` and a `userId`, an `anonymousId` or both; a visitor who has not signed in has only `anonymousId`.

> [!NOTE]
>
> A call that names a `userId` needs the `Maqetin-Identity-Token` header in `required` mode, the default. A call with only an `anonymousId` needs none. See [Identity verification](https://docs.maqetin.com/data/identity-verification.md).

## Headers

**Authorization** `string` *required*

`Bearer mq_live_…`, your public key. A secret key is refused here: send events with a secret key to [`/v1/batch`](https://docs.maqetin.com/api-reference/batch).

**Maqetin-Identity-Token** `string`

A token your server signed for this `userId`. See [Identity token](https://docs.maqetin.com/api-reference/introduction.md#identity-token).

## Body

The body is at most 32 KiB. Any other top-level field is a `400`.

**event** `string` *required*

The name of the event, at least 1 character. See [Name events](#name-events).

**channel** `string` *required*

Where the call came from: `web`, `ios`, `android`, `node`, `python`, `go` or `rest`. Use `rest` for your own HTTP calls.

**userId** `string`

Your own id for the person, 1 to 256 characters. Required when there is no `anonymousId`.

**anonymousId** `string`

The id of a visitor who has not signed in, 1 to 256 characters. Required when there is no `userId`.

**properties** `object` (default: \{})

What you know about the event. Any JSON values. Property names cannot hold the NUL character.

**messageId** `string`

1 to 64 characters. A retry with the same id is stored once. See [Send an event once](https://docs.maqetin.com/api-reference/introduction.md#send-an-event-once).

**timestamp** `string`

When it happened, as an ISO 8601 date-time. Used only together with `sentAt`. See [Event time](https://docs.maqetin.com/api-reference/introduction.md#event-time).

**sentAt** `string`

When your client sent the request, as an ISO 8601 date-time.

**sessionId** `string`

The id of the session, at most 256 characters.

**sdkVersion** `string`

The version of the SDK that made the call.

**context** `object`

Where the event was made. The SDK fills it for you. Same rules as the `context` of [Identify](https://docs.maqetin.com/api-reference/identify.md).

## Name events

Name an event `object.action`, lower case and past tense, such as `order.placed`. The object is the part before the first dot. The gateway takes any name that is not empty, so the convention is yours to keep.

Ten objects belong to Maqetin; do not use them for events of your own (the SDK sends `page.viewed` itself): `app`, `install`, `deeplink`, `screen`, `page`, `push`, `in_app`, `link`, `message` and `email`.

## Response

**accepted** `number` *required*

The number of events taken: `1`.

A `202` means the event is stored. A refusal has `error` and, for a body problem, `at`. See [Errors](https://docs.maqetin.com/api-reference/errors.md#event-routes).

```bash cURL theme={null}
curl https://in.maqetin.com/v1/track \
  -H 'Authorization: Bearer mq_live_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "userId": "user_123",
  "event": "order.completed",
  "properties": {
    "orderId": "ord_1001",
    "total": 49.9,
    "currency": "USD"
  },
  "channel": "rest"
}'
```

```json 202 theme={null}
{ "accepted": 1 }
```

```json 400 theme={null}
{ "error": "invalid payload", "at": ["/channel"] }
```


## Related topics

- [Email](https://docs.maqetin.com/messaging/email.md)
- [Events](https://docs.maqetin.com/data/events.md)
- [Batch](https://docs.maqetin.com/api-reference/batch.md)
- [Quickstart](https://docs.maqetin.com/quickstart.md)
- [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md)


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