Runtime APIs
Summarize
Summary of Runtime APIs
ServiceNow CPQ provides Runtime APIs to enable customers and end users to create, update, save, and manipulate product configurations efficiently. These APIs support standard CRUD operations on CPQ configurations and allow retrieval of Bill of Materials (BOM) data, facilitating integration with front-end applications and seamless configuration management.
Show less
Runtime API Setup
Runtime API calls use a base URL formatted as https://<tenant>.<sector>.<cpq>/api/, where tenant and sector correspond to your environment details. Authentication requires two HTTP headers in each request:
- origin: Specifies the runtime client origin configured in CPQ Admin settings.
- authorization: Bearer token used for secure access.
Use open source API collections for quick testing and integration.
Key API Operations
Create Configuration
Start a new CPQ configuration by sending the configurable product ID. The response includes a unique configuration UUID used for subsequent operations. You can optionally initialize specific field values during creation.
Reconfigure Configuration
Modify an existing configuration by passing the product ID and existing configuration UUID. This returns a new configuration UUID, which should be used for all further updates and saves in the session.
Update Configuration
Update field values within a loaded configuration by specifying the configuration UUID and desired field changes. Optional query parameters control whether the response includes only changed data (delta=true) or the full configuration, and whether to save the changes persistently (save=true).
Save Configuration
Saving is a specialized update that finalizes the configuration session. It triggers backend actions such as populating Salesforce CPQ custom objects and sending data to configured webhooks. Once saved, further edits require starting a new configuration or reconfiguration session.
BOM Retrieval
Retrieve the Bill of Materials for a configuration by providing the configuration UUID. The API supports retrieving the entire BOM or filtered subsets like sales or manufacturing BOMs. Additional BOM types can be defined per product.
Practical Implications for ServiceNow Customers
- Runtime APIs enable dynamic, programmatic control over CPQ configurations, improving automation and integration with custom front-end applications.
- Authentication and origin headers ensure secure and authorized API access aligned with your CPQ tenant setup.
- Create, reconfigure, update, and save APIs support a full lifecycle of configuration management via RESTful calls.
- BOM APIs allow retrieval of detailed product assemblies, critical for sales, manufacturing, and inventory processes.
- Use of query parameters in update and save endpoints provides flexibility in response payload size and backend processing.
- After saving a configuration, the session is closed, requiring a new start for further edits to ensure data integrity.
Overall, these APIs empower ServiceNow customers to extend CPQ capabilities, automate configuration workflows, and integrate configuration data into broader enterprise processes effectively.
CPQ provides a set of APIs for building front-end applications and manipulating configurations. These are commonly referred to as buyside or runtime APIs and are used by customers or end users to create, update and save CPQ configurations.
Runtime APIs support the standard create, read, update, and delete functions for CPQ configurations, along with the ability to retrieve bill of materials (BOM) data from CPQ.
To make CPQ runtime APIs accessible and provide a quick start to end developers, see the open source repositories for API collections that can easily be imported and tested.
Runtime API setup
The base URL format for all runtime API calls is https://<tenant>.<sector>.<cpq>/api/, where <tenant> is the listed tenant name and<sector> is the
appropriate sector that the environment is located on (usually test or prod).
In Salesforce, you can find the CPQ tenant URL by going into Setup, searching for Custom Settings in the Quick Find box, and then clicking Manage next to CPQ Tenant.
Runtime API calls are authenticated through a combination of a bearer token and the defined origin in the runtime client. The origins of the runtime application are specified when a runtime client is created in the CPQ Admin settings.
To authorize these API calls, you must add two headers to the each runtime API request:
| Header | Key | Value |
|---|---|---|
| Origin Header | origin | <runtimeClientOrigin> |
| Authorization Header | authorization | Bearer <runtimeToken> |
Sample headers:
- origin: localhost
- authorization: Bearer vEqzz4BVkb15Le11En8axEuN71FA6Vt_cw
Create a configuration
To start a new configuration via the APIs, the create configuration call passes the ID of the configurable product. In response, it receives a CPQ configuration ID that can be used to specify this configuration in later calls.
| HTTP method | POST |
| URL | https://<tenant>.<sector>.logik.io/api/ |
| Path parameters | N/A |
| Query parameters | N/A |
The two key pieces of the payload are:
- The ID of a CPQ enabled product, with a blueprint that is deployed
- The CPQ configuration UUID that is being reconfigured
Sample URL:
https://dev1.test.cpq/api/
Sample payload:
{
"sessionContext":
{
"stateful": true
},
"partnerData":
{
"product":
{
"configuredProductId": "<Id of a Logik.io Enabled Product>",
}
},
"fields": []
}
{
“variableName”: “<Field Name>”, “value”: “<Field Value>”
}Sample response:
{
"fields": [<ARRAY OF FIELD OBJECTS>],
"uuid": "08176434-9b1e-4fc8-b2c4-8aba2c35fda3",
"revision": 0,
"relatedChanges":
[
{
"key": "products",
"type": "PRODUCT"
}
],
"valid": true,
"messages": [],
"productChange": true,
"products": [<ARRAY OF PRODUCTS IN CONFIGURATION>],
"total": 30,
"layouts": [<ARRAY OF LAYOUTS>]
}
Reconfigure a configuration
The reconfigure API call is similar to the create configuration call. The reconfigure call passes the ID of the configurable product and an existing CPQ configuration ID, and in return receives a new Configuration ID with the same field data as the prior configuration but allowing for changes to be made.
| HTTP method | POST |
| URL | https://<tenant>.<sector>.cpq/api/ |
| Path parameters | N/A |
| Query parameters | N/A |
The two key pieces of the payload are:
- The ID of a CPQ enabled product, with a blueprint that is deployed
- The CPQ configuration UUID that is being reconfigured
Sample URL:
https://dev1.test.Logik/api/
Sample payload:
{
"sessionContext":
{
"stateful": true
},
"partnerData":
{
"product":
{
"configuredProductId": "<Id of a Logik.io Enabled Product>",
"configurationAttributes":
{
"LGK__ConfigurationId__c": "<uuid>"
}
}
},
"fields": []
}
Sample response:
{
"fields": [<ARRAY OF FIELD OBJECTS>],
"uuid": "d98d60cd-9379-4b7b-86fd-de828c340f80",
"revision": 0,
"relatedChanges":
[
{
"key": "products",
"type": "PRODUCT"
}
],
"valid": true,
"messages": [],
"productChange": true,
"products": [<ARRAY OF PRODUCTS IN CONFIGURATION>],
"total": 30,
"layouts": [<ARRAY OF LAYOUTS>]
}
Update a configuration
Updating a configuration requires a configuration to be loaded using either the create configuration or reconfigure API calls. The Update Configuration call passes a CPQ Configuration ID and any desired field values, and in response receives the updated configuration from CPQ.
| HTTP method | PATCH | |||
| URL | https://<tenant>.<sector>.cpq/api/ | |||
| Path parameters | N/A | |||
| Query Parameters | Name | Allowed Value | Required? | Default if not specified |
| delta | true | false | optional | true | |
| save | true | false | optional | false | |
Query parameters:
delta
If delta=true, CPQ sends back only data that has changed based on the update that was sent. This is the default behavior.
If delta=false, CPQ sends back the entire configuration and BOM data in response.
save
If save=true, CPQ saves this configuration and (depending on the settings) performs additional actions such as sending the data to a webhook or writing the data into custom objects in Salesforce. This is the behavior of the save configuration call.
If save=false, CPQ updates this configuration and sends the updated data back in the response. This is the default behavior, and this is the behavior of the update call.
Sample URL:
https://dev1.test.logik.io/api/fbc3d32c-7f86-4461-b144-986a0e8a5768
Sample payload:
{
"fields":
[
{
"variableName": "orderQty",
"value": 3
}
]
}
Sample response:
{
"fields": [],
"uuid": "fbc3d32c-7f86-4461-b144-986a0e8a5768",
"revision": 0,
"relatedChanges":
[
{
"key": "products",
"type": "PRODUCT"
}
],
"valid": true,
"messages": [],
"productChange": true,
"products": null
}
Save a configuration
Saving a configuration is a subset of the update configuration. It requires a configuration to be loaded using either the create configuration or reconfigure API calls. The save configuration call passes a CPQ configuration ID and any desired field values, and in response receives the updated configuration from CPQ.
If you are using Salesforce as a backend, when the save API is called, CPQ asynchronously creates and populates the CPQ custom objects Configuration Field Data Sets and Configuration Line Items with the appropriate data.
If your CPQ instance has a webhook configured, when the save API is called, the data is sent to the endpoint specified in the webhook setting. See Webhooks.
| HTTP method | PATCH | |||
| URL | https://<tenant>.<sector>.cpq/api/ | |||
| Path parameters | N/A | |||
| Query Parameters | Name | Allowed Value | Required? | Default if not specified |
| delta | true | false | optional | true | |
| save | true | false | optional | false | |
Query parameters:
delta
If delta=true, CPQ sends back only data that has changed based on the update that was sent. This is the default behavior.
If delta=false, CPQ sends back the entire configuration and BOM data in response.
save
If save=true, CPQ saves this configuration and (depending on the settings) performs additional actions such as sending the data to a webhook or writing the data into custom objects in Salesforce.
If save=false, CPQ updates this configuration and sends the updated data back in the response. This is the behavior of the update call.
Sample cURL request:
curl --location --request PATCH 'https://mpanigrahi-demo.demo01.logik.io/api/6d0ef6fd-4c88-44f3-a296-b03421c369c6' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Origin: https://mpanigrahi-demo.demo01.logik.io' \
--header 'Authorization: <<RUNTIME TOKEN>>' \
--header 'Cookie: LGKSESSION=NDA5OWJmNmEtNDhhOS00YTc4LTk3ODktZTg0OGYyOGIwMjZk' \
--data '{"fields":[{"variableName":"name_d1","value":"megha","dataType":"text"}],"responseState":{"setPagination":{"collections":{"pageSize":10,"pageNumber":0},"fields":{"pageSize":10,"pageNumber":0},"componentTypes":{"pageSize":10,"pageNumber":0}},"defaultPagination":{"pageSize":10,"pageNumber":0},"searchValues":{}}}'
Sample response:
{
"fields": [<ARRAY OF FIELD OBJECTS>],
"uuid": "8817655d-7a11-41ef-a9fd-59c2855a3e4b",
"revision": 1,
"valid": true,
"messages": [],
"productChange": false,
"products": [<ARRAY OF PRODUCTS IN CONFIGURATION>],
"total": 0
}
BOM APIs
The BOM APIs are useful for retrieving the final output of configuration. The BOM APIs can be used to retrieve the entire BOM, or specific subsets, such as sales or manufacturing BOMs.
The Get BOM call passes a CPQ Configuration ID and in return receives the current BOM generated by the current state of the configuration. There are 3 built in BOM types: “all”, “sales” and “manufacturing”. Additional BOM types can be dynamically added by setting the bomType field on the product.
| HTTP method | GET | ||
| URL | https://<tenant>.<sector>.cpq/api/<uuid>/bom/<bomType> | ||
| Path Parameters | Name | Allowed Value | Required? |
| <uuid> | 32 character CPQ configuration UUID | required | |
| <bomType> | name of the BOM to retrieve | optional | |
| Query parameters | N/A | ||
Sample response:
{"products": [
{
"id": "01t5f000006QKysAAG",
"quantity": 1,
"bomType": "Sales",
"orderNumber": 10,
"type": "accessory",
"name": "Amend Flow Bundle Sub",
"partnerId": "01t5f000006QKysAAG",
"productCode": "AFBC-SC",
"externalId": "",
"productFamily": "Miscellaneous",
"description": "",
"uom": "",
"price": 5,
"extPrice": 5,
"level": 0,
"rollUpPrice": 5
},
{
"id": "01t5f000006QKz2AAG",
"quantity": 1,
"bomType": "Sales",
"orderNumber": 20,
"type": "accessory",
"name": "Amend Flow Bundle Asset",
"partnerId": "01t5f000006QKz2AAG",
"productCode": "AFBC2-SC",
"externalId": "",
"productFamily": "Miscellaneous",
"description": "",
"uom": "",
"price": 25,
"extPrice": 25,
"level": 0,
"rollUpPrice": 25
}
]}
For information about additional configuration APIs and sample scenarios, see Additional configuration APIs.