{ "openapi": "3.0.0", "info": { "title": "Policies System API", "description": "\r\n This API will create promotion alarms when selling products with undesired prices and promotions. It will create conditions that will check if the prices and the promotions are correct. If not, the system will alarm the store with information about the product sold at unexpected prices.\r\n\r\n ## Index\r\n\r\n- `GET` [Get Policy List](https://developers.vtex.com/docs/api-reference/policies-system-api#get-/api/policy-engine/policies)\r\n- `POST` [Evaluate Policies](https://developers.vtex.com/docs/api-reference/policies-system-api#post-/api/policy-engine/evaluate)\r\n- `GET` [Get Policy by ID](https://developers.vtex.com/docs/api-reference/policies-system-api#get-/api/policy-engine/policies/-id-)\r\n- `POST` [Create Policy](https://developers.vtex.com/docs/api-reference/policies-system-api#post-/api/policy-engine/policies/-id-)\r\n- `PUT` [Update Policy](https://developers.vtex.com/docs/api-reference/policies-system-api#put-/api/policy-engine/policies/-id-)\r\n- `DELETE` [Delete Policy by ID](https://developers.vtex.com/docs/api-reference/policies-system-api#delete-/api/policy-engine/policies/-id-)", "contact": {}, "version": "" }, "servers": [ { "url": "https://{accountName}.{environment}.com.br", "description": "VTEX server URL.", "variables": { "accountName": { "description": "Name of the VTEX account. Used as part of the URL.", "default": "apiexamples" }, "environment": { "description": "Environment to use. Used as part of the URL.", "enum": [ "vtexcommercestable" ], "default": "vtexcommercestable" } } } ], "paths": { "/api/policy-engine/policies": { "get": { "tags": [ "Policy" ], "summary": "Get policy list", "description": "Retrieves a list of all policies in the account and general information of each policy.\r\n\r\n## Permissions\r\n\r\nAny user or [application key](https://developers.vtex.com\/docs\/guides\/api-authentication-using-application-keys) must have at least one of the appropriate [License Manager resources](https:\/\/help.vtex.com\/en\/tutorial\/license-manager-resources--3q6ztrC8YynQf6rdc6euk3) to be able to successfully run this request. Otherwise they will receive a status code `403` error. These are the applicable resources for this endpoint:\r\n\r\n| **Product** | **Category** | **Resource** |\r\n| --------------- | ----------------- | ----------------- |\r\n| Promotions Policy Engine | Policies | **List Policies** |\r\n\r\nThere are no applicable [predefined roles](https://help.vtex.com/en/tutorial/predefined-roles--jGDurZKJHvHJS13LnO7Dy) for this resource list. You must [create a custom role](https://help.vtex.com/en/tutorial/roles--7HKK5Uau2H6wxE1rH5oRbc#creating-a-role) and add at least one of the resources above in order to use this endpoint.To learn more about machine authentication at VTEX, see [Authentication overview](https://developers.vtex.com/docs/guides/authentication).\r\n\r\n>\u2757 To prevent integrations from having excessive permissions, consider the [best practices for managing app keys](https://help.vtex.com/en/tutorial/best-practices-application-keys--7b6nD1VMHa49aI5brlOvJm) when assigning License Manager roles to integrations.", "operationId": "Policy_List", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PolicyGetResponse" }, "example": [ { "id": "pa_test_001", "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 70%." } } ], "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": [ "70.00" ] } ], "operation": "and" } } ] } ] } } } } } } }, "/api/policy-engine/evaluate": { "post": { "tags": [ "Policy" ], "summary": "Evaluate Policies", "description": "This endpoint consults all policies and checks the ones that satisfy the request body’s conditions.", "operationId": "Policy_Evaluate", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } } ], "requestBody": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EvaluatePolicyRequest" }, "example": { "resource": "vrn:vtex.promotions-alert:aws-us-east-1:kamila:master:/_v/promotions_alert", "context": { "brandId": "2000001", "discountPercentage": "91.00" } } } }, "required": true }, "responses": { "200": { "description": "", "headers": {}, "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PolicyActionGetResponse" }, "example": [ { "id": "SendSlackMessage", "metadata": { "channel": "C01NJFF35R6", "relatedUsers": [ "URUNDC2NB" ], "alertDescription": "Avoid selling products from Berenice with a discount greater than 70%." } } ] } } } } }, "deprecated": false } }, "/api/policy-engine/policies/{id}": { "get": { "tags": [ "Policy" ], "summary": "Get Policy by ID", "description": "Retrieves general information of a policy by its ID.", "operationId": "Policy_Get", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "id", "in": "path", "required": true, "description": "Policy ID", "schema": { "type": "string", "default": "pa_test_001" } } ], "responses": { "200": { "description": "", "headers": {}, "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PolicyGetResponse" }, "example": [ { "id": "pa_test_001", "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 70%." } } ], "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": [ "70.00" ] } ], "operation": "and" } } ] } ] } } } } } }, "post": { "tags": [ "Policy" ], "summary": "Create Policy", "description": "Creates a new policy from scratch.", "operationId": "Policy_CreateOrUpdate", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "id", "in": "path", "required": true, "description": "Policy ID", "schema": { "type": "string", "default": "pa_test_001" } } ], "requestBody": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PolicySaveRequest" }, "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" } } ] } } } }, "responses": { "200": { "description": "", "headers": {}, "content": { "application/octet-stream": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PolicyGetResponse" }, "example": [ { "id": "pa_test_001", "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 70%." } } ], "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": [ "70.00" ] } ], "operation": "and" } } ] } ] } } } } } }, "put": { "tags": [ "Policy" ], "summary": "Update Policy", "description": "Updates an existing policy at your account.", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "id", "in": "path", "required": true, "description": "Policy ID", "schema": { "type": "string", "default": "pa_test_001" } } ], "requestBody": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PolicySaveRequest" } } }, "required": true }, "responses": { "200": { "description": "", "headers": {}, "content": { "application/octet-stream": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PolicyGetResponse" }, "example": [ { "id": "pa_test_001", "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" } } ] } ] } } } } }, "deprecated": false }, "delete": { "tags": [ "Policy" ], "summary": "Delete Policy by ID", "description": "Deletes a specific policy of the account by its ID.", "operationId": "Policy_Delete", "parameters": [ { "name": "Content-Type", "in": "header", "description": "Describes the type of the content being sent", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "Accept", "in": "header", "description": "HTTP Client Negotiation _Accept_ Header. Indicates the types of responses the client can understand ", "required": true, "style": "simple", "schema": { "type": "string", "default": "application/json" } }, { "name": "id", "in": "path", "required": true, "description": "Policy ID", "schema": { "type": "string", "default": "pa_test_001" } } ], "responses": { "200": { "description": "200 OK" } }, "deprecated": false } } }, "components": { "schemas": { "PolicyActionGetResponse": { "title": "PolicyActionGetResponse", "type": "object", "properties": { "id": { "type": "string", "description": "Action ID", "title": "id" }, "metadata": { "type": "object", "description": "Metadata object from the current action", "title": "metadata", "additionalProperties": true } } }, "EvaluatePolicyRequest": { "required": [ "resource", "context" ], "type": "object", "properties": { "resource": { "description": "Scope on which this policy must be evaluated", "title": "resource", "type": "string", "default": "vrn:vtex.promotions-alert:aws-us-east-1:kamila:master:/_v/promotions_alert" }, "context": { "type": "object", "description": "Conditions that the Policy needs to satisfy", "title": "context", "default": { "brandId": "2000001", "discountPercentage": "91.00" }, "additionalProperties": true } } }, "Account": { "title": "Account", "type": "object", "properties": { "mainAccountName": { "type": "string" }, "name": { "type": "string" }, "id": { "type": "string" }, "operationDate": { "type": "string", "format": "date-time" }, "accountType": { "$ref": "#/components/schemas/AccountType" }, "isActive": { "type": "boolean" }, "isOperating": { "type": "boolean" } } }, "AccountType": { "title": "AccountType", "enum": [ 0, 1 ], "type": "integer", "example": 0 }, "PolicySaveRequest": { "required": [ "name", "description", "statements" ], "type": "object", "properties": { "name": { "type": "string", "description": "Policy Name", "title": "name" }, "description": { "type": "string", "description": "Policy description. This description is only for internal use of identification", "title": "description" }, "statements": { "type": "array", "title": "statements", "items": { "$ref": "#/components/schemas/StatementGetResponse" }, "description": "Requirements to the Policy be applied" } } }, "PolicyGetResponse": { "title": "PolicyGetResponse", "type": "object", "properties": { "id": { "type": "string", "title": "id", "description": "Policy ID." }, "name": { "type": "string", "description": "Policy name.", "title": "name" }, "description": { "type": "string", "description": "Policy description. This description is only for internal use of identification.", "title": "description" }, "statements": { "type": "array", "title": "statements", "items": { "$ref": "#/components/schemas/StatementGetResponse" }, "description": "Requirements to the policy be applied." } } }, "StatementGetResponse": { "type": "object", "required": [ "effect" ], "properties": { "effect": { "type": "string", "title": "effect", "description": "This field is not functional at the moment. To create a correct request, fill the field with `Allow`.", "default": "Allow" }, "actions": { "type": "array", "title": "actions", "properties": { "id": { "type": "string", "title": "id", "description": "Action ID. The possible values can be `SendSlackMessage`, `SendEmail`, and `DeactivatePromotions`." }, "metadata": { "type": "object", "title": "metadata", "description": "Data inside of the actions.", "additionalProperties": true } }, "description": "Actions that the policy will execute." }, "resource": { "type": "string", "description": "Scope on which this policy must be evaluated.", "title": "resource" }, "condition": { "type": "object", "properties": { "conditions": { "type": "array", "description": "List of conditions that will activate the policy.", "items": { "properties": { "conditions": { "title": "conditions", "type": "array", "description": "These are the conditions the actions can have. The possible values are `[]`, `stringEquals`, and `numericGreaterThan`.", "items": { "type": "string" } }, "operation": { "type": "string", "title": "operation", "description": "The 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`." }, "key": { "type": "string", "title": "key", "description": "The element that will define what the policy will influence. This field has the possible values `skuId`, `brandId`, `discountPercentage`." }, "values": { "type": "array", "title": "values", "items": { "type": "string", "description": "Key value." }, "description": "Array with values of the key." } } } } }, "description": "Condition to activate this policy. This object can have a maximum of ten recursive conditions.", "title": "condition" }, "operation": { "type": "string", "title": "operation", "description": "This 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`." } } } } }, "tags": [ { "name": "Policy" } ] }