User Survey Submit
Request Details
Item | Value |
Description | This endpoint submits a survey response. |
Method | POST |
Endpoint | https://[environment]api[client_id].crowdtwist.com//v2.1/users/[user_id]/survey/[activity_id]/response?api_key=[api_key]&id_type=[id_type] |
HTTP Header |
X-CT-Authorization = CTApiKey [API Key] Note: There is a space between CTApiKey and the API Key value. |
Content Type | application/json |
Request
Field Name | Sample Value | Required | Format | Notes |
URL PARAMETERS | ||||
activity_id | 1 | Yes | String | Activity ID of survey being submitted to. |
QUERY STRING PARAMETERS | ||||
api_key | QWERTYP | Yes | String | |
id_type | No | String | Type of ID being sent, defaults to ID if not specified. Options: – facebook_user_id – twitter_user_id – id (CrowdTwist ID default if blank) – third_party_id – username – mobile_phone_number |
Request Body
Field Name |
Sample Value |
Required |
Format |
Description |
survey_response | See the SURVEY RESPONSE ARRAY section. | Yes | Array | An array of survey response objects. |
SURVEY RESPONSE ARRAY | ||||
question_id | 10 | Yes | Integer | The id of the question. |
selected_answers | [1,2,3] | No | Array | An array containing one or more selected answer. This should be null for freeform text questions and answers where only “Other” is selected. |
text_answer | My Answer | No | String | The answer to freeform text questions. This should be set to null or not included for multi and single select multiple choice questions. |
other | This is a freeform response | No | String | The value a user submits when choosing “Other”. Should be null when no freeform answer is provided. |
Response
Response Body
Field Name | Sample Value | Required | Format | Description |
activity_id | 1 | Yes | Integer | The ID of the survey. |
message | “survey response submitted successfully” | Yes | String | A response message. |
points_awarded | 100 | Yes | Integer | The number of points the user was awarded. |
total_responses | 1000 | Yes | Integer | The number of unique members that have responded to this survey. |
Error Responses
Field Name |
Sample Value |
Required |
Format |
Description |
---|---|---|---|---|
error |
Field value is empty. |
Yes |
String |
This is a short form of the error. |
message |
Value of field [fieldname] must not be empty |
Yes |
String |
This is a detailed message around the error specifying, as specifically as possible, what the fields are that are missing or where exactly the error is. |
Error Response Codes
Error | Error Code | Description | Reason |
---|---|---|---|
Input Error | 4xx | Returned whenever the request is missing required fields, including situations in which the body is malformed (e.g. HTTP method not supported, receipt not found, etc.). | – missing_data – not_unique – receipt_not_found – invalid_amount – invalid_currency – invalid_date – invalid_custom_field – invalid |
Server Error | 5xx | HTTP error status code is returned due to an error that occurred in the backend. | – internal_error: unexpected error occurred in the CrowdTwist backend – missing_field – invalid_data – not_configured: error occurs when an configuration has not been configured yet |
Example Response Codes
Response Code | Error | Message |
400 | input_error | Member has already submitted a response. |
403 | forbidden | Survey is not active. |
404 | page_not_found | Unable to find user. |
Samples
Sample Request
Sample Request Body
Sample Response Body
Sample Error Response