Your data
Commercial rules
Minimum order, payments, discounts, codes, extras, order changes.
What it does in the conversation
The assistant applies your rules while it builds the cart and the total: it tells the customer how much is missing to the minimum order, offers only your payment methods, applies discounts and friend codes, adds the extra for heavy items, and accepts changes to a sent order only within your window. Every rule is a choice among those GroceryAI already applies: no free text ends up in the assistant's instructions.
The rules are versioned: every change makes a new version, you can go back to an earlier one, and the preview shows what the customer will read before you save.
Customer: How much is missing for the minimum order?
Assistant: Your cart is €21.40: the minimum order is €25.00, so €3.60 is missing. Shall I suggest something?
Minimum order 25.00 in the example regole.json. Illustrative example, with the products of the template and an invented store.
If it is missing
- Without a minimum order, any amount is accepted.
- Without bank details, bank transfer cannot be offered.
- Without discounts and friend codes, no discount is applied and a code the customer writes is not valid.
- Without the change window, the default applies: changes up to 2 hours before delivery.
- Without heavy-item extras, cases and sacks travel at no extra cost.
The fields
Required: without it the product is not sold the way the customer expects. Recommended: without it there is a declared fallback, but the experience is poorer. Optional: an improvement.
regole.json (PUT /v1/rules and the Rules page)
min_order_amountrequired- Type
- amount or null
- Example
25.00- Rule
- null or 0.00 = no minimum.
payment_methodsrequired- Type
- list
- Example
cash, card_pos, bank_transfer- Rule
- At least one of: cash, card_pos, prepaid_link, bank_transfer.
zonesrequired- Type
- list
- Example
centro · 4.50 · 60.00- Rule
- Cost and free threshold per zone; threshold never below the cost.
bank_transferrecommended- Type
- holder, IBAN, BIC, bank
- Example
IT60 X054 …- Rule
- Required if bank_transfer is a payment method; IBAN with its check digits.
prepaid_flowoptional- Type
- choice
- Example
none- Rule
- operator_link: your staff sends the payment link; none.
cash_requires_own_deliveryoptional- Type
- yes/no
- Example
true- Rule
- Cash only when you deliver with your own vehicles (default yes).
discountsoptional- Type
- percentages and days
- Example
welcome 5 · comeback 8 after 45 days- Rule
- Welcome, comeback after N days, loyalty tiers (days increasing), not on offers (default).
friend_codesoptional- Type
- codes and percentage
- Example
BENVENUTO5 · 5- Rule
- Letters and digits, 3 to 40; the customer can write them in any case.
heavy_extrasoptional- Type
- terms or weight, free units, rate
- Example
cassa · 8 free · 0.40- Rule
- At least a term or a minimum weight.
order_edit_window_hoursoptional- Type
- hours
- Example
3- Rule
- Up to how many hours before delivery the customer can change the order (default 2).
checkout_upselloptional- Type
- terms, how many
- Example
pile, sacchetti · 2- Rule
- Items proposed at checkout, up to 5.
cart_reminderoptional- Type
- yes/no
- Example
true- Rule
- Reminder of a cart left half-way.
slot_on_sendoptional- Type
- choice
- Example
propose- Rule
- set_first: the assistant sets the first window; propose: it asks.
Download the template
- Example regole.jsonregole.json
- Schema of regole.jsonregole.schema.json
Frequent errors and their message
SOGLIA_SOTTO_IL_COSTO«The free delivery threshold cannot be lower than the delivery cost.»
What to do: Raise the threshold or leave it empty.
COORDINATE_BANCARIE_ASSENTI«To offer bank transfer, the shop's account details are needed first.»
What to do: Fill in holder and IBAN, then add bank transfer.
IBAN_NON_VALIDO«The IBAN check digits do not match.»(explanation of this guide: Core returns the code)
What to do: Copy it again from your bank: spaces and lowercase are accepted.
GRADINI_NON_IN_ORDINE«Loyalty tiers go from the shortest to the longest period.»(explanation of this guide: Core returns the code)
What to do: Order them by increasing days.
VERSIONE_CAMBIATA«Someone changed the rules in the meantime. Reload the page and make your change again.»
What to do: Send based_on_version equal to the current version.
How to send it
- From the portalIn part
Today: Shop rules → minimum order, payment methods, cost and threshold per zone, versions and preview. Coming: bank details, discounts, friend codes, heavy-item extras, change window, upsell, reminder.
- From the APIComing
GET/PUT /v1/rules and POST /v1/rules/preview exist; the key permissions rules:read and rules:write cannot be created from the portal yet.
- JSON documentComing
regole.json: the same document, to download and reload (for those who manage several stores).
Availability as measured on the live service on 30 October 2026.
Write the rules (start from the current version)
curl
curl -X PUT "https://oxjqgjbiltoviwldailg.supabase.co/functions/v1/core-api/v1/rules" \
-H "Authorization: Bearer $GAI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: regole-2026-11-02" \
-d '{"based_on_version":3,"min_order_amount":"25.00","payment_methods":["cash","card_pos"],"zones":[{"zone_slug":"centro","delivery_cost":"4.50","free_threshold":"60.00"}],"order_edit_window_hours":3}'Node.js (18+)
const risposta = await fetch("https://oxjqgjbiltoviwldailg.supabase.co/functions/v1/core-api/v1/rules", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.GAI_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
based_on_version: 3,
min_order_amount: "25.00",
payment_methods: ["cash", "card_pos"],
zones: [{ zone_slug: "centro", delivery_cost: "4.50", free_threshold: "60.00" }],
order_edit_window_hours: 3,
}),
});
console.log(risposta.status, await risposta.json());