Create Policy

Creates a new policy from scratch.

Request body object has the following properties:

AttributeTypeDescription
namestringPolicy Name
descriptionstringPolicy description. This description is only for internal use of identification
statementsarray of objectsRequirements to the Policy be applied
↳ effectstringThis field is not functional at the moment. To create a correct request, fill the field with Allow
↳ actionsarray of objectsActions that the Policy will execute
↳↳ idstringAction ID. The possible values can be SendSlackMessage, SendEmail, and DeactivatePromotions
↳↳ metadataobjectData inside of the actions
↳ resourcestringScope on which this policy must be evaluated
↳ conditionobjectCondition to activate this policy. This object can have a maximum of ten recursive conditions
↳↳ conditionsarray of objectsList of conditions that will activate the policy
↳↳↳ conditionsarrayThese are the conditions the actions can have. The possible values are [], stringEquals, and numericGreaterThan
↳↳↳ operationstringThe action of the condition. This operation possible values are None, stringEquals, stringEqualsIgnoreCase, numericEquals, numericLessThan, numericLessThanEquals, numericGreaterThan, numericGreaterThanEquals, bool, not, or, and, dateTimeUtcGreaterThan, dateTimeUtcLessThan, and between
↳↳↳ keystringThe element that will define what the policy will influence. This field has the possible values skuId, brandId, discountPercentage
↳↳↳ valuesarrayValue of the key
↳↳ operationstringThis operation will determine if all the conditions need to be valid or at least one of them if the conditions array is not empty. The possible values to these fields are None, stringEquals, stringEqualsIgnoreCase, numericEquals, numericLessThan, numericLessThanEquals, numericGreaterThan, numericGreaterThanEquals, bool, not, or, and, dateTimeUtcGreaterThan, dateTimeUtcLessThan, and between

Request body example:

{
        "name": "TestAlarmBerenice",
        "description": "TesteMarcosPromotionsAlert",
        "statements": [
            {
              "effect": "Allow", 
              "actions": [
                    {
                        "id": "SendSlackMessage",
                        "metadata": {
                            "channel": "C01NJFF35R6",
                            "relatedUsers": [
                                "URUNDC2NB"
                            ],
                            "alertDescription": "Avoid selling products from Berenice with a discount greater than 40%."
                        }
                    }
                ],
                "resource": "vrn:vtex.promotions-alert:aws-us-east-1:kamila:master:/_v/promotions_alert",
                "condition": {
                    "conditions": [
                        {
                            "conditions": [],
                            "operation": "stringEquals",
                            "key": "brandId",
                            "values": [
                                "2000001"
                            ]
                        },
                        {
                            "conditions": [],
                            "operation": "numericGreaterThan",
                            "key": "discountPercentage",
                            "values": [
                                "40.00"
                            ]
                        }
                    ],
                    "operation": "and"
                }
            }
        ]
    }
 }

Response body example:

200 OK
Language
URL
Click Try It! to start a request and see the response here!