Inform end users of their cost per billing period using this API to calculate price data for a given collection of offerings, rates, and products configuration.
Before you start
- Have you configured your product catalog? Review our Product Catalog documentation for an overview on how to configure your Product Catalog.
API Definition
Request body
type PriceRequest = {
"pricingBehavior": string; // only valid value is "UNBOUNDED"
"currency": string; // e.g. USD, EUR
"configurations": [
{
referenceId?: string;
offeringId: string;
rateId: string;
items: [
{
productId: string;
quantity?: number;
}
]
}
]
}configurations[].items[].quantityis omitted when the product is a usage product.configurations[].referenceIdis an optional, client-provided string to map part of the API response back to the request input. If not provided, the API response will assign a random reference ID per pricing output.
Response body
Error
Error responses will come in the form of:
type Error = {
errorCode: string;
message: string;
context?: Record<string, unknown>;
}
type ApiErrorResponse = {
operation: "calculatePrices";
error: Error;
}- There is a
contextobject whenever there's additional to include with the error.
| Error description | Error code |
|---|---|
Multiple configurations inputs have the same reference ID | CONFLICTING REFERENCE ID |
| The requested currency is not configured in the tenant | UNCONFIGURED_CURRENCY |
Success or Partial Success
The API handles partial success, meaning that MonetizeNow will process valid inputs and indicate which inputs are invalid; the referenceId property is useful to identify which inputs have resulted in error/success.
type PriceItemSuccess = {
productId: string;
netAmount: number;
quantity: number;
}
type PriceSuccess = {
referenceId: string;
rateId: string;
billingFrequency: string;
netAmount: number;
currency: string;
items: PriceItemSuccess[];
}
type PriceError = {
referenceId: string;
errorCode: string;
details: string;
context: Record<string, any>;
}
type ApiSuccessResponse = {
prices: PricessSuccess[];
errors: PriceError[];
}| Error description | Error code |
|---|---|
| Requested rate is not configured with the requested currency | RATE_CURRENCY_VALIDATION_FAILURE |
| Requested rate is nonexistent | INVALID_RATE |
| Requested rate does not belong to requested offering | INVALID_OFFERING_RATE |
| Requested offering is nonexistent | INVALID_OFFERING |
| Requested offering does not have 'active' status | OFFERING_NOT_ACTIVE |
| Pricing input is missing mandatory products | MISSING_REQUIRED_PRODUCT_CONFIGURATION |