Prerequisites
For a cost to be recorded:- Organization must have an active subscription
- Token must be ACTIVE
- Fee must be compatible with organization’s currency
Recording Flow
- Usage event received with fee eventName, token ID, and quantity
- Token
value× quantity = subtotal (in token’s currency) - Exchange rate fetched for token currency → org currency
- Total amount calculated in org currency
costBatchWindowRefgenerated from hash(eventName, orgId, timestamp window)- Cost record created
Exchange Rate Calculation
If the token currency differs from the organization currency, an exchange rate is applied:- First, try PTAX API (Brazilian Central Bank) for BRL rates
- Fallback to ExchangeRateAPI
- Final fallback to MANUAL rates