CEEJAYDocs

Answer a survey

Send the player's answers to a survey, by question key, and grant its rewards on the first completion.

POST /v1/player/surveys/answer · for player session

Use it when the player finishes a survey from List surveys. CEEJAY checks every answer by the rules Discord and the Member Hub use: a required question needs an answer, a number must be a number, an email address and a link must be one, a pick must be one of the question's options, and a score must be on its scale. The answers are saved to the member's response, and on the first completion CEEJAY grants the survey's rewards: its XP, its roles and its reward list. CEEJAY does not send the member a direct message. The request needs the game loop. For the three conditions (game loop enabled for the game, member consent, server membership) and the error each returns, see What has to be true first.

Body parameters

Prop

Type

Returns

Prop

Type

A second answer to a survey that lets members edit their answers updates them and grants nothing. A survey that does not returns survey_unavailable with the reason already_answered. The request is safe to repeat and takes no key.

Example

Request
curl -X POST https://ceejay.communitystudios.xyz/api/v1/player/surveys/answer \
  -H "Authorization: Bearer $CEEJAY_PLAYER_SESSION" \
  -H "Content-Type: application/json" \
  -d '{
    "surveyId": 41,
    "answers": {
      "k_00000000000000a1": "4",
      "k_00000000000000a3": "More maps, please"
    }
  }'

The TypeScript example uses connect.hub.answerSurvey from the Connect client in the TypeScript SDK. The player must be connected first: the client manages and refreshes the player session. It returns the data of the response below.

200 OK, the first completion
{
  "success": true,
  "data": {
    "surveyId": 41,
    "updated": false,
    "rewards": { "xp": 50, "roles": 0, "names": ["20 coins"] }
  }
}

A wrong answer

An answer its question doesn't take (an empty required question, text that is not a number, a pick that is not one of the options, a score off the scale) returns 400 with field: "answers", the question's key in question, and a message that names the question and the rule, such as How would you rate the build?: pick one of the options. Show it beside that question and let the player try again. Nothing is saved until every answer is right.

Limits

20 writes a minute for one player session, shared by every request of the game loop that changes something. Every request made with a player session also counts toward 140 a minute. See Rate limits. Over a limit the response is 429 with the code rate_limited, retryAfter and a Retry-After header.

Errors

StatuscodeerrorWhen
400bad_requestThe request body must be a JSON objectThe body is JSON but not an object. A body that is not JSON at all returns bad_request with the message The request body must be JSON
400bad_requestsurveyId must be a whole number from 1 to 2147483647surveyId is missing, is not a whole number, or is outside 1 to 2,147,483,647
400bad_requestanswers must be an object of answers by question keyanswers is missing or is not an object, holds more than 50 answers, or holds a key or a value that is not one a survey takes
400bad_requestThe question and the ruleAn answer its question doesn't take. The body includes field: "answers" and the question's key in question
401connection_endedThis connection has endedThe connection or this device was ended since the player session was made. Discard the stored tokens and show the player as disconnected
404survey_not_foundSurvey not foundThe survey does not exist in this community
409hub_not_enabledThis game does not show the community's quests, shop and rankThe game loop is disabled for the game
409sharing_neededThe member has not consented to sharing their data with this gameThe member has not consented, or must consent again. The body includes manageUrl: send the player there
409membership_requiredThe member has to be in the server to use thisThe Discord account is not in the server. The body includes membership and, for left and not_member, joinUrl
409survey_unavailableThis survey cannot be answered right nowThe survey cannot be answered now. The body includes reason and a message to show the player: not_open, closed, paused, role, already_answered, not_due (its game event has not been logged enough times yet), answer_in_discord or not_here (not shown in this game)
413body_too_largeThe request body is larger than 16 KBThe body is larger than 16 KB. Nothing was changed
503bot_unavailableThis could not be done right now and nothing was changed. Try again in a few secondsCEEJAY's bot could not be reached or was too busy, and nothing was changed. The body includes retryAfter, in seconds
504bot_timeoutThe answer did not arrive in time, and the request may or may not have been done. Send the same request again: it is safe to repeatThe request timed out, so it is not known whether it was processed. Send the same request again: it is safe to repeat

Every error body also includes requestId. Match on code; message text can change.

The errors every request of a game shares (the key, the state of the game, the origin, 405, 429, 500) are on the Errors page, and the errors specific to the game loop are under Codes of the game loop.

On this page

Community StudiosPrivacyTerms