Pricing API

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

  1. 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[].quantity is omitted when the product is a usage product.
  • configurations[].referenceId is 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 context object whenever there's additional to include with the error.
Error descriptionError code
Multiple configurations inputs have the same reference IDCONFLICTING REFERENCE ID
The requested currency is not configured in the tenantUNCONFIGURED_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 descriptionError code
Requested rate is not configured with the requested currencyRATE_CURRENCY_VALIDATION_FAILURE
Requested rate is nonexistentINVALID_RATE
Requested rate does not belong to requested offeringINVALID_OFFERING_RATE
Requested offering is nonexistentINVALID_OFFERING
Requested offering does not have 'active' statusOFFERING_NOT_ACTIVE
Pricing input is missing mandatory productsMISSING_REQUIRED_PRODUCT_CONFIGURATION