Here you can find all the Rule sets combinations for a Contest creation POST via API. The Contest has to have at least 4 rule sets with actions that are contest start, finish, finalise and points calculation.

This page is for reference only to display all the possible rules combinations.

You can not create a contest only with rules parameters. All other POST body parameters that are required for a contest creation must exist.

You can find the rest of the POST body parameters needed to create a contest here

Resource URL:

https://<apphost>.competitionlabs.com/api/<your-space-name>/competitions/<competitionId>/contests

Request headers

Key
Value
Required
X-API-KEY
Your unique API keyYes
Content-Type
application/jsonYes

Request URL parameters

Parameter
Type
Required
Description
space
StringYesThis is the space name which is linked to the account
id
StringYesCompetition identifier retrieved from GET Competitions resource

Post body ruleSets parameter

ParameterTypeRequiredDescription
ruleSets













Array [Object]












Yes












A list of RuleSetsTypeRequiredDescription
priority
IntegerYesA value to display the rules in order
scope
StringYesWhat model it belongs to for example contest or achievement
onMatchThen
StringOptional

Only Required when "Custom points" action is selected

Available onMatchThen
Add points
	"onMatchThen": "add"

Subtract points
	"onMatchThen": "subtract"

Multiply event points by
	"onMatchThen": "multiply.points"

Use my adjustment factor
	"onMatchThen": "multiply.source"
onMatchConstant
StringOptional

Only Required when "Custom points" action is selected. It’s a value that represent how many points will be added, subtracted or multiplied.

action
StringYes

Displays the rule set. 

Available actions
"Event points" - Add the event points to the leaderboard
	"action": "contest.points.calculated.by"

"Custom points" - Add or subtract points from the leaderboard
	"action": "contests.points.calculated.custom"

"Entrant progression" - Entrants to this contests are those members that match these conditions
	"action": "entrant.determined.by"

"Start the contests" - Start the contests
	"action": "open.contest"

"Finish the contests" - Finish the contests
	"action": "finish.contest"

"Finalise the contests" - Finalise the contests
	"action": "finalise.contest"

"Cancel the contests" - Cancel the contests
	"action": "cancel.contests"
conditions







Array [Object]






Yes






MainConditionSet model.

TypeRequiredDescription

matchCondition

Enum

  • All
  • Any
YesWhether the rules must all evaluate as True or False or at least one of the rules must be True or False to satisfy the rule
mustEvaluateTo
BooleanYesThe value the rule(s) must evaluate to for the rule to be satisfied
rules




Array [Object]



Yes



MainRule model.

TypeRequiredDescription
fact
StringYes

Displays the facts of the rule. 

Available "Event points" fact
The external event reference id
	"fact": "event.external.id"

The action is example is BET, WIN and so on
	"fact": "event.action.type"

The product or the games
	"fact": "event.product.id"

The CompetitionLabs reward id
	"fact": "event.reward.id"

The event source value
	"fact": "event.source.value"

The event points value
	"fact": "event.points.value"

The event transaction timeStamp in minutes
	"fact": "event.transaction.timeStamp"
Available "Start the contests" fact
The competitions
	"fact": "competition.status"

The contests parents
	"fact": "contest.parents.status"

When the current date
	"fact": "current.date"

When the current time
	"fact": "current.time"
Available "Finish the contests" fact
The contests has been active for
	"fact": "contest.active.elapsed"

When the current date
	"fact": "current.date"

When the current time
	"fact": "current.time"
Available "Finalise the contests" fact
The contests finished
	"fact": "contest.finish.elapsed"
Available "Custom points" fact
The count of events where the nested condition(s) evaluate to TRUE for the event
	"fact": "event.count"

The average source value for events where the nested condition(s) evaluate to TRUE for the event
	"fact": "avg.event.source.value"

The sum of all the source values for events where the nested condition(s) evaluate to TRUE for the event
	"fact": "sum.event.source.value"

The average points for all matching events
	"fact": "avg.event.points.value"

The sum of all the points for events where the nested condition(s) evaluate to TRUE for the event
	"fact": "sum.event.points.value"
