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",
},
],
});curl -X POST "https://api.priceos.com/v1/usage/batch" \
-H "x-api-key: PRICEOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Usage
Track Usage (Batch)
Record usage for multiple events (max 100).
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",
},
],
});curl -X POST "https://api.priceos.com/v1/usage/batch" \
-H "x-api-key: PRICEOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Headers
API key from your PriceOS dashboard.
Body
application/json
Batch usage events.
Required array length:
1 - 100 elementsShow child attributes
Show child attributes