Add a price rule
const url = 'https://example.com/price-rules';const options = { method: 'POST', headers: { cookie: 'bottle.session_token=<bottle.session_token>', 'Content-Type': 'application/json' }, body: '{"name":null,"audience":"consumer","customerId":null,"rateSetId":null,"scope":"product","productId":null,"gasTypeId":null,"categoryId":null,"counting":"stepped","steps":[{"kind":"percent_off","fromQuantity":1,"percent":1}],"active":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/price-rules \ --header 'Content-Type: application/json' \ --cookie bottle.session_token=<bottle.session_token> \ --data '{ "name": null, "audience": "consumer", "customerId": null, "rateSetId": null, "scope": "product", "productId": null, "gasTypeId": null, "categoryId": null, "counting": "stepped", "steps": [ { "kind": "percent_off", "fromQuantity": 1, "percent": 1 } ], "active": true }'Who it is for (audience, with customerId for one customer or rateSetId for a rate set), what it covers (scope, with the productId, gasTypeId or categoryId it names), and the price from each quantity (steps, read stepped or bulk). Rules never touch deposits, rent or delivery, and quantity counts per product across the whole order.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Consumer: everybody who is not a trade customer, signed in or not. trade: trade customers. rate_set: the members of one rate set, named by rateSetId. customer: one customer, named by customerId.
UUID v7
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8fUUID v7
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8fWhat the rule covers: one product (productId), every size of a gas type (gasTypeId), a shop category (categoryId), or everything sold. Never deposits, rent or delivery.
UUID v7
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8fUUID v7
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8fUUID v7
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8fStepped: each step prices only the units within it (“first 5 at £38, next 5 at £36, then £34.20”). bulk: the highest step reached prices every unit (“10 or more and all of them are £34.20”).
Responses
Section titled “Responses”Added
object
Consumer: everybody who is not a trade customer, signed in or not. trade: trade customers. rate_set: the members of one rate set, named by rateSetId. customer: one customer, named by customerId.
UUID v7
UUID v7
What the rule covers: one product (productId), every size of a gas type (gasTypeId), a shop category (categoryId), or everything sold. Never deposits, rent or delivery.
UUID v7
UUID v7
UUID v7
Stepped: each step prices only the units within it (“first 5 at £38, next 5 at £36, then £34.20”). bulk: the highest step reached prices every unit (“10 or more and all of them are £34.20”).
UUID v7
Example
{ "audience": "consumer", "customerId": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "rateSetId": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "scope": "product", "productId": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "gasTypeId": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "categoryId": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "counting": "stepped", "steps": [ { "kind": "percent_off" } ], "id": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f"}Not signed in
object
Example
{ "error": "not_found", "message": "Customer not found"}Not a member, or without the permission this needs
object
Example
{ "error": "not_found", "message": "Customer not found"}Validation failed (validation), or the customer, product, gas type or category named is not this business’s (unknown_target, with the field)
object
Example
{ "error": "unknown_target", "field": "customerId"}