Available "Entrant progression" fact
The entrants lowest finish position (rank) during the previous round
	"fact": "entrants.previous.round.leaderboard.positions"

The entrants score during the previous round
	"fact": "entrants.previous.round.contests.scores"
Available "Cancel the contests" fact
The contests finished
	"fact": "contest.finish.elapsed"
operator
StringYes

Part of the rule which operates the fact ex. is, more than, less than etc.

Available "Event points" operator
For "The external event reference id"
	is
	"operator": "=="

For "The action"
	is
	"operator": "=="

For "The product"
	is
	"operator": "=="

For "The CompetitionLabs reward id"
	is
	"operator": "=="

For "The event source value"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is equal to
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The event points value"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is equal to
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The event transaction timeStamp in minutes"
	is less than
	operator": "<"

	is less than or equal to
	operator": "<="
Available "Start the contests" operator
For "The competitions"
	is
	"operator": "=="

For "The contests parents"
	are all
	"operator": "=="

	are not all
	"operator": ""

For "When the current date"
	is
	"operator": "=="

	is before
	"operator": "before"

	is after
	"operator": "after"

	is or or after
	"operator": "on.or.after"

	is on or before
	"operator": "on.or.before"

For "When the current time"
	is
	"operator": "=="

	is before
	"operator": "before"

	is after
	"operator": "after"

	is or or after
	"operator": "on.or.after"

	is on or before
	"operator": "on.or.before"
Available "Finish the contests" operator
For "The contests has been active for"
	more than
	"operator": ">"

	more than or exactly
	"operator": ">="

	less than or exactly
	"operator": "<="

	less than
	"operator": "<"

For "When the current date"
	is
	"operator": "=="

	is before
	"operator": "before"

	is after
	"operator": "after"

	is or or after
	"operator": "on.or.after"

	is on or before
	"operator": "on.or.before"

For "When the current time"
	is
	"operator": "=="

	is before
	"operator": "before"

	is after
	"operator": "after"

	is or or after
	"operator": "on.or.after"

	is on or before
	"operator": "on.or.before"
Available "Finalise the contests" operator
For "The contests finished"
	is equal or more than
	"operator": ">="

	is more than
	"operator": ">"

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"
Available "Custom points" operator
For "The count of events where the nested condition(s) evaluate to TRUE for the event"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The average source value for events where the nested condition(s) evaluate to TRUE for the event"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The sum of all the source values for events where the nested condition(s) evaluate to TRUE for the event"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The average points for all matching events"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"

For "The sum of all the points for events where the nested condition(s) evaluate to TRUE for the event"
	is equal to or more than
	"operator": ">="

	is more than
	"operator": ">"

	is
	operator": "=="

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"
Available "Entrant progression" operator
For "The entrants lowest finish position (rank) during the previous round"
	was more than
	"operator": ">"

	was equal to or more than
	"operator": ">="

	was equal to
	"operator": "=="

	was equal to or less than
	operator": "<="

	was less than
	operator": "<"

For "The entrants score during the previous round"
	was more than
	"operator": ">"

	was equal to or more than
	"operator": ">="

	was equal to
	"operator": "=="

	was equal to or less than
	operator": "<="

	was less than
	operator": "<"
Available "Cancel the contests" fact
For "The contests finished"
	is equal or more than
	"operator": ">="

	is more than
	"operator": ">"

	is less than or equal to
	operator": "<="

	is less than
	operator": "<"
constant
StringYes

A rules value that defines the fact ex. if the fact is "the action" then the constant is "win". Some constants are pre defined (they are called macros)

Available "Start the contests" constant
The competitions - active
	"constant": "$competition.active.status"

The contests parents - finalised
	"constant": "$finalised.status"
Available "Finish the contests" constant
The contests has been active for - the time between contest…and competitions end in
	"constant": "$competitions.scheduled.end"

All the other constants are variables.

subConditions
Array [Object]Optional

subConditionSet model. Works the same as Main condition set model. Within the subConditionSet model you will find all the relevant and needed sub conditions for posting

