Contract Amender API
Contract Renewer API
Generate Quote Document API
Service Router
CPQ API Quickstart Guide
Disable CPQ Triggers in Apex
Salesforce CPQ Plugins
Previous Versions
Receive a CPQ contract in a request, and return quote information for one or more renewal quotes.
| Required Editions |
|---|
| Available in: Salesforce CPQ Summer ’16 and later |
SBQQ.ContractManipulationAPI.ContractRenewer
JSON, Apex
PATCH
Authorization: Bearer token
All of these user permissions are required.
Name: context
Type: RenewalContext
Required: Yes
Description: JSON object containing the contracts to renew. Include the IDs of each contract to renew. If there’s more than one contract, include the ID of the contract to use as the main contract.
Name: masterContractId
Type: Id
Required: No
Description: If you’re renewing multiple contracts, specify the ID of the main contract.
Name: renewedContracts
Type: ContractModel[]
Required: Yes
Description: One or more ContractModels to renew.
Available in: Salesforce CPQ Winter ’21 and later
Name: returnOnlyQuoteId
Type: boolean
Required: No
Description: If true, return the ID of the renewed quotes. If false or null, return the information for the renewed quotes.
Default value is false.
If returnOnlyQuoteId is false or null:
QuoteModel[]
Representation of one or more SBQQ__Quote__c data for renewal quotes.
If returnOnlyQuoteId is true:
integer
The ID of the SBQQ__Quote__c record.
Where possible, we changed noninclusive terms to align with our company value of Equality. Because changing terms in our code can break current implementations, we maintained this metadata type’s name.
Important
1curl
2 "https://yourInstance.salesforce.com/services/apexrest/SBQQ/ServiceRouter?loader=SBQQ.ContractManipulationAPI.ContractRenewer" -H
3 "Content-Type: application/json" -H "Authorization: Bearer token" -X POST -d
4 @context.jsonThis request body context.json file renews one or more Contracts. The context value is a JSON formatted string.
1{"context": "{\"masterContractId\": null, \"renewedContracts\":
2[{\"attributes\":{\"type\":\"Contract\"},\"Id\":\"800540000006LLVAA2\"}]}"}An example response body after renewing 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/a0p610000040iumAAA"
6 },
7 "Id": "a0p610000040iumAAA",
8 "Name": "Q-00880"
9 },
10 "nextKey": 5,
11 "netTotal": 300,
12 "netNonSegmentTotal": 300,
13 "lineItems": [
14 {
15 "record": {
16 "attributes": {
17 "type": "SBQQ__QuoteLine__c",
18 "url": "/services/data/v41.0/sobjects/SBQQ__QuoteLine__c/a0l61000003u09UAAQ"
19 },
20 "Id": "a0l61000003u09UAAQ"
21 }
22 }
23 ],
24 "lineItemGroups": [ ]
25}]Before saving the ContractRenewer example class, ensure that you’ve created individual Apex classes for your CPQ models.
1// Define a class to hold information about the contracts to renew
2private with sharing class CreateRenewalContext {
3 public Id masterContractId;
4 public Contract[] renewedContracts;
5public Boolean returnOnlyQuoteId;
6}
7
8//define a class to hold the serialized context and the returned quote information
9public with sharing class ContractRenewer {
10 public QuoteModel[] load(String masterContractId, String serializedContext) {
11 String quotesJSON = SBQQ.ServiceRouter.load('SBQQ.ContractManipulationAPI.ContractRenewer', masterContractId, serializedContext);
12 return (QuoteModel[]) JSON.deserialize(quotesJSON, List<QuoteModel>.class);
13 }
14}
15
16// populate the renewal context
17CreateRenewalContext context = new CreateRenewalContext();
18context.masterContractId = '4567';
19context.renewedContracts = [SELECT Id FROM Contract WHERE Id IN ('4567', '8910')];
20// Set returnOnlyQuoteId to true if you only want the Quote ID and not the entire Quote model.
21context.returnOnlyQuoteId = true;
22
23
24// Serialized the renewal context
25// For example, context = '{"masterContractId": "8001D000000AUlg", "renewedContracts":
26//[{"attributes":{"type":"Contract"},"Id":"8001D000000AUlg"},
27// {"attributes":{"type":"Contract"},"Id":"8001D000000AVGt"}]}';
28String jsonContext = JSON.serialize(context);
29
30// renew the two contracts
31ContractRenewer renewer = new ContractRenewer();
32QuoteModel[] quotes = renewer.load(null, jsonContext);Example response body for returnOnlyQuoteId = true:
1{"attributes":{"type":"SBQQ__Quote__c","url":"/services/data/v50.0/sobjects/SBQQ__Quote__c/123456"},"Id":"56789"}