Skip to main content
POST
/
track
TypeScript
import { Autumn } from 'autumn-js';

const autumn = new Autumn();

const { data, error } = await autumn.track({ customer_id: 'x' });
{
  "customer_id": "customer_123",
  "feature_id": "api_tokens"
}
This endpoint is for tracking usage events in Autumn, so feature usage can be limited or billed for.
If the customer_id you send doesn’t already exist, Autumn will automatically create a new customer. You can optionally set the properties of this new customer through the customer_data field.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
customer_id
string
required

ID which you provided when creating the customer

feature_id
string

ID of the feature to track usage for. Required if event_name is not provided. Use this for direct feature tracking.

event_name
string

An event name can be used in place of feature_id. This can be used if multiple features are tracked in the same event.

value
number

The amount of usage to record. Defaults to 1. Can be negative to increase the balance (e.g., when removing a seat).

properties
object

Additional properties to attach to this usage event.

idempotency_key
string

Unique key to prevent duplicate event recording. Use this to safely retry requests without creating duplicate usage records.

customer_data
object

Additional customer properties. These will be used to create or update the customer if they don't exist or their properties are not already set.

entity_id
string

If using entity balances (eg, seats), the entity ID to track usage for.

overage_behavior
enum<string>

How to handle usage when balance is insufficient. 'cap' limits usage to available balance, 'reject' prevents the usage entirely.

Available options:
cap,
reject

Response

200 - application/json
customer_id
string
required

The ID of the customer

entity_id
string

The ID of the entity (if provided)

event_name
string

The name of the event

feature_id
string

The ID of the feature (if provided)