Generate Quote Document API
Creates and saves a CPQ quote document.
| Required Editions |
|---|
| Available in: Salesforce CPQ Winter ’19 and later |
- Name
QuoteDocumentAPI.SaveProposal
“Proposal” refers to Salesforce CPQ’s Quote Document object.
- Formats
JSON, Apex
- HTTP Method
POST
- Authentication
Authorization: Bearer token
Request Parameters
| Name | Type | Required | Definition |
|---|---|---|---|
| Name | String | No | The document name |
| paperSize | String | No | Values are Default, Letter, Legal, A4. Defaults to “Default.” |
| outputFormat | String | No | Values are PDF, Word. Defaults to “PDF.” |
| quoteId | ID | Yes | The quote’s ID |
| templateId | ID | Yes | The quote template’s ID |
| language | String | No | Defaults to “en_US.” |
Response
| Name | Type | Description |
|---|---|---|
| jobID | ID | Apex queueable job ID |
REST Examples
1curl "https://yourInstance.salesforce.com/services/apexrest/SBQQ/ServiceRouter?saver=QuoteDocumentAPI.SaveProposal"
2-H "Content-Type: application/json" -H "Authorization: Bearer token" -X POST -d @data.jsonExample request body data.json file for generating and saving a quote document.
1"{\"saver\":\"SBQQ.QuoteDocumentAPI.Save\",\"model\":\"{\\\"name\\\":\\\"test\\\",\\\"quoteId\\\"
2:\\\"a0n0R000000jhVC\\\",\\\"templateId\\\":\\\"a0l0R000000vahe\\\",\\\"outputFormat\\\":
3\\\"PDF\\\",\\\"language\\\":\\\"en_US\\\",\\\"paperSize\\\":\\\"Default\\\"}\"}"Example response body after creating the APEX job for creating the quote document.
1"7070R00000Nj8mjQAB"If the Bearer token contains special characters, enclose the Authorization header in single quotes instead of double quotes.
Note
APEX Examples
Before saving the GenerateQuoteProposal example class, make sure that the CPQ model classes are added as individual APEX classes in your org.
1public with sharing class GenerateQuoteProposal {
2
3 public String save(QuoteProposalModel context) {
4 return SBQQ.ServiceRouter.save('SBQQ.QuoteDocumentAPI.Save', JSON.serialize(context));
5 }
6}Run the following code in anonymous Apex to get the Apex job ID for generating and saving the quote proposal.
1QuoteProposalModel model = new QuoteProposalModel();
2model.quoteId = 'a0n0R000000jhVC';
3model.templateId = 'a0l0R000000vahe';
4GenerateQuoteProposal proposalGenerator = new GenerateQuoteProposal();
5String jobId = proposalGenerator.save(model);
6System.debug(jobId);- Attachments marked Required are ignored when you’re using the API. In contrast, when you’re using the Preview and Generate document buttons, the attachments are automatically generated as part of the document.
- An attachment in the Template section is always included regardless of whether it’s marked Required. This behavior is also observed when you’re using Preview and Generate document buttons.
- Guest users can’t create quote documents in the Documents folder. See Salesforce Help and SOAP API Developer Guide for details.
See Also