Example
"jsonClass": "SubConditionSet",
"matchCondition": "All",
"mustEvaluateTo": true,
"subRules": [
	{
	"jsonClass": "SubRule",
    "fact": "event.action.type",
	"operator": "==",
    "constant": "bet"

All the valid "SubRule" facts are the same as above in conditions → rules → fact

and

All the valid "SubRule" operators are the same as above in conditions → rules → operator

EXAMPLE

Json ruleSets example
			"ruleSets": [{
 				"jsonClass": "RuleSet",
 				"priority": 1,
 				"scope": "contest",
 				"action": "contests.points.calculated.custom",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "event.count",
 						"operator": ">=",
 						"constant": "1",
 						"subConditions": [{
 							"jsonClass": "SubConditionSet",
 							"matchCondition": "All",
 							"mustEvaluateTo": true,
 							"subRules": [{
 								"jsonClass": "SubRule",
 								"fact": "event.action.type",
 								"operator": "==",
 								"constant": "bet"
 							}]
 						}]
 					}]
 				}],
 				"onMatchThen": "add",
 				"onMatchConstant": "5"
 			}, {
 				"jsonClass": "RuleSet",
 				"priority": 2,
 				"scope": "contest",
 				"action": "open.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.parents.status",
 						"operator": "==",
 						"constant": "$finalised.status"
 					}]
 				}]
 			},
 			{
 				"jsonClass": "RuleSet",
 				"priority": 3,
 				"scope": "contest",
 				"action": "finish.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.active.elapsed",
 						"operator": ">=",
 						"constant": "$competition.scheduled.end"
 					}]
 				}]
 			},
 			{
 				"jsonClass": "RuleSet",
 				"priority": 4,
 				"scope": "contest",
 				"action": "finalise.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.finish.elapsed",
 						"operator": ">=",
 						"constant": "1"
 					}]
 				}]
 			}
 		]
