Validate Quote API

Validate a CPQ quote and return any validation errors.

Required Editions
Available in: Salesforce CPQ Winter ’19 and later
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.

RESPONSE

Type

String[]

Description

If the quote is valid, the array is empty. Otherwise, the array contains an item for each validation error.

REST Examples 

1curl "https://YOURINSTANCE.salesforce.com/services/apexrest/SBQQ/ServiceRouter?loader=QuoteAPI.QuoteValidator" -H 
2"Content-Type: application/json" -H "Authorization: Bearer TOKEN" -X PATCH -d @quoteModel.json

The request body quoteModel.json file validates a quote. The context value is a JSON formatted string/serialization of a quote, the same as the CPQ Save Quote API.

1{"context": "{\"record\": {\"attributes\":{\"type\":\"SBQQ__Quote__c\",\"url\":\"/services/data/v41.0/sobjects/SBQQ__Quote__c/a0l61000003kUlVAAU\"},
2\"Name\":\"Q-00681\",\"Id\":\"a0l61000003kUlVAAU\"},\"nextKey\":2,\"netTotal\":0.00,\"lineItems\":[],\"lineItemGroups\":[],\"customerTotal\":0.00}"}

An example response body after creating the Apex job for generating the quote proposal.

1// valid quote
2[]
3
4// invalid quote
5[
6  "message 1",
7  "message 2",
8  "message 3"
9]

Apex Examples 

Before saving the Validator example class, make sure that the CPQ model classes are added as individual Apex classes in your org.

1public with sharing class Validator {
2
3   public List<String> validate(QuoteModel quote) {
4      String res=SBQQ.ServiceRouter.load(’SBQQ.QuoteAPI.QuoteValidator’, null, JSON.serialize(quote));
5      return (List<String>) JSON.deserialize(res, List<String>.class);
6   }
7}

Run the following code in anonymous Apex to get Apex job ID for generating and saving the quote proposal.

1QuoteModel quoteModel; //Use Read Quote API to obtain a QuoteModel
2
3Validator validator = new Validator();
4List<String> msgs = validator.validate(quoteModel);
5System.debug(msgs);