Docs

Docs / Data Feed / Pricing rules

For Data Feed stores
Endpoint · Preview a pricing rule

POST/pricing-rules/preview

See what a new rule, or a change to one, would do to your prices before you save it. Saves nothing.

Needs Pricing rules: Read and writeBase URL https://backend.fflmonkey.com/api/v1Counts 1 toward 120 a minute

Fields

Needs Pricing rules: Read and write, like the save it stands in for. It is the preview your Pricing screen shows, and it saves nothing: no rule, no price and no change are written or announced. Send one of two bodies:

  • A new rule: the body you would send to POST /pricing-rules, checked as a create is. It is previewed where that create would put it.
  • A change to a rule: rule_id and the fields you would send to PATCH /pricing-rules/{id}, laid over the rule as the PATCH would lay them. rule_id alone previews the rule as it is.
FieldTypeRule
rule_idoptionalintegerA stored rule to preview a change to. With it, every other field is optional and is laid over the rule as a PATCH would lay it. Without it, the body is a new rule's.
nameoptionalstringUp to 120 characters. Required for a new rule.
markup_percentageoptionalstring, number or nullPercent added to the base, -100 to 999.99, at most two decimals, or null for none. Best sent as a string, such as "22.50".
markup_value_fixedoptionalstring, number or nullDollars added after the percentage, -100000 to 100000, at most two decimals, or null for none.
apply_markup_price_tooptionalstringThe base the markup is added to: cost, msrp, map_then_cost or map_then_msrp. Required for a new rule.
apply_only_when_has_mapoptionalbooleantrue skips a product whose offer has no MAP above its cost.
apply_only_when_has_msrpoptionalbooleantrue skips a product whose offer has no MSRP.
enforce_map_flooroptionalboolean or nulltrue never prices below MAP, false may, null follows your store's setting.
categoriesoptionallist of stringsCategory slugs from GET /categories; each takes in the categories below it. Empty or left out: any.
manufacturersoptionallist of stringsBrand slugs from GET /manufacturers. Empty or left out: any.
product_classesoptionallist of stringsProduct class slugs from GET /product-classes. Empty or left out: any.
distributorsoptionallist of stringsDistributor slugs, as a product's sourced_from names them. Empty or left out: any.
upcsoptionallist of stringsUPCs, each up to 32 characters. Empty or left out: any.
from_priceoptionalstring, number or nullThe lowest distributor cost the rule applies to, 0 to 9999999.99, at most two decimals, or null for no lower bound.
to_priceoptionalstring, number or nullThe highest distributor cost it applies to, on the same terms, or null for no upper bound.
disabledoptionalbooleantrue keeps the rule and never applies it.
auto_placeoptionalbooleanDefault true: directly above the first rule that is broader than this one. false: last. Refused with rule_id.
acknowledge_zero_matchoptionalbooleanAccepted, and changes nothing: a preview is never refused for matching nothing, it says so in zero_match.

Each list takes at most 1,000 entries. Money with a third decimal is refused, never rounded. A rule's place is not a field: sort_order is refused. Move a rule with POST /pricing-rules/reorder.

10 previews a minute per store, pricing rules and restrictions together, whichever key asks, on top of the key's own limit: each one works part of your catalog out twice, for up to five seconds.

What it answers

How many products the rule names, and up to 25 real products worked out both ways, those that would change first.

FieldMeaning
scope_countHow many products in the catalog its conditions name, counted up to limits.max_count. The whole catalog when narrowed is false.
narrowedfalse when its conditions could not be counted (no condition at all, or a cost range), so scope_count is the whole catalog.
scope_cappedThe count stopped at limits.max_count: there are more.
scope_exactfalse when a condition is judged per offer (MAP or MSRP only, a cost range, a stock floor), so scope_count is an upper bound and the samples are the truth.
catalog_countProducts in the catalog, up to limits.max_count.
sampledProducts worked out both ways, up to 200.
changedOf those, how many would change.
timed_outThe five seconds ran out while sampling: sampled is what was done.
zero_matchIt names no product in the catalog, so saving it would ask for acknowledge_zero_match.
samplesUp to limits.max_samples products, those that would change first. See below.
limitsThe limits the answer was worked out under: max_count (100,001), max_samples (25) and timeout_seconds (5).

Each sample

FieldMeaning
product_idThe product, as GET /products/{id} takes it.
titleIts name.
upcIts UPC, or null.
image_urlIts thumbnail, or null.
beforeThe product as your store stands now. See below.
afterThe product once the rule is saved.
changedIts price, whether it is sold, why not, or where it comes from would change.

Each side, before and after

FieldMeaning
priceThe price your store would sell it at, or null when it would not be sold.
visibleWhether your store would sell it.
hidden_reasonWhy it would not be sold, such as restricted, no_offers or no_price, or null when it would.
sourced_fromThe distributor it would come from, in_house for your own stock, or null.
applied_rule_idThe pricing rule that would price it, or null: your default margin, or the rule you are previewing while it has no id yet.
cost_priceThe winning distributor offer's cost; null for your own stock.
map_priceThe winning offer's MAP, or null.
msrp_priceThe winning offer's MSRP, or null.
this_ruletrue when the rule you are previewing would price it: the new rule, or the stored rule you are changing, which keeps its own id. Pricing rule previews only.

Returns

  • 200What saving it would do, in data. Nothing was saved.
  • 404pricing_rule_not_found: your store has no rule with that rule_id.
  • 422validation_failed: a field broke a rule, as it would on the save.
  • 429rate_limited: more than 10 previews in a minute for this store. Wait for Retry-After seconds.

This endpoint can also answer 401 invalid_api_key, 403 license_not_active, 403 product_not_included, 403 insufficient_scope and 429 rate_limited.

Example

FFL Monkey Data Feed API, version 1. Questions: Support in your FFL Monkey account, or [email protected].