Skip to main content
If you would like to use PriceOS to track customers’ usage for your limit features, you can do so with our track usage endpoint.
See creating limit features to learn how to set up usage tracking for features.

Track a single usage event

import { useTrackUsage } from "priceos/react";
import type { MyFeatures } from "./priceos.types";

export function TrackApiCallButton() {
  const { trackUsage } = useTrackUsage<MyFeatures>();

  async function onClick() {
    await trackUsage({
      featureKey: "api_calls",
      amount: 1,
      eventKey: "api_calls_customer_123_req_9f3a2",
    });
  }

  return <button onClick={onClick}>Record API call</button>;
}
You can use negative numbers in the amount field to reduce usage in our backend SDK and API only (not client side).
eventKey is optional, but strongly recommended to deduplicate events and safely retry requests.
For more details, see Track usage.

Setting usage directly

Sometimes you just want to set usage totals directly instead of adding separate usage events. You can use the set usage endpoint which will automatically calculate the usage event needed to get to your desired total.
import { PriceOS } from "priceos";
import type { MyFeatures } from "./priceos.types";

const priceos = new PriceOS<MyFeatures>(process.env.PRICEOS_API_KEY!);

const result = await priceos.usage.set({
  customerId: "customer_123",
  featureKey: "api_calls",
  used: 1200,
  eventKey: "set_usage_customer_123_api_calls_2026_02_18",
});
For more details, see Set usage.

Track usage in batch

Use batch when you need to send multiple events together (up to 100 per request).
import { PriceOS } from "priceos";
import type { MyFeatures } from "./priceos.types";

const priceos = new PriceOS<MyFeatures>(process.env.PRICEOS_API_KEY!);

const result = await priceos.usage.trackBatch({
  events: [
    {
      customerId: "customer_123",
      featureKey: "api_calls",
      amount: 1.5,
      eventKey: "evt_1",
    },
    {
      customerId: "customer_123",
      featureKey: "api_calls",
      amount: 2,
      eventKey: "evt_2",
    },
  ],
});
For more details, see Track usage batch.