Request Format
See Processor API Definitions for API contracts.
The Processor API supports a number of built in objects as well as custom ones defined in the Builder API.
Pre-Defined
- Basket
- Coupon Codes
- Costs
- Settings
Basket
Basket supports items
as well as custom properties defined using the Properties endpoints in the Builder API.
items
have two built in properties: Quantity
and Price
as well as custom properties. E.g.
{
"basket": {
"items": [
{
"quantity": 2,
"price": 58.99,
"customItemProperty": "value"
}
],
"customBasketProperty": "value"
}
}
Coupon Codes
Coupon codes are an array of objects with one property: code
. E.g.
{
"couponCodes": [
{
"code": "ABC123"
}
]
}
Costs
Costs are an array of objects with a name
and value
property. E.g.
{
"costs": [
{
"name": "Shipping",
"value": 5.99
}
]
}
Settings
See Processor API Definitions for more details on the settings
object. Some additional notes are below.
- The
explain
flag is useful for understanding what the engine is doing. It should only be used for diagnostics. Note, if a discount doesn't appear in the explain list it generally means there was an error loading the discount. E.g. it references an expression that hasn't been published to live. utcNow
- this is generally used for previewing discounts in the future.dataInstance
- see Publishing Model for details on how this is used
Default Parent Properties
Some default parent properties that can be passed to the Processor API are created when you create a project: context
and customer
. An example is below.
E.g.
{
"context": {
"currencyCode": "USD"
},
"customer": {
"email": "test@example.com"
}
}
Currency Code
If you are using discounts that work with money (as opposed to content discounts for example) then you need to provide a currencyCode
property in the context
property.
See the Currencies page for more details.
Customer
The email address is used for coupon codes that are restricted to specific users.
Custom
Using the Builder API you can create new properties. Parent properties are defined using the Object
DataType
on a property. Objects allow child properties.
E.g. if you create an object property called custom
and a property called customProperty
you would pass these to the Processor API like this:
{
"context": {
"currencyCode": "USD"
},
"custom": {
"customProperty": "test"
}
}
See Properties page to see the data types supported.