POST /api/:space/competitions/:competitionId/contests

Description:

Create a contest for a specific Competition Identifier.

A Contest can not be created in a Finished or Canceled Competition

Resource URL:

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

Request headers

KeyValueRequired
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 parameter

Parameter
Type
Required
Description
competitionId
StringYesCompetition identifier retrieved from GET Competitions resource
number
IntegerYesContests position e.g. if there are 2 Contests which one is first and which one is second. The default is 0
label
StringYesA name of the Contest
description
StringOptionalDescription of the Contest
termsConditions
StringOptionalTerms and conditions of a Contest
round
IntegerYesTo what round does the contest belong. The default is 1
roundType

String

YesType of rounds in a contest, eg. TimeBound
entrantsFromContest
Array [String]OptionalArray of Strings to identify which entrants will progress to next contest, for the first round the value should be 0 or can be left empty
options
ObjectYes



From Options domain model the only entries that are required:

TypeRequiredDescription
numberOfEntrants
From numberOfEntrants modelIntegerYesMaximum and Minimum number of entrants
minimumIntegerYesThe minimum number of entrants. The default is 1
maximumIntegerOptionalThe maximum number of entrants. Left empty means that no limitations are added
scheduledDates
From scheduleDates modelDateTimeYesStartEndDate model
startDateTimeYesTime and date of when the contest has to start. Example: 2019-09-24T14:25:00.000+00:00
endDateTimeYesTime and date of when the contest has to end. ISO8601 timestamp. Example: 2019-09-24T14:25:00.000+00:00
productsArray [Object]OptionalA list of Products
ruleSetsArray [Object]YesA list of RuleSets
autoStartBooleanOptionalTrue means that the contest will auto start depending on the scheduledDates
autoStopBooleanOptionalTrue means that the contest will auto stop depending on the scheduledDates
optinRequiredForEntrantsBooleanYesIf True, members must Opt in before they can acquire points in the contest
strategies
ObjectYesA Strategies model where you can change the Ranking and Scoring strategies
All the other entries
ObjectOptionalAll the other entries are optional to use
metadataArray [Object]OptionalA list of MetaData
statusStringNoA status of a contestCreating a contest in a competition that hasn't been started yet the contest is automatically set to NotStarted or creating a contest in a competition that has already been started then the contest is set to Active.
statusCodeIntegerNoA status of a contest defined as a number. Creating a contest in a competition that hasn't been started yet the contest is automatically set to 0 (NotStarted) or creating a contest in a competition that has already been started then the contest is set to 3 (Active).
rewardsArray [Object]OptionalA model of a RewardTypeRequiredDescription
entityIdStringYesA contest Id. The string has to be left empty as it will populate automatically when the contest will be created
rewardRankStringYesIt associates with the rank of the leaderboard
rewardNameStringYesThe name of a reward
valueIntegerYesNumerical value of the reward that will be issued based on the reward type
rewardTypeStringYesReward type identifier retrieved from GET RewardTypes resource
descriptionStringOptionalThe description of a Reward 
delayIntegerOptionalDelay of issuing a reward in minutes
memberAcknowledgmentRequiredBooleanOptionalRequires member acknowledgment to claim a reward. If set to True reward will not be automatically issued
metadataArray [Object]OptionalA list of Metadata
pointInTimeDateTimeOptionalReward is available until a specific point in time

EXAMPLE

Request
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": 1, "scope": "contest", "action": "contest.points.calculated.by", "conditions": [{ "jsonClass": "MainConditionSet", "matchCondition": "All", "mustEvaluateTo": true, "rules": [{ "jsonClass": "MainRule", "fact": "event.action.type", "operator": "==", "constant": "bet" }]}]},{ "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, "strategies": {"jsonClass": "Strategies","strategyType": "TotalCumulative","rankingStrategy": {"jsonClass": "RankingStrategy","scoreDesc": true,"timeDesc": false,"scoreFirst": true,"ignoreTime": false,"ignoreScore": false},"scoringStrategy": {"jsonClass": "ScoringStrategy","limitUpdatesTo": 0,"sumBestXOf": 0,"lastUpdateTimeStamp": 0,"recordTimeWhenSumReaches": 0.0}} }, "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
    "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": "contest.points.calculated.by",
                    "conditions": [
                        {
                            "jsonClass": "MainConditionSet",
                            "matchCondition": "All",
                            "mustEvaluateTo": true,
                            "rules": [
                                {
                                    "jsonClass": "MainRule",
                                    "fact": "event.action.type",
                                    "operator": "==",
                                    "constant": "bet"
                                }
                            ]
                        }
                    ]
                },
                {
                    "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,
			"strategies": {
				"jsonClass": "Strategies",
				"strategyType": "TotalCumulative",
				"rankingStrategy": {
					"jsonClass": "RankingStrategy",
					"scoreDesc": true,
					"timeDesc": false,
					"scoreFirst": true,
					"ignoreTime": false,
					"ignoreScore": false
				},
				"scoringStrategy": {
					"jsonClass": "ScoringStrategy",
					"limitUpdatesTo": 0,
					"sumBestXOf": 0,
					"lastUpdateTimeStamp": 0,
					"recordTimeWhenSumReaches": 0.0
				}
			}
        },
        "metadata": [],
        "created": "2019-09-24T14:10:01.475+00:00",
        "id": "C_CbY20BmZKDVA-UjKaD",
        "translations": {},
        "translatableFields": [
            "label",
            "description",
            "termsConditions"
        ]
    }
}

ERROR CODES

CodeHTTP StatusDescriptionExample

503competitionId parameter was empty;
Error Response 503
{
    "status": 503
}
1001400
  • competitionId parameter was excluded;
  • round parameter was excluded;
  • number parameter was excluded;
  • roundType parameter was excluded, empty or incorrect;
  • reward parameter was excluded;
  • optinRequiredForEntrants parameter was excluded
Error Response 400
{
    "errors": [
        {
            "message": "Malformed JSON body.",
            "code": 1001,
            "status": 400
        }
    ]
}
1017405
  • Contest operations not allowed for Competition currentStatus: Finished
  • Contest operations not allowed for Competition currentStatus: Cancelled
Error Response 405
{
    "errors": [
        {
            "message": "Contest operations not allowed for Competition currentStatus: Finished.",
            "code": 1017,
            "status": 405
        }
    ]
}
Error Response 405
{
    "errors": [
        {
            "message": "Contest operations not allowed for Competition currentStatus: Cancelled.",
            "code": 1017,
            "status": 405
        }
    ]
}