{"section":"tracks","requestedLocale":"en","requestedSlug":"adding-a-price-rule","locale":"en","slug":"adding-a-price-rule","path":"docs/en/tracks/vtex-modules-getting-started/prices-101/adding-a-price-rule.md","branch":"main","content":"There are two of adding a price rule:\n\n- through the Admin\n- by API REST\n\nFollow the steps below to add a price rule to your store:\n\n## Admin\n\n1. In the VTEX Admin, go to **Prices > Price rules**, or type **Price rules** in the search bar at the top of the page.\n2. Click on the green **New Rule** button.\n3. In the first step, **What is the general data of this rule?**, select a trade policy from the *dropdown menu*.\n4. In the second step, **What items will this rule apply to?**, choose whether the rule will apply to *all products* or *only to chosen categories and brands*. If you select the second option, you should also choose the **Categories** and/or desired **Brands**.\n5. In the third step, **Apply rule to items within a markup range?**, switch the *toggle* to yes to make use of the markup range. Type in the markup's minimum percentage in the **From** field and its max percentage in the **up to** field to select items within this range.\n6. In the next step, **Select timeframe to apply this rule in?**, switching the *toggle* to yes will allow you to use this criteria. Choose the **Start Date**, **Start Hour**, **End Date** and the **End Hour** to define the period in which this rule will be applied.\n7. In the final step, **What will the price change for this rule be?**, set the price percentage *modifier*. The price rule will apply this modifier to the selected SKUs.\n8. Click on **Save**\n9. A *sidebar* to confirm the new rule will appear. Click on **Confirm**.\n\n## API REST\n\n> ⚠️ Authentications for Prices module's API REST calls should be done using AppKey and AppToken. For more info, read our article on [how to generate an AppKey and AppToken to authenticate integrations](https://developers.vtex.com/vtex-developer-docs/docs/getting-started-authentication)\n\nTo add a **price rule**, you need to send a __POST__ to the following endpoint:\n\n`https://api.vtex.com/{{accountName}}/pricing/pipeline/catalog`\n\n- The request object has the following properties:\n\n| __Properties__ | __Types__ | __Description__ |\n|------------------|-----------|-------------|\n| tradePolicyId | string | ID of the price table in which the rule will be applied |\n| rules | array | Price rule criteria |\n| id | integer | Price rule ID. You can add more than one rule to the same price table.|\n| context | object | Object containing the price rule properties |\n| categories | object | Category to which to rule applies |\n| brands | object | Brand to which the rule applies  |\n| markupRange | object | Rules applied to items in a markup range |\n| from | integer | Minimum markup range value |\n| to | integer | Maximum markup range value |\n| dateRange | object | Rule's date and time range |\n| from | string | Start date and time |\n| to | string | End date and time |\n| percentualModifier | integer | Price variation for this rule |\n\n- The response object has the following properties:\n\n| __Properties__ | __Types__ | __Description__ |\n|------------------|-----------|-------------|\n| tradePolicyId | string | ID of the price table in which the rule will be applied |\n| rules | array | Price rule's object array to be applied to the price table |\n| id | integer | Price rule ID. You can add more than one rule to the same price table.|\n| context | object | Object containing the price rule properties |\n| categories | object | Category to which to rule applies |\n| brands | object | Brand to which the rule applies  |\n| markupRange | object | Rules applied to items in a markup range |\n| from | integer | Minimum markup range value |\n| to | integer | Maximum markup range value |\n| dateRange | object | Rule's date and time range |\n| from | string | Start date and time |\n| to | string | End date and time |\n| percentualModifier | integer | Price variation for this rule |\n\n- Below, we have an example of a Header and Body to be used in the request\n\n### Headers\n\n| Header| Value |\n|------------------|-----------|\n| Accept | application/vnd.vtex.pricing.v3+json |\n| Content-Type | application/json |\n| X-VTEX-API-AppKey | \\{\\{X-VTEX-API-AppKey\\}\\} |\n| X-VTEX-API-AppToken | \\{\\{X-VTEX-API-AppToken\\}\\} |\n\n### Body \n```json\n {\n        \"tradePolicyId\": \"1\",\n        \"rules\": [\n            {\n                \"id\": 0,\n                \"context\": {\n                    \"categories\": {\n                        \"8\": \"categoryName\"\n                    },\n                    \"brands\": {\n                        \"2000003\": \"brandName\"\n                    },\n                    \"markupRange\": {\n                        \"from\": 20,\n                        \"to\": 50\n                    },\n                    \"dateRange\": {\n                        \"from\": \"2019-07-09T15:00:00.000Z\",\n                        \"to\": \"2019-07-12T15:00:00.000Z\"\n                    }\n                },\n                \"percentualModifier\": 10\n            }\n        ]\n }\n```\n*If the array is sent blank, previously added rules will be deleted*"}