Save Quote API

The Save Quote API saves a CPQ quote.

Required Editions
Available in: Salesforce CPQ Summer ’16 and later
Formats

JSON, Apex

HTTP Method

POST

Authentication

Authorization: Bearer token

REQUEST

Name

quote

Type

QuoteModel

Required

Yes

Description

Representation of SBQQ__Quote__c data

RESPONSE

Type

QuoteModel

Description

Representation of SBQQ__Quote__c data

REST Examples 

1curl
2     "https://YOURINSTANCE.salesforce.com/services/apexrest/SBQQ/ServiceRouter" -H
3     "Content-Type: application/json" -H "Authorization: Bearer token" -X POST -d
4     @quoteModel.json

This request body quoteModel.json file saves a quote. The context value is a JSON formatted string.

1{"saver": "SBQQ.QuoteAPI.QuoteSaver", "model": "{\"record\":
2{\"attributes\":{\"type\":\"SBQQ__Quote__c\",\"url\":\"/services/data/v41.0/sobjects/
3SBQQ__Quote__c/a0l61000003kUlVAAU\"},
4\"Name\":\"Q-00681\",\"Id\":\"a0l61000003kUlVAAU\"},\"nextKey\":2,\"netTotal\":0.00,\
5"lineItems\":[],\"lineItemGroups\":[],\"customerTotal\":0.00}"}

An example response body after saving a quote. The actual response is a JSON formatted string.

1{    
2    "record": {        
3      "attributes":{
4         "type":"SBQQ__Quote__c",
5         "url":"/services/data/v41.0/sobjects/SBQQ__Quote__c/a0l61000003kUlVAAU"
6     },        
7     "Name":"Q-00681",        
8     "Id":"a0l61000003kUlVAAU"
9  },    
10  "nextKey":2,    
11  "netTotal":0.00,    
12  "lineItems":[],
13  "lineItemGroups":[],    
14  "customerTotal":0.00
15}

APEX Examples 

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

1public with sharing class QuoteSaver {
2    public QuoteModel save(QuoteModel quote) {
3        String quoteJSON = SBQQ.ServiceRouter.save('SBQQ.QuoteAPI.QuoteSaver', JSON.serialize(quote));
4        return (QuoteModel) JSON.deserialize(quoteJSON, QuoteModel.class);
5    }
6}

For an example of the QuoteSaver class, run the following code in anonymous Apex.

1QuoteModel quoteModel; //Use Read, Add Products, or Calculate APIs to obtain a QuoteModel
2
3QuoteSaver saver = new QuoteSaver();
4QuoteModel savedQuote = saver.save(quoteModel);
5System.debug(savedQuote);