Skip to main content
POST
/
v0
/
billableMetrics
Create
curl --request POST \
  --url https://api.paygentic.io/v0/billableMetrics \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "aggregation": "SUM",
  "description": "<string>",
  "merchantId": "<string>",
  "mode": "usage",
  "name": "<string>",
  "productId": "<string>",
  "unit": "<string>"
}'
{
  "id": "bm_w9x0y1z2a3b4c5d6",
  "object": "billableMetric",
  "aggregation": "SUM",
  "createdAt": "2024-01-15T10:30:00Z",
  "description": "Total tokens consumed by Claude language model interactions",
  "merchantId": "org_e7f8g9h0i1j2k3l4",
  "mode": "usage",
  "name": "Claude Tokens",
  "productId": "prod_m5n6o7p8q9r0s1t2",
  "taxRate": 8.5,
  "unit": "tokens",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Authorizations

Authorization
string
header
required

API key authentication

Body

application/json
aggregation
enum<string>
required

Aggregation calculation method for metric values. Sample values: 'SUM' totals all consumption values within the billing period

Available options:
SUM
description
string
required

Explanatory text describing what the metric tracks and how it's used for billing. Sample values: 'Total tokens consumed by Claude language model interactions', 'Gigabytes of cloud storage utilized', 'Count of machine learning inference requests processed', 'Quantity of AI-generated images created', 'Compute hours spent training neural networks', 'Terabytes of data transferred'

merchantId
string
required

The unique identifier of the merchant organization associated with the billable metric.

name
string
required

Human-readable label identifying what this metric measures. Sample values: 'Claude Tokens', 'Storage Capacity', 'Model Inference Calls', 'Generated Images', 'Training Compute Hours', 'Data Transfer Volume'

productId
string
required

The unique identifier of the product associated with the billable metric.

unit
string
required

Measurement unit used when aggregating this metric's values. Common examples: 'tokens', 'GB', 'calls', 'images', 'hours', 'TB', 'queries', 'requests'

mode
enum<string>

Billing frequency mode selection. Sample values: 'flat' applies fixed periodic charge regardless of consumption, 'usage' applies variable charges based on reported consumption amounts

Available options:
usage,
flat

Response

Billable metric created successfully

id
string

Unique identifier for a billable metric

object
enum<string>
default:billableMetric
Available options:
billableMetric
aggregation
enum<string>
Available options:
SUM,
MAX,
COUNT,
COUNT_UNIQUE
createdAt
string<date-time>
description
string
merchantId
string

Unique identifier for an organization

mode
enum<string>
Available options:
usage,
flat
name
string
productId
string

Unique identifier for a product

unit
string
updatedAt
string<date-time>