Calculate Quote API
The Calculate Quote API calculates the prices of a CPQ quote.
| Required Editions |
|---|
| Available in: Salesforce CPQ Summer ’16 and later |
Calculate Quote API performances handles calculations similarly to the speed of asynchronous calculations in Salesforce CPQ. We do not recommend using it for processes that require instant calculation.
The Calculate Quote API doesn’t use batches when creating and calculating quotes. Performance may vary for quotes with large volumes of quote lines.
The Calculate Quote API requires callback when evaluating quote-scoped product rules.
- Formats
JSON, Apex
- HTTP Method
PATCH
- Authentication
Authorization: Bearer token
REQUEST
- Parameter 1
Name: quote
Type: QuoteModel
Required: Yes
Description: Representation of SBQQ__Quote__c data. See CPQ API QuoteModel
- Parameter 2
Name: callbackClass
Type: String
Required: Required for Apex Trigger
Description: This Apex class implements the CPQ CalculateCallback interface.
This request body quoteToCalculate.json file calculates a quote. The context value is a JSON formatted string.
An example response body after successfully calculating a product. The actual response is a JSON formatted string.
When you execute the Calculate API with an Apex trigger, you also need to create a quote calculator callback class. This class must implement the CPQ CalculateCallback interface to save the quote after calculating it in the background.
Before saving the QuoteCalculator example class, make sure that the CPQ model classes are added as individual Apex classes in your org.
For an example of the QuoteCalculator class, run the following code in anonymous Apex.