PUT /api/:space/competitions/:competitionId/contests/:contestId

Description:

Update a contest for a given ID.

A reward can not be updated with a contest. All the rewards that need to be updated within a contest have to be deleted by inserting the reward Id in the "deleteRewards" parameter and new ones will be created by inserting the reward model in the "rewards" parameter.


Resource URL:

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

Request header

KeyValueRequired
X-API-KEY
Your unique API keyYes
Content-Type
application/jsonYes

Request URL parameter

Parameter
Type
Required
Description
space
StringYesThis is the space name which is linked to the account
competitionId
StringYesCompetition identifier retrieved from GET Competitions resource
contestId
StringYesContest identifier retrieved from GET contests request

Put 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
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).
rewardArray [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 PUT https://app.competitionlabs.com/api/<your-space-name>/competitions/iLMexGUBOmEkXOJnG2MB/contests/n7MkxGUBOmEkXOJnoGMo
-d '{ "contest": { "competitionId": "8vDwZ20BmZKDVA-UDqap", "number": 0, "label": "Test", "description": "", "termsConditions": "", "round": 1, "roundType": "TimeBound", "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" }]}]}], "autoStart": true, "autoStop": true, "scheduledDates": { "jsonClass": "StartEndDate", "start": "2019-09-27T14:25:00.000+00:00", "end": "2019-09-24T15:25:00.000+00:00" }, "optinRequiredForEntrants": false }}, "rewards": [{ "jsonClass": "Reward", "entityId": "", "rewardRank": "2", "rewardName": "Test", "value": 1.0, "rewardType": "GuyNjGYBZ-qHKtWie_x4", "description": "", "memberAcknowledgmentRequired": false, "metadata": [], "pointInTime": "2019-09-24T14:03:14.204+00:00" }], "deleteRewards": ["Ow0faG0BY3Ny-K3H2een"]}'
Response
{
    "data": {
        "jsonClass": "Contest",
        "accountId": "FuyNjGYBZ-qHKtWicfwh",
        "competitionId": "CfAeaG0BmZKDVA-Uzacw",
        "number": 0,
        "label": "Test",
        "description": "",
        "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-27T14:25:00.000+00:00",
                "end": "2019-09-24T15:25:00.000+00:00"
            },
            "actualDates": {
                "jsonClass": "StartEndDate"
            },
            "optinRequiredForEntrants": false,
            "useGlobalEvents": false
        },
        "created": "2019-09-25T11:13:00.443+00:00",
        "id": "DvAfaG0BmZKDVA-U2Kcb",
        "translations": {},
        "status": "NotStarted",
        "statusCode": 0,
        "translatableFields": [
            "label",
            "description",
            "termsConditions"
        ]
    }
}

ERROR CODES

CodeHTTP StatusDescriptionExample
1007404Contest with CL-contestId not found.
Error Response 404
{
    "errors": [
        {
            "message": "Contest with CL-contestId: DvAfaG0BmZKDVA-U2Kcba not found.",
            "code": 1007,
            "status": 404
        }
    ]
}
1001400
  • number parameter was excluded;
  • label parameter was excluded;
  • competitionId parameter was excluded;
  • round parameter was excluded;
  • roundType parameter was excluded;


Error Response 400
{
    "errors": [
        {
            "message": "Could not extract contest, make sure that the model is correctly defined",
            "code": 1001,
            "status": 400
        }
    ]
}
  • entityId parameter was excluded;
  • rewardRank parameter was excluded;
  • rewardName parameter was excluded;
  • value parameter was excluded;
  • rewardType parameter was excluded;
  • description parameter was excluded;
Error Response 400
{
    "errors": [
        {
            "message": "Could not extract rewards, make sure that the models is correctly defined",
            "code": 1001,
            "status": 400
        }
    ]
}
2023409Rules cannot be empty
Error Response 409
{
    "errors": [
        {
            "message": "Rules cannot be empty.",
            "code": 2023,
            "status": 409
        }
    ]
}
3008412
  • Contest parameters are locked for a contest in Active status
  • Contest parameters are locked for a contest in Canceled status
  • Contest parameters are locked for a contest in Finished status
Error Response 412
{
    "errors": [
        {
            "message": "Invalid operation request. Contest parameters are locked for a contest in Active status.",
            "code": 3008,
            "status": 412
        }
    ]
}

503scheduleDate parameter was excluded;
Error Response 503
{
    "status": 503
}