Skip to main content
POST
/
v1
/
usage
Node.js
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.track({
  customerId: "customer_123",
  featureKey: "api_calls",
  eventKey: "api_calls_customer_123_req_9f3a2",
});
{
  "applied": true,
  "used": 123,
  "eventId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "reason": "<string>"
}

Headers

x-api-key
string
required

API key from your PriceOS dashboard.

Body

application/json
customerId
string
required

Internal customer ID. If the customer ID does not exist yet, it will be created.

featureKey
string
required

Feature key to track usage for.

amount
number
default:1

Usage amount to record. Defaults to 1. Supports positive or negative values.

eventKey
string

Stable unique identifier for this event. Reuse it on retries and for deduplication.

occurredAt
integer

Unix timestamp (ms) when the event occurred.

metadata
object

Optional metadata for the event (string key/value pairs).

Response

Usage recorded

Usage result.

applied
boolean
required

Whether the usage event was applied.

used
number | null
required

Updated usage total, if applicable.

eventId
string<uuid> | null

Usage event ID when available.

reason
string | null

Reason the usage event was not applied.