POST /api/:space/competitions

Description:

Create a new competition. Once a competition is registered it will be automatically moved to a Ready state.

Resource URL:

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

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

Post body parameters

Parameter
Type
Required
Description
competitionType
StringYesCompetition Type enums. Default is Leaderboard
entrantMemberType
StringYesMember type Default is Individual
numberOfRounds
IntegerOptionalNumber of rounds to be played in a competition. Default is 1
label
StringYesThe title of the competition
description
StringOptional

Description of the competition

termsConditions
StringOptionalTerms and conditions of a competition
options
ObjectYes

From Options domain model the only entries that are required:

TypeRequiredDescription
numberOfEntrants
IntegerYesThe maximum and minimum number of entrants
products
Array [Object]YesThe Product model
autoStart
BooleanYesTrue if you want the Competition to auto start
autoStopBooleanYesTrue if you want the Competition to auto end
scheduledDates
DateTimeYesThe date and time of when the competition should start and end
includeEntrantsWhere
ObjectYesThe ComplexFilters model
All the other entries
ObjectOptionalAll other entries from Options
metadata
Array [Object]Optional

A list of MetaData

status
StringNo

A status of a competition

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 '{ "competitionType": "Leaderboard", "entrantMemberType": "Individual", "numberOfRounds": 1, "label": "TEST API Comp", "description": "test", "termsConditions": "test", "options": { "numberOfEntrants": { "minimum": 1 }, "products": [{ "name": "fruits", "productType": "UNKNOWN", "description": "", "adjustmentFactor": 1.0, "productRefId": "fruits", "actionAdjustmentFactors": [{ "ruleActionHelper": { "jsonClass": "RuleActionHelper", "name": "spin", "key": "spin", "description": "", "accountId": "FuyNjGYBZ-qHKtWicfwh", "system": false, "metadata": [], "created": "2019-05-17T08:35:08.984+00:00", "id": "EpTuxGoBfMYIl33APh04" }, "adjustmentFactor": 1.0 }], "productGroups": [ "" ], "metadata": [], "created": "2019-05-17T08:33:05.483+00:00", "id": "2THsxGoBkhPuXvX2WyHL" }], "autoStart": true, "autoStop": true, "scheduledDates": { "start": "2019-09-24T11:39:00.000+00:00", "end": "2019-09-24T12:39:00.000+00:00" }, "includeEntrantsWhere": { "filters": [], "must": [], "mustNot": [], "should": [], "shouldMatchAtLeast": 0 }, "optinRequiredForEntrants": true }}'
Response
{
    "data":  {
        "jsonClass": "Competition",
        "accountId": "FuyNjGYBZ-qHKtWicfwh",
        "competitionType": "Leaderboard",
        "entrantMemberType": "Individual",
        "allowMultipleEntriesPerRound": true,
        "numberOfRounds": 1,
        "label": "TEST API Comp",
        "description": "test",
        "termsConditions": "test",
        "options": {
            "numberOfEntrants": {
                "jsonClass": "MaxMin",
                "minimum": 1
            },
            "products": [
                {
                    "jsonClass": "Product",
                    "name": "fruits",
                    "productType": "UNKNOWN",
                    "description": "",
                    "adjustmentFactor": 1.0,
                    "productRefId": "fruits",
                    "actionAdjustmentFactors": [
                        {
                            "ruleActionHelper": {
                                "jsonClass": "RuleActionHelper",
                                "name": "spin",
                                "key": "spin",
                                "description": "",
                                "accountId": "FuyNjGYBZ-qHKtWicfwh",
                                "system": false,
                                "metadata": [],
                                "created": "2019-05-17T08:35:08.984+00:00",
                                "id": "EpTuxGoBfMYIl33APh04"
                            },
                            "adjustmentFactor": 1.0
                        }
                    ],
                    "productGroups": [
                        ""
                    ],
                    "metadata": [],
                    "created": "2019-09-24T11:34:00.498+00:00"
                }
            ],
            "ruleSets": [],
            "isPublic": true,
            "autoStart": true,
            "autoStartRetryInterval": 1000,
            "autoStop": true,
            "autoStopRetryInterval": 1000,
            "scheduledDates": {
                "jsonClass": "StartEndDate",
                "start": "2019-09-24T11:39:00.000+00:00",
                "end": "2019-09-24T12:39:00.000+00:00"
            },
            "actualDates": {
                "jsonClass": "StartEndDate"
            },
            "includeEntrantsWhere": {
                "filters": [],
                "must": [],
                "mustNot": [],
                "should": [],
                "shouldMatchAtLeast": 0
            },
            "optinRequiredForEntrants": true,
            "useGlobalEvents": false
        },
        "created": "2019-09-24T11:34:00.508+00:00",
        "id": "u_AMY20BmZKDVA-UtqU8",
        "translations": {},
        "status": "Preparing",
        "statusCode": 2,
        "translatableFields": [
            "label",
            "description",
            "termsConditions"
        ]
    }
}

ERROR CODES

CodeHTTP StatusDescriptionExample
3018406includeEntrantsWhere parameter was excluded;
Error Response 406
{
    "errors": [
        {
            "message": "Competition Validation Failed - For competition [RPBiaG0BmZKDVA-UwKeR] no entrants are available.",
            "code": 3018,
            "status": 406
        }
    ]
}
1001400
  • competitionType parameter was empty or excluded;
  • entrantMemberType parameter was empty or excluded;
Error Response 400
{
    "errors": [
        {
            "message": "Malformed JSON body.",
            "code": 1001,
            "status": 400
        }
    ]
}