# Record attributes, events and purchases (Braze)

`POST /v1/compat/braze/users/track`

Requires an API key with the `contacts:write events:write` scope. [About keys and scopes](/docs/api/authentication)

Braze's `/users/track`, so an app sending to Braze can send here too while it moves, by pointing its REST endpoint at `…/v1/compat/braze`. Each item names its person by `external_id` (the contact's `externalId`) or `email`; a person not yet known is created. `first_name`, `last_name`, `email`, `phone` and `country` fill those fields; an `email_subscribe` or `push_subscribe` of `unsubscribed` withdraws that consent; every other key becomes an attribute. Consent is never granted here: import it with its evidence. A purchase is recorded as a `Product Purchased` event with `product_id`, `currency`, `price`, `quantity` and `total`. Items that fail are listed in `errors`; the rest apply. Agent keys are refused.

Requires API-key scope: `contacts:write` and `events:write`.

## Request body

- `attributes` (BrazeAttributesInput[], optional, at most 75 items)
  - `external_id` (string, optional, 1–255 characters)
  - `email` (string, optional, 3–320 characters)
- `events` (BrazeEventInput[], optional, at most 75 items)
  - `external_id` (string, optional, 1–255 characters)
  - `email` (string, optional, 3–320 characters)
  - `name` (string, required, 1–128 characters)
  - `time` (string, required, date-time)
  - `properties` (object, optional)
- `purchases` (BrazePurchaseInput[], optional, at most 75 items)
  - `external_id` (string, optional, 1–255 characters)
  - `email` (string, optional, 3–320 characters)
  - `product_id` (string, required, 1–255 characters)
  - `currency` (string, required)
  - `price` (number, required, min 0, max 1000000000)
  - `quantity` (integer, optional, min 1, max 100, default `1`)
  - `time` (string, required, date-time)
  - `properties` (object, optional)

## Returns

Returns `201 Created`. Otherwise returns an error; [Errors](/docs/api/errors) lists every code and which to retry.

## Example

```bash
curl -X POST https://api.kirora.io/v1/compat/braze/users/track \
  -H "Authorization: Bearer $KIRORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "attributes": [
      {}
    ],
    "events": [
      {
        "name": "Weekend specials",
        "time": "2030-03-14T09:30:00Z"
      }
    ],
    "purchases": [
      {
        "product_id": "product_id_example",
        "currency": "USD",
        "price": 0,
        "time": "2030-03-14T09:30:00Z"
      }
    ]
  }'
```

Response `201`:

```json
{
  "message": "success",
  "attributes_processed": -9007199254740991,
  "events_processed": -9007199254740991,
  "purchases_processed": -9007199254740991,
  "errors": [
    {
      "type": "type_example",
      "input_array": "attributes",
      "index": -9007199254740991
    }
  ]
}
```
