create-mapping-rule
Create a mapping rule and return its id. A mapping rule computes what a channel field is sent, instead of copying a product column across unchanged: a percentage off the price, a fallback chain across UPC/EAN/ISBN, a conditional literal. A field mapping points at one by ruleId on apply-product-template-mappings, and rules are company-wide, so one rule can back the same field on every template.
Nothing changes on any listing from this call: wire the returned id into templates with apply-product-template-mappings ({ fieldName: "price", scope: "common", ruleId }), then republish. Check the arithmetic first with preview-mapping-rule.
conditions is an array of branches evaluated in order, each { conditions, successful_output, failed_output }. The inner conditions is an array of AND-groups that are ORed together. An output is { template, filters, type, round, charm_price }: template is a "{{property}}" string, type: "number" keeps a numeric field numeric, and filters transform the value.
Worked example — send price 5% under catalog price: [{"conditions":[[{"type":"number","option":"has value","property":"price","value":""}]],"successful_output":{"template":"{{price}}","type":"number","filters":[{"type":"math","option":"calculate","attribute":"price","additional_settings":{"items":[{"math_option":"multiply","value":0.95}],"round":"","charm_price":false}}]},"failed_output":null}]
math_option is multiply, divide, add or subtract and items chain in order; round is "", "round up", "round down" or "full".
charm_price exists at BOTH levels and they do different things. On the output (sibling of template/filters) it rounds UP to end in .99, so 37.43 becomes 37.99 — that is the one you usually want. Inside a filter's additional_settings it only shaves a cent off a value that is already a whole number, so 38 becomes 37.99 but 37.43 is left alone.
Authenticated via bearer token.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"conditions": "<conditions>"
},
"name": "create-mapping-rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Rule name | |
| conditions | Yes | Array of rule branches — see the worked example above | |
| description | No | Free-text description | |
| failedOutput | No | Legacy top-level fallback output | |
| successfulOutput | No | Legacy top-level output. Only for the older single-branch format; current rules keep outputs inside the branches. |