Calls
Triggers
create
5min
this call creates a trigger the arguments that must be included in the doc are described below basic parameters name type required description action string true create group id integer true the project the product is in doc array false see doc parameters below doc parameters name type required description reverse trigger boolean false if the user first meets a trigger condition and then later changes a value so the condition is not met, true will ensure the product is removed from the cart this is generally the behavior you'd expect, and the default is true action associative array true contains two variables product id and action type ; see below for more ex { "action" { product id \[1, 2, etc ], action type "show prod in list" } } product id array true a list of product id's you'd like the trigger to be set for action type string true one of four actions the product can take when the trigger condition is met add product no show this adds the product to the user's cart automatically when the conditions are met additionally it ensures that users who do not meet the condition can not select the product on the product selection widget when adding automatically to a user, this is the most common option show prod in list the product shows in the product selection widget where the user has the option can select it remove prod from list ensures that the product does not appear for users to select on the product selection widget add product this adds the product automatically if they meet the conditions, but also shows the product to users who do not meet the condition on the product selection widget conditions associative array true contains two variables andor and condition list ; see below for more ex "conditions" { "andor" "and", "condition list" \[ { "field id" "instrument", "field value" "guitar" }, { etc } ] } andor string true when setting a trigger you can include one or more conditions if adding multiple, "and" means all of the conditions must me true while "or" means that only one of the conditions must be true default is "and" condition list array true this is an array of associative arrays, each of which describes the trigger condition which must be met to trigger on a field, you include field id and field value to trigger on a status being applied to a user, you include status id and action action only has one argument, "set status" this is met when a status is applied to a user to trigger on the addition of some other product, include product id and action action only has one argument, "product added" this is met when a product is added to a users cart, either through the api, manually by an admin, or by the user values are case sensitive example call curl x post "https //www regpack com/reg/api2/triggers/" \\ h "content type application/json" \\ h "accept application/json" \\ h "api id 15263" \\ h "api user api admin\@regpacks com" \\ h "api token cd2e514f 7gab 3cde 62fg 51abcd4e7362" \\ d '{ "action" "create", "group id" 1625251, "doc" { "reverse trigger" true, "action" { "product id" "2767021", "action type" "add product no show" }, "conditions" { "andor" "and", "condition list" \[ { "field id" "f 349514 4451053", "field value" "guitar" }, { "product id" "2594110", "action" "product added" }, { "status id" "90809", "action" "set status" } ] } } }' import requests import json triggers endpoint = https //www regpack com/reg/api2/triggers/ headers = { "content type" "application/json", "accept" "application/json", "api id" "15263", "api user" "api admin\@regpacks com", "api token" "cd2e514f 7gab 3cde 62fg 51abcd4e7362", } payload = { "action" "create", "group id" 1625251, "doc" { "reverse trigger" true, "action" { "product id" "2767021", "action type" "add product no show" }, "conditions" { "andor" "and", "condition list" \[ { "field id" "f 349514 4451053", "field value" "guitar" }, { "product id" "2594110", "action" "product added" }, { "status id" "90809", "action" "set status" }, ], }, }, } add trigger json = json dumps(payload) add trigger response = requests post(url=triggers endpoint, data=add trigger json, headers=headers, timeout=10) response { "undo trigger" true, "action" { "action vars" { "product id" "1654403" }, "action type" "add product no show" }, "log conds" { "andor" "and", "conditions" \[ { "log ex id" "field set to", "vars" { "field id" "f 349514 4451053", "field value" "guitar" } }, { "log ex id" "product added", "vars" { "product id" "745947" }, "multi id" "multi product added 745947" }, { "log ex id" "set status", "vars" { "status id" "70418" }, "multi id" "multi set status 70418" } ] }, "text qv" " \<span class=\\"fs wrap\\"> \<span class=\\"filter name\\">rate type\</span> \<em>is\</em> \<span class=\\"answer\\">\<span class=\\"val\\">bucket rate \</span>\</span> \<a href=\\"javascript;\\" class=\\"fs delete\\" rel=\\"f231\\">\</a> \</span> \<span class=\\"fs wrap\\"> \<span class=\\"filter name\\">administrator license 12 month legacy price business package\</span> \<em>is\</em> \<span class=\\"answer\\">\<span class=\\"val\\">added to user cart\</span>\</span> \<a href=\\"javascript;\\" class=\\"fs delete\\" rel=\\"multi product added 745947\\">\</a> \</span> \<span class=\\"fs wrap\\"> \<span class=\\"filter name\\">status is active\</span> \<a href=\\"javascript;\\" class=\\"fs delete\\" rel=\\"multi set status 70418\\">\</a> \</span>", "ui obj" \[ { "trigger id" "mongo text search", "vars" \[ { "rate type" "guitar" } ] }, { "trigger id" "product logs", "multi id" "multi product added 745947", "vars" \[ { "log ex id" "product added" }, { "trigger vars" "{\\"product id\\" \\"745947\\"}" } ] }, { "trigger id" "set status log", "vars" \[ { "log ex id" "set status" }, { "trigger vars" "{\\"status id\\" \\"70418\\"}" } ] } ], "group id" "1625251", " id" "100906231 1656649", "creation date" { "sec" 1729011822, "usec" 42000 }, "trig action cond level" "parent condition child condition child action", "success" true }