Docs API reference Usage events

Usage events

Track customer app usage by sending usage events with the Mantle API. Usage events can be used for metered usage billing, or simply to track user behavior for analytics.

POST   https://appapi.heymantle.com/v1/usage_events

POST /v1/usage_events

Send usage events to Mantle.

Header parameters

X-Mantle-App-Idstring

The App Id when you create an API key in your Mantle dashboard.

X-Mantle-Customer-Api-Tokenstring

The API token you receive from your POST request to the /identify endpoint.

Body parameters

customerIdstring

The unique identifier for the customer. Not required if the request is sent with X-Mantle-Customer-Api-Token headers.

eventIdstring

The unique identifier for the event. Also accepted as event_id

eventNamestring

The event name (a key) used to track the usage metric. Also accepted as event_name

timestamptimestamp

The time the event occurred in milliseconds.

properties<string,object>

Key-value pairs of properties for the event.

events[object]

An array of Usage Events. Used when you would like to bulk send usage events.

Sending a single event

curl --request POST \
  --url https://appapi.heymantle.com/v1/usage_events \
  --header 'X-Mantle-App-Id: string' \
  --header 'X-Mantle-Customer-Api-Token: string' \
  --header 'Content-Type: application/json' \
  --data '
  {
    "customerId": "string",
    "eventId": "string",
    "eventName": "string",
    "timestamp": 1709315224000,
    "properties": {
      "key": "value"
    }
  }
  '

Sending multiple events

curl --request POST \
  --url https://appapi.heymantle.com/v1/usage_events \
  --header 'X-Mantle-App-Id: string' \
  --header 'X-Mantle-Customer-Api-Token: string' \
  --header 'Content-Type: application/json' \
  --data '
  {
    "events": [
      {
        "customerId": "string",
        "eventId": "string",
        "eventName": "string",
        "timestamp": 1709315224000,
        "properties": {
          "key": "value"
        }
      },
      {
        "customerId": "string",
        "eventId": "string",
        "eventName": "string",
        "timestamp": 1709315224000,
        "properties": {
          "key": "value"
        }
      }
    ]
  }
  '

Returns { "success": true } if successful.