{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":37323,"path":"order-management/cpq_reconfigure_api.md","title":"The CPQ Reconfigure API","bundle":null,"doc_type":null,"release":"australia","body":"\n# The CPQ Reconfigure API\n\nThe CPQ Reconfigure API headlessly invokes CPQ services to reconfigure a quote bundle.\n\nThe CPQ Reconfigure API is a custom Salesforce API that invokes CPQ services headlessly. Unlike RFQ, this API is used to reconfigure an existing quote bundle.\n\n## Prerequisites\n\nThe Runtime Client Token must be set in the Admin Custom Settings page in Salesforce. The token must include an origin that matches the CPQ URL, which cannot include a trailing slash \\(/\\) character.\n\nThe Runtime Configuration URL must also be set in the Admin Custom Settings page. In most cases, this should match the administration URL on the same page.\n\nIn Salesforce Setup, go to Security, and then to Remote Site Settings. Add a new remote site with your CPQ domain as the URL.\n\n\\[Omitted image \"cpq-salesforce-remote-site-settings.png\"\\] Alt text: Remote sites list\n\n**Important:** This API relies on **uniqueIdentifier** to match child lines. If you don't have unique **uniqueIdentifier** values for products, child lines may update incorrectly.\n\n## API details\n\nEndpoint: `/services/apexrest/LGK/cpq-quote-lines/reconfigure`\n\n**Note:** Request endpoints and parameters are case sensitive.\n\nMethods: Receives and returns `application/json`.\n\nPATCH: The method currently only supports two fields, `configurationId` and `configurableQuoteLineId`.\n\nResponse: A quote \\(`SBQQ__Q__c`\\) record.\n\n**Note:** The quote info returned will include info on all quote lines, not just the ones being added by the request. For example, if the configuration with three line items gets added to a quote that already had two lines on it, the quote info returned will included all five lines.\n\nRequest example:\n\n```\n{\n\t\"configurationId\":\"86ec190e-cba8-4b1d-a2dc-ba47714a22b5\",\n\t\"configurableQuoteLineId\":\"a137d00000977oWAAQ\"\n}\n```\n\nResponse example:\n\n```\n{\n\"attributes\": {\n\"type\": \"SBQQ__Quote__c\",\n\"url\": \"/services/data/v56.0/sobjects/SBQQ__Quote__c/a0zR0000003f3GLIAY\"\n},\n\"Name\": \"Q-00090\",\n\"Id\": \"a0zR0000003f3GLIAY\",\n\"SBQQ__LineItemCount__c\": 4,\n\"SBQQ__LineItems__r\": {\n\"totalSize\": 4,\n\"done\": true,\n\"records\": [\n{\n\"attributes\": {\n\"type\": \"SBQQ__QuoteLine__c\",\n\"url\": \"/services/data/v56.0/sobjects/SBQQ__QuoteLine__c/a0vR0000005LPRxIAO\"\n},\n\"SBQQ__Quote__c\": \"a0zR0000003f3GLIAY\",\n\"Id\": \"a0vR0000005LPRxIAO\",\n\"Name\": \"QL-0000122\",\n\"SBQQ__ProductName__c\": \"LGK Machine\"\n},\n{\n\"attributes\": {\n\"type\": \"SBQQ__QuoteLine__c\",\n\"url\": \"/services/data/v56.0/sobjects/SBQQ__QuoteLine__c/a0vR0000005LPRyIAO\"\n},\n\"SBQQ__Quote__c\": \"a0zR0000003f3GLIAY\",\n\"Id\": \"a0vR0000005LPRyIAO\",\n\"Name\": \"QL-0000123\",\n\"SBQQ__ProductName__c\": \"Analytics Software\"\n},\n{\n\"attributes\": {\n\"type\": \"SBQQ__QuoteLine__c\",\n\"url\": \"/services/data/v56.0/sobjects/SBQQ__QuoteLine__c/a0vR0000005LPS2IAO\"\n},\n\"SBQQ__Quote__c\": \"a0zR0000003f3GLIAY\",\n\"Id\": \"a0vR0000005LPS2IAO\",\n\"Name\": \"QL-0000124\",\n\"SBQQ__ProductName__c\": \"Extended Warranty\"\n},\n{\n\"attributes\": {\n\"type\": \"SBQQ__QuoteLine__c\",\n\"url\": \"/services/data/v56.0/sobjects/SBQQ__QuoteLine__c/a0vR0000005LPS3IAO\"\n},\n\"SBQQ__Quote__c\": \"a0zR0000003f3GLIAY\",\n\"Id\": \"a0vR0000005LPS3IAO\",\n\"Name\": \"QL-0000125\",\n\"SBQQ__ProductName__c\": \"Scanner\"\n}\n]\n},\n\"SBQQ__Type__c\": \"Quote\"\n}\n```\n\nRequests can be made directly through Apex. The argument is a `Map<String,Object>` with the same fields used in the REST API. For example:\n\n```\nMap<String, Object> requestBody = new Map<String, Object>{\n  'configurableQuoteLineId' => '01t8a000005hldvAAA',\n  'configurationId' => '79a3ffdd-7dd0-41f6-8700-4bd7506407c7'    \n};\nString result = LGK.CpqReconfigureApiController.reconfigure(requestBody);\n```\n\nThe response is a JSON formatted string representing the quote object, similar to the response in the REST APIs.\n\n## Custom field mapping\n\nIf a field on the Quote Line object in Salesforce has a name that matches, custom values can be written from the `extended` or `pricing` information in a CPQ product.\n\n"}}