Request for a complete contest creation
curl
--header "X-API-KEY: <your-api-key>"
--header "Content-Type: application/json"
--request POST https://app.competitionlabs.com/api/<your-space-name>/competitions/AVaIeGLa4Zm8V4vzCObS/contests/
-d '{ "contest": { "jsonClass": "Contest", "competitionId": "9PCOY20BmZKDVA-UR6WX", "number": 0, "label": "Test", "description": "", "termsConditions": "", "round": 1, "roundType": "TimeBound", "entrantsFromContest": [], "options": { "numberOfEntrants": { "jsonClass": "MaxMin", "minimum": 1 }, "products": [], "ruleSets": [{"jsonClass": "RuleSet", "priority": 4, "scope": "contest", "action": "contests.points.calculated.custom", "conditions": [ { "jsonClass": "MainConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "rules": [ { "jsonClass": "MainRule", "fact": "event.count", "operator": ">=", "constant": "1", "subConditions": [{ "jsonClass": "SubConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "subRules": [{"jsonClass": "SubRule", "fact": "event.action.type", "operator": "==", "constant": "bet"}]}]}]}], "onMatchThen": "add", "onMatchConstant": "5"}
],{ "jsonClass": "RuleSet", "priority": 2 "scope": "contest", "action": "open.contest", "conditions": [{ "jsonClass": "MainConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "rules": [{ "jsonClass": "MainRule", "fact": "contest.parents.status", "operator": "==", "constant": "$finalised.status" }]}]},{ "jsonClass": "RuleSet", "priority": 3, "scope": "contest", "action": "finish.contest", "conditions": [{ "jsonClass": "MainConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "rules": [{ "jsonClass": "MainRule", "fact": "contest.active.elapsed", "operator": ">=", "constant": "$competition.scheduled.end" }]}]},{ "jsonClass": "RuleSet", "priority": 4, "scope": "contest", "action": "finalise.contest", "conditions": [{ "jsonClass": "MainConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "rules": [{ "jsonClass": "MainRule", "fact": "contest.finish.elapsed", "operator": ">=", "constant": "1" }]}]}], "isPublic": true, "autoStart": true, "autoStartRetryInterval": 1000, "autoStop": true, "autoStopRetryInterval": 1000, "scheduledDates": { "jsonClass": "StartEndDate", "start": "2019-09-24T14:25:00.000+00:00", "end": "2019-09-24T15:25:00.000+00:00" }, "actualDates": { "jsonClass": "StartEndDate" }, "optinRequiredForEntrants": false, "useGlobalEvents": false }, "metadata": [], "translations": {}, "status": "NotStarted", "statusCode": 0, "translatableFields": [ "label", "description", "termsConditions" ]}, "rewards": [{ "jsonClass": "Reward", "entityId": "_PCVY20BmZKDVA-UUaWY", "rewardRank": "1", "rewardName": "Test", "value": 1.0, "rewardType": "GuyNjGYBZ-qHKtWie_x4", "description": "", "delay": 0, "memberAcknowledgmentRequired": false, "metadata": [], "pointInTime": "2019-09-24T14:03:14.204+00:00", "translations": {}, "translatableFields": [ "rewardName", "description" ]}]}'
Response of a complete contest creation
"data":  {
 	"jsonClass": "Contest",
 	"accountId": "FuyNjGYBZ-qHKtWicfwh",
 	"competitionId": "9PCOY20BmZKDVA-UR6WX",
 	"number": 0,
 	"label": "test",
 	"description": "",
 	"termsConditions": "",
 	"round": 1,
 	"roundType": "TimeBound",
 	"entrantsFromContest": [],
 	"options": {
 		"numberOfEntrants": {
 			"jsonClass": "MaxMin",
 			"minimum": 1
 		},
 		"products": [],
 		"ruleSets": [{
 				"jsonClass": "RuleSet",
 				"priority": 1,
 				"scope": "contest",
 				"action": "contests.points.calculated.custom",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "event.count",
 						"operator": ">=",
 						"constant": "1",
 						"subConditions": [{
 							"jsonClass": "SubConditionSet",
 							"matchCondition": "All",
 							"mustEvaluateTo": true,
 							"subRules": [{
 								"jsonClass": "SubRule",
 								"fact": "event.action.type",
 								"operator": "==",
 								"constant": "bet"
 							}]
 						}]
 					}]
 				}],
 				"onMatchThen": "add",
 				"onMatchConstant": "5"
 			}, {
 				"jsonClass": "RuleSet",
 				"priority": 2,
 				"scope": "contest",
 				"action": "open.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.parents.status",
 						"operator": "==",
 						"constant": "$finalised.status"
 					}]
 				}]
 			},
 			{
 				"jsonClass": "RuleSet",
 				"priority": 3,
 				"scope": "contest",
 				"action": "finish.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.active.elapsed",
 						"operator": ">=",
 						"constant": "$competition.scheduled.end"
 					}]
 				}]
 			},
 			{
 				"jsonClass": "RuleSet",
 				"priority": 4,
 				"scope": "contest",
 				"action": "finalise.contest",
 				"conditions": [{
 					"jsonClass": "MainConditionSet",
 					"matchCondition": "All",
 					"mustEvaluateTo": true,
 					"rules": [{
 						"jsonClass": "MainRule",
 						"fact": "contest.finish.elapsed",
 						"operator": ">=",
 						"constant": "1"
 					}]
 				}]
 			}
 		],
 		"isPublic": true,
 		"autoStart": true,
 		"autoStartRetryInterval": 1000,
 		"autoStop": true,
 		"autoStopRetryInterval": 1000,
 		"scheduledDates": {
 			"jsonClass": "StartEndDate",
 			"start": "2019-09-24T14:25:00.000+00:00",
 			"end": "2019-09-24T15:25:00.000+00:00"
 		},
 		"actualDates": {
 			"jsonClass": "StartEndDate"
 		},
 		"optinRequiredForEntrants": false,
 		"useGlobalEvents": false
 	},
 	"metadata": [],
 	"created": "2019-09-24T14:10:01.475+00:00",
 	"id": "C_CbY20BmZKDVA-UjKaD",
 	"translations": {},
 	"status": "NotStarted",
 	"statusCode": 0,
 	"translatableFields": [
 		"label",
 		"description",
 		"termsConditions"
 	]
 }