{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":37624,"path":"order-management/logik_salesforce_cpq_request_for_quote_api.md","title":"The RFQ \\(Request for Quote\\) API","bundle":null,"doc_type":null,"release":"australia","body":"\n# The RFQ \\(Request for Quote\\) API\n\nCPQ adds additional functionality to the Salesforce CPQ package APIs. This functionality lets you add products and data to an existing Salesforce CPQ quote.\n\nAs part of the CPQ integration package with Salesforce CPQ, CPQ provides an API to add a CPQ configured product, sales BOM products and BOM data to a new or existing Salesforce CPQ quote \\(`SBQQ__Quote__c`\\). This provides CPQ functionality in addition to the Salesforce CPQ package APIs.\n\n[Salesforce CPQ package APIs](https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_get_started.htm)\n\nView a video about the Request for Quote API:\n\n[https://youtu.be/e0nxEITIzq8](https://youtu.be/e0nxEITIzq8)\n\n## URL and endpoint\n\nTwo HTTP methods are exposed for the endpoint:\n\n-   POST for creating a new quote and adding a product and configuration\n-   PATCH for adding a new product and configuration to an existing quote\n\nThis API is exposed as an Apex Rest Service in the Salesforce org with a path of `/services/apexrest/LGK/request-quote`: for example, `https://<yourInstance>.salesforce.com/services/apexrest/LGK/request-quote`, where `<yourInstance>` is the personal domain of your Salesforce org.\n\n## Setup and authorization\n\nThis API is exposed in the Salesforce org and requires authorization with Salesforce to be accessed and called. See [Salesforce Help on Authorization options for making API calls](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_flows.htm&type=5). This API can also be tested using the [Salesforce Workbench Application](https://workbench.developerforce.com/).\n\nIn CPQ, the only step is to ensure that in Admin settings, **Push BOM Data to ServiceNow CPQ Salesforce Object** is enabled. CPQ uses the data stored in the Configuration Line Items \\(LGK\\_\\_ConfigurationLineItem\\_\\_c\\) to create any additional sales BOM lines on the quote and write the BOM Data field on the quote line.\n\n**Note:** The API will also respect normal Salesforce user access levels, so if the authenticated Salesforce user \\(or a partner site itself, via sharing settings\\) does not have certain object or field level access, the API call may fail or not behave as expected. The user calling the API needs access to the standard Salesforce CPQ and related objects as well as the CPQ Configuration Line Item object and its fields.\n\nA short list of necessary objects includes:\n\n-   Pricebook\n-   Product feature \\(for the “Dynamic” feature on the product\\)\n-   Quote\n-   Product\n-   Quote line\n-   Config Line Item\n\nIf there is an issue with the API, make sure the user not only has access to the object or fields, but also to the specific record. This is always true, but because partner profiles start off with less access to records, they are more susceptible to the problem.\n\nTo use these APIs, create and save a CPQ configuration, making note of the configuration ID that will be used for the calls. Also copy the product ID of the configurable product that was used to create the configuration demo.\n\n## Create new quote and add product\n\nThe create quote and add product API call can be very useful if CPQ is being used outside the traditional Salesforce CPQ context. This can enable an omni channel experience without exposing end users to the Salesforce CPQ Quote Line Editor.\n\n<table><tbody><tr><td>\n\nHTTP method\n\n</td><td>\n\nPOST\n\n</td></tr><tr><td>\n\nURL\n\n</td><td>\n\nhttps://&lt;yourInstance&gt;.salesforce.com/services/apexrest/LGK/request-quote\n\n</td></tr><tr><td>\n\nPath parameters\n\n</td><td>\n\nN/A\n\n</td></tr><tr><td>\n\nQuery parameters\n\n</td><td>\n\nN/A\n\n</td></tr></tbody>\n</table>The required parameters in the request body are:\n\n-   **configurableProductId**\n\n    The CPQ enabled configurable product ID\n\n-   **configurationId**\n\n    The CPQ configuration UUID received after saving a configuration\n\n-   **pricebookId**\n\n    The Salesforce ID of the Pricebook2 record that has a valid pricebook entry for the product\n\n\n-   **** –\n-   **** –\n-   **** –\n\nIf included, **accountId** and **opportunityId** are populated on the newly created quote.\n\nSample URL: `https://demoloik.my.salesforce.com/services/apexrest/LGK/request-quote`\n\nSample request payload:\n\n```\n{\n  \"configurableProductId\": \"01t5f000003w24zAAA\",\n  \"configurationId\": \"eeec456c-a4f6-407a-94b1-03e8b6cf29ea\",\n  \"pricebookId\": \"01s5f000000AsLDAA0\" }\n```\n\nSample response:\n\n```\n{\n  \"attributes\" : {\n    \"type\" : \"SBQQ__Quote__c\",\n    \"url\" : \"/services/data/v57.0/sobjects/SBQQ__Quote__c/a0q5f0000057YAYAA2\"\n  },\n  \"Name\" : \"Q-00162\",\n  \"Id\" : \"a0q5f0000057YAYAA2\",\n  \"SBQQ__LineItemCount__c\" : 3,\n  \"SBQQ__LineItems__r\" : {\n    \"totalSize\" : 3,\n    \"done\" : true,\n    \"records\" : [ {\n      \"attributes\" : {\n        \"type\" : \"SBQQ__QuoteLine__c\",\n        \"url\" : \"/services/data/v57.0/sobjects/SBQQ__QuoteLine__c/a0m5f000007ZYr6AAG\"\n      },\n      \"SBQQ__Quote__c\" : \"a0q5f0000057YAYAA2\",\n      \"Id\" : \"a0m5f000007ZYr6AAG\",\n      \"Name\" : \"QL-0001001\",\n      \"SBQQ__ProductName__c\" : \"AFB\"\n    }, {\n      \"attributes\" : {\n        \"type\" : \"SBQQ__QuoteLine__c\",\n        \"url\" : \"/services/data/v57.0/sobjects/SBQQ__QuoteLine__c/a0m5f000007ZYr7AAG\"\n      },\n      \"SBQQ__Quote__c\" : \"a0q5f0000057YAYAA2\",\n      \"Id\" : \"a0m5f000007ZYr7AAG\",\n      \"Name\" : \"QL-0001002\",\n      \"SBQQ__ProductName__c\" : \"Simple Amend Child Subscription\"\n    }, {\n      \"attributes\" : {\n        \"type\" : \"SBQQ__QuoteLine__c\",\n        \"url\" : \"/services/data/v57.0/sobjects/SBQQ__QuoteLine__c/a0m5f000007ZYr8AAG\"\n      },\n      \"SBQQ__Quote__c\" : \"a0q5f0000057YAYAA2\",\n      \"Id\" : \"a0m5f000007ZYr8AAG\",\n      \"Name\" : \"QL-0001003\",\n      \"SBQQ__ProductName__c\" : \"Simple Amend Child Asset\"\n    } ]\n  },\n  \"SBQQ__Type__c\" : \"Quote\"\n}\n```\n\n## Add product to quote\n\nThe Add Product to Quote API can be used when additional configurations are added to a single quote, either generated through the normal CPQ flow, through manual record creation, or through one that has already been created using the Create New Quote API above.\n\n<table><tbody><tr><td>\n\nHTTP method\n\n</td><td>\n\nPATCH\n\n</td></tr><tr><td>\n\nURL\n\n</td><td>\n\nhttps://&lt;yourInstance&gt;.salesforce.com/services/apexrest/LGK/request-quote\n\n</td></tr><tr><td>\n\nPath parameters\n\n</td><td>\n\nN/A\n\n</td></tr><tr><td>\n\nQuery parameters\n\n</td><td>\n\nN/A\n\n</td></tr></tbody>\n</table>The required parameters in the request body are:\n\n-   **configurableProductId**\n\n    the CPQ enabled configurable product ID\n\n-   **configurationId**\n\n    The CPQ configuration UUID received after saving a configuration\n\n-   **quoteId**\n\n    The Salesforce ID of the SBQQ\\_\\_Quote\\_\\_c record to add this configuration to\n\n\nIf included, **quoteLineGroupId** adds the newly created quote line to the specified quote line group.\n\nSample URL: `https://demologik.my.salesforce.com/services/apexrest/LGK/request-quote`\n\nSample request body:\n\n```\n{\n    \"configurableProductId\": \"01t5f000002SwERAA0\",\n    \"configurationId\": \"8978145d-35ba-4633-8139-e305ea4b9874\",\n    \"quoteId\": \"a0q5f0000057YATAA2\",\n}\n```\n\nSample response body:\n\n```\n{\n    \"attributes\": {\n        \"type\": \"SBQQ__Quote__c\",\n        \"url\": \"/services/data/v57.0/sobjects/SBQQ__Quote__c/a0q5f000005MNDhAAO\"\n    },\n    \"Name\": \"Q-00286\",\n    \"Id\": \"a0q5f000005MNDhAAO\",\n    \"SBQQ__LineItemCount__c\": 1,\n    \"SBQQ__LineItems__r\": {\n        \"totalSize\": 1,\n        \"done\": true,\n        \"records\": [\n            {\n                \"attributes\": {\n                    \"type\": \"SBQQ__QuoteLine__c\",\n                    \"url\": \"/services/data/v57.0/sobjects/SBQQ__QuoteLine__c/a0m5f00000AhsZsAAJ\"\n                },\n                \"SBQQ__Quote__c\": \"a0q5f000005MNDhAAO\",\n                \"Id\": \"a0m5f00000AhsZsAAJ\",\n                \"Name\": \"QL-0003664\",\n                \"SBQQ__ProductName__c\": \"Cloud Workload Configurator\"\n            }\n        ]\n    },\n    \"SBQQ__Type__c\": \"Quote\"\n}\n```\n\n[Salesforce CPQ Extension APIs Postman Collection](https://drive.google.com/file/d/1Slr7O1QIzfpAat-16x-vkuGeshzLv3Kw/view?usp=share_link):\n\n```\n{\n\t\"info\": {\n\t\t\"_postman_id\": \"2562674d-051d-4663-b3ed-482e6be1b78f\",\n\t\t\"name\": \"Logik Salesforce CPQ Extension APIs\",\n\t\t\"schema\": \"https://schema.getpostman.com/json/collection/v2.1.0/collection.json\"\"\n\t},\n\t\"item\": [\n\t\t{\n\t\t\t\"name\": \"Salesforce Authentication\",\n\t\t\t\"item\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Salesforce Authentication\",\n\t\t\t\t\t\"event\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"listen\": \"test\",\n\t\t\t\t\t\t\t\"script\": {\n\t\t\t\t\t\t\t\t\"exec\": [\n\t\t\t\t\t\t\t\t\t\"var jsonData = pm.response.json();\",\n\t\t\t\t\t\t\t\t\t\"pm.collectionVariables.set(\\\"salesforce_access_token\\\", jsonData.access_token);\"\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\"type\": \"text/javascript\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\t\"request\": {\n\t\t\t\t\t\t\"method\": \"POST\",\n\t\t\t\t\t\t\"header\": [],\n\t\t\t\t\t\t\"body\": {\n\t\t\t\t\t\t\t\"mode\": \"formdata\",\n\t\t\t\t\t\t\t\"formdata\": []\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"url\": {\n\t\t\t\t\t\t\t\"raw\": \"{{salesforce_domain}}/services/oauth2/token?username={{salesforce_username}}&password={{salesforce_password}}&grant_type=password&client_id={{salesforce_client_id}}&client_secret={{salesforce_client_secret}}\",\n\t\t\t\t\t\t\t\"host\": [\n\t\t\t\t\t\t\t\t\"{{salesforce_domain}}\"\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\"path\": [\n\t\t\t\t\t\t\t\t\"services\",\n\t\t\t\t\t\t\t\t\"oauth2\",\n\t\t\t\t\t\t\t\t\"token\"\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\"query\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"key\": \"username\",\n\t\t\t\t\t\t\t\t\t\"value\": \"{{salesforce_username}}\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"key\": \"password\",\n\t\t\t\t\t\t\t\t\t\"value\": \"{{salesforce_password}}\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"key\": \"grant_type\",\n\t\t\t\t\t\t\t\t\t\"value\": \"password\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"key\": \"client_id\",\n\t\t\t\t\t\t\t\t\t\"value\": \"{{salesforce_client_id}}\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"key\": \"client_secret\",\n\t\t\t\t\t\t\t\t\t\"value\": \"{{salesforce_client_secret}}\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"response\": []\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\": \"Logik CPQ Extension APIs\",\n\t\t\t\"item\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Create New Quote\",\n\t\t\t\t\t\"request\": {\n\t\t\t\t\t\t\"method\": \"POST\",\n\t\t\t\t\t\t\"header\": [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"key\": \"Content-Type\",\n\t\t\t\t\t\t\t\t\"value\": \"application/json\",\n\t\t\t\t\t\t\t\t\"type\": \"default\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"body\": {\n\t\t\t\t\t\t\t\"mode\": \"raw\",\n\t\t\t\t\t\t\t\"raw\": \"{\\n    \\\"configurableProductId\\\": \\\"{{configurableProductId}}\\\",\\n    \\\"configurationId\\\": \\\"{{configurationId}}\\\",\\n    \\\"pricebookId\\\": \\\"{{pricebookId}}\\\",\\n    \\\"accountId\\\": \\\"{{accountId}}\\\",\\n    \\\"opportunityId\\\": \\\"{{opportunityId}}\\\"\\n}\",\n\t\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\t\"raw\": {\n\t\t\t\t\t\t\t\t\t\"language\": \"json\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"url\": {\n\t\t\t\t\t\t\t\"raw\": \"{{salesforce_domain}}/services/apexrest/LGK/request-quote\",\n\t\t\t\t\t\t\t\"host\": [\n\t\t\t\t\t\t\t\t\"{{salesforce_domain}}\"\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\"path\": [\n\t\t\t\t\t\t\t\t\"services\",\n\t\t\t\t\t\t\t\t\"apexrest\",\n\t\t\t\t\t\t\t\t\"LGK\",\n\t\t\t\t\t\t\t\t\"request-quote\"\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"response\": []\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": \"Add to Existing Quote\",\n\t\t\t\t\t\"request\": {\n\t\t\t\t\t\t\"method\": \"PATCH\",\n\t\t\t\t\t\t\"header\": [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"key\": \"Content-Type\",\n\t\t\t\t\t\t\t\t\"value\": \"application/json\",\n\t\t\t\t\t\t\t\t\"type\": \"default\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"body\": {\n\t\t\t\t\t\t\t\"mode\": \"raw\",\n\t\t\t\t\t\t\t\"raw\": \"{\\n    \\\"configurableProductId\\\": \\\"{{configurableProductId}}\\\",\\n    \\\"configurationId\\\": \\\"{{configurationId}}\\\",\\n    \\\"quoteId\\\": \\\"{{quoteId}}\\\",\\n    \\\"quoteLineGroupId\\\": \\\"{{quoteLineGroupId}}\\\"\\n}\",\n\t\t\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\t\t\"raw\": {\n\t\t\t\t\t\t\t\t\t\"language\": \"json\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"url\": {\n\t\t\t\t\t\t\t\"raw\": \"{{salesforce_domain}}/services/apexrest/LGK/request-quote\",\n\t\t\t\t\t\t\t\"host\": [\n\t\t\t\t\t\t\t\t\"{{salesforce_domain}}\"\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\"path\": [\n\t\t\t\t\t\t\t\t\"services\",\n\t\t\t\t\t\t\t\t\"apexrest\",\n\t\t\t\t\t\t\t\t\"LGK\",\n\t\t\t\t\t\t\t\t\"request-quote\"\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t\"response\": []\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"auth\": {\n\t\t\t\t\"type\": \"bearer\",\n\t\t\t\t\"bearer\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"key\": \"token\",\n\t\t\t\t\t\t\"value\": \"{{salesforce_access_token}}\",\n\t\t\t\t\t\t\"type\": \"string\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t\"event\": [\n\t\t\t\t{\n\t\t\t\t\t\"listen\": \"prerequest\",\n\t\t\t\t\t\"script\": {\n\t\t\t\t\t\t\"type\": \"text/javascript\",\n\t\t\t\t\t\t\"exec\": [\n\t\t\t\t\t\t\t\"let sfToken = pm.collectionVariables.get('salesforce_access_token');\",\n\t\t\t\t\t\t\t\"if(sfToken == null) {\",\n\t\t\t\t\t\t\t\"    console.error('Run Salesforce Authentication first')\",\n\t\t\t\t\t\t\t\"}\"\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"listen\": \"test\",\n\t\t\t\t\t\"script\": {\n\t\t\t\t\t\t\"type\": \"text/javascript\",\n\t\t\t\t\t\t\"exec\": [\n\t\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t],\n\t\"event\": [\n\t\t{\n\t\t\t\"listen\": \"prerequest\",\n\t\t\t\"script\": {\n\t\t\t\t\"type\": \"text/javascript\",\n\t\t\t\t\"exec\": [\n\t\t\t\t\t\"\"\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"listen\": \"test\",\n\t\t\t\"script\": {\n\t\t\t\t\"type\": \"text/javascript\",\n\t\t\t\t\"exec\": [\n\t\t\t\t\t\"\"\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"variable\": [\n\t\t{\n\t\t\t\"key\": \"salesforce_domain\",\n\t\t\t\"value\": \"https://demologik6.my.salesforce.com\"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"salesforce_username\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"salesforce_password\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"salesforce_client_id\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"salesforce_client_secret\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"salesforce_access_token\",\n\t\t\t\"value\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"configurableProductId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"configurationId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"pricebookId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"accountId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"opportunityId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"quoteId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t},\n\t\t{\n\t\t\t\"key\": \"quoteLineGroupId\",\n\t\t\t\"value\": \"\",\n\t\t\t\"type\": \"default\"\n\t\t}\n\t]\n}\n```\n\n"}}