Skip to main content
POST
/
v1
/
usage
/
batch
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.trackBatch({
  events: [
    {
      customerId: "customer_123",
      featureKey: "api_calls",
      eventKey: "evt_1",
    },
    {
      customerId: "customer_123",
      featureKey: "api_calls",
      amount: 2,
      eventKey: "evt_2",
    },
  ],
});
{
  "results": [
    {
      "success": true,
      "result": {
        "applied": true,
        "used": 123,
        "eventId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "reason": "<string>"
      }
    }
  ],
  "hasErrors": true
}

Headers

x-api-key
string
required

API key from your PriceOS dashboard.

Body

application/json
events
object[]
required

Batch usage events.

Required array length: 1 - 100 elements

Response

Usage batch recorded

results
object[]
required

Batch usage results, in the same order as the request.

Batch usage result entry.

hasErrors
boolean
required

Whether any usage events failed.