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
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.
{
"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
| Status | code | error | When |
|---|---|---|---|
400 | bad_request | The request body must be a JSON object | The 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 |
400 | bad_request | surveyId must be a whole number from 1 to 2147483647 | surveyId is missing, is not a whole number, or is outside 1 to 2,147,483,647 |
400 | bad_request | answers must be an object of answers by question key | answers 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 |
400 | bad_request | The question and the rule | An answer its question doesn't take. The body includes field: "answers" and the question's key in question |
401 | connection_ended | This connection has ended | The connection or this device was ended since the player session was made. Discard the stored tokens and show the player as disconnected |
404 | survey_not_found | Survey not found | The survey does not exist in this community |
409 | hub_not_enabled | This game does not show the community's quests, shop and rank | The game loop is disabled for the game |
409 | sharing_needed | The member has not consented to sharing their data with this game | The member has not consented, or must consent again. The body includes manageUrl: send the player there |
409 | membership_required | The member has to be in the server to use this | The Discord account is not in the server. The body includes membership and, for left and not_member, joinUrl |
409 | survey_unavailable | This survey cannot be answered right now | The 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) |
413 | body_too_large | The request body is larger than 16 KB | The body is larger than 16 KB. Nothing was changed |
503 | bot_unavailable | This could not be done right now and nothing was changed. Try again in a few seconds | CEEJAY's bot could not be reached or was too busy, and nothing was changed. The body includes retryAfter, in seconds |
504 | bot_timeout | The 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 repeat | The 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.

