cURL
curl --request POST \
--url https://api.tirdad.ai/v1/prices/units \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"base_currency": "<string>",
"code": "<string>",
"conversion_rate": "<string>",
"name": "<string>",
"symbol": "<string>",
"metadata": {}
}
'from tirdad_sdk import Tirdad
with Tirdad(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.price_units.create_price_unit(base_currency="<value>", code="<value>", conversion_rate="<value>", name="<value>", symbol="<value>")
# Handle response
print(res)import { Tirdad } from "@tirdad/sdk";
const tirdad = new Tirdad({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await tirdad.priceUnits.createPriceUnit({
baseCurrency: "<value>",
code: "<value>",
conversionRate: "<value>",
name: "<value>",
symbol: "<value>",
});
console.log(result);
}
run();package main
import(
"context"
tirdad "github.com/tirdad-billing/go-sdk/v2"
"github.com/tirdad-billing/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := tirdad.New(
tirdad.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.PriceUnits.CreatePriceUnit(ctx, types.CreatePriceUnitRequest{
BaseCurrency: "<value>",
Code: "<value>",
ConversionRate: "<value>",
Name: "<value>",
Symbol: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.CreatePriceUnitResponse != nil {
// handle response
}
}{
"base_currency": "<string>",
"code": "<string>",
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"environment_id": "<string>",
"id": "<string>",
"metadata": {},
"name": "<string>",
"status": "published",
"symbol": "<string>",
"tenant_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Price Units
Create price unit
Use when defining a new unit of measure for pricing (e.g. GB, API call, seat). Ideal for metered or usage-based prices.
POST
/
prices
/
units
cURL
curl --request POST \
--url https://api.tirdad.ai/v1/prices/units \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"base_currency": "<string>",
"code": "<string>",
"conversion_rate": "<string>",
"name": "<string>",
"symbol": "<string>",
"metadata": {}
}
'from tirdad_sdk import Tirdad
with Tirdad(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.price_units.create_price_unit(base_currency="<value>", code="<value>", conversion_rate="<value>", name="<value>", symbol="<value>")
# Handle response
print(res)import { Tirdad } from "@tirdad/sdk";
const tirdad = new Tirdad({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await tirdad.priceUnits.createPriceUnit({
baseCurrency: "<value>",
code: "<value>",
conversionRate: "<value>",
name: "<value>",
symbol: "<value>",
});
console.log(result);
}
run();package main
import(
"context"
tirdad "github.com/tirdad-billing/go-sdk/v2"
"github.com/tirdad-billing/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := tirdad.New(
tirdad.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.PriceUnits.CreatePriceUnit(ctx, types.CreatePriceUnitRequest{
BaseCurrency: "<value>",
Code: "<value>",
ConversionRate: "<value>",
Name: "<value>",
Symbol: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.CreatePriceUnitResponse != nil {
// handle response
}
}{
"base_currency": "<string>",
"code": "<string>",
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"environment_id": "<string>",
"id": "<string>",
"metadata": {},
"name": "<string>",
"status": "published",
"symbol": "<string>",
"tenant_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Body
application/json
Price unit details
ConversionRate defines the exchange rate from this price unit to the base currency. This rate is used to convert amounts in the custom price unit to the base currency for storage and billing.
Conversion formula: price_unit_amount * conversion_rate = base_currency_amount
Example: If conversion_rate = "0.01" and base_currency = "usd": 100 price_unit tokens * 0.01 = 1.00 USD
Note: Rounding precision is determined by the base currency (e.g., USD uses 2 decimal places, JPY uses 0).
Response
Created