User Survey Submit


Request Details

Item Value
Description Submits a survey response.
Method POST
Endpoint https://api.crowdtwist.com/v2/survey/[survey_id]/?api_key=[api_key]&id_type=[id_type]
Content Type: JSON (application/json)


Request

Field Name Sample Value Required Format Notes
URL PARAMETERS
survey_id 23 Yes String ID of survey being submitted to.
QUERY STRING PARAMETERS
api_key QWERTYUIOP Yes String
id_type email No String Type of ID being sent, defaults to ID if not specified.
Options:
– email
– facebook_user_id
– twitter_user_id
– id (CrowdTwist ID default if blank)
– third_party_id
– username
– mobile_phone_number
REQUEST BODY
user_id 1 Yes Mixed ID of user.
survey_responses Response Object Yes Array Array of answers to survey questions.
RESPONSE OBJECT
id 45 No String ID of question.
value Drug Store No String Answer to question specified in id field.
image_id 9105ba5937e340fb6bac58e2edd6359e5180b90b No String For answers with multiple images, values are pipe delimited.
image_url https://sample.crowdtwist.com/img/v2/9105b0b90b/100/100/0/image.jpg No String For answers with multiple images, values are pipe delimited.

Sample Request

{
  "user_id": 11122266,
  "survey_responses": [
    {
      "id": "3690",
      "value": "3"
    },
    {
      "id": "4768",
      "value": "1|4|5",
      "image_id": "59afe4e56214bea2ea44e9213d322b7e0407e53c|cbb6373ac9aa931769a25a0173bb9d21db7fc934|eee99ee267e988bb527ec2ee0e976a01138184ff",
      "image_url": "https://cdn.crowdtwist.com/img/v2/59afe4e56214bea2ea44e9213d322b7e0407e53c/100/100/0/image.jpg|https://cdn.crowdtwist.com/img/v2/cbb6373ac9aa931769a25a0173bb9d21db7fc934/100/100/0/image.jpg|https://cdn.crowdtwist.com/img/v2/eee99ee267e988bb527ec2ee0e976a01138184ff/100/100/0/image.jpg"
    },
    {
      "id": "4769",
      "value": "Testing text input!",
      "image_id": null,
      "image_url": null
    }
  ]
}
{
  "user_id": 11122266,
  "survey_responses": [
    {
      "id": "3690",
      "value": "3"
    },
    {
      "id": "4768",
      "value": "1|4|5",
      "image_id": "59afe4e56214bea2ea44e9213d322b7e0407e53c|cbb6373ac9aa931769a25a0173bb9d21db7fc934|eee99ee267e988bb527ec2ee0e976a01138184ff",
      "image_url": "https://cdn.crowdtwist.com/img/v2/59afe4e56214bea2ea44e9213d322b7e0407e53c/100/100/0/image.jpg|https://cdn.crowdtwist.com/img/v2/cbb6373ac9aa931769a25a0173bb9d21db7fc934/100/100/0/image.jpg|https://cdn.crowdtwist.com/img/v2/eee99ee267e988bb527ec2ee0e976a01138184ff/100/100/0/image.jpg"
    },
    {
      "id": "4769",
      "value": "Testing text input!",
      "image_id": null,
      "image_url": null
    }
  ]
}


Successful Response – Activity Object

Field Name Sample Value Required Format Description
id 225 Yes String CrowdTwist internal ID for activity
date_created 1425404945 Yes Integer Date activity was recorded
name shared a link Yes String Name of activity
num_points 1000 Yes Integer Points earned for completing activity
extra_data {
survey_type : “monthly”
}
No JSON Extra data set via User Survey Submit API (JSON)

Successful Response – Request Body

Field Name Sample Value Required Format Description
id 45 No String ID of question.
value Drug Store No String Answer to question specified in id field


Error Response

Field Name Sample Value Required Format Description
error param_error Yes String A machine readable code that describes the error.
message Missing the user_id parameter Yes String A short, descriptive sentence detailing the error.


Error Response Codes

Error Message
input_error The input provided in invalid or formatted incorrectly.
internal_error Something went wrong on our end.
page_not_found The requested page does not exist or has been removed.
param_error A missing or invalid parameter is included in the request.
questions_required Answers to one or more questions required.


Sample Request

curl -X POST
'https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email'
{
  "user_id": "13546",
  "survey_responses": [
    {
      "id": "45",
      "value": "Drug Store"
    },
    {
      "id": "56",
      "value": "Department Store"
    }
  ],
  "extra_data": {
    "survey_type": "monthly"
  }
}
curl -X POST
'https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email'
{
  "user_id": "13546",
  "survey_responses": [
    {
      "id": "45",
      "value": "Drug Store"
    },
    {
      "id": "56",
      "value": "Department Store"
    }
  ],
  "extra_data": {
    "survey_type": "monthly"
  }
}


Sample Multi-Select Request

curl -X POST
'https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email'
{
  "user_id": 3,
  "survey_responses":[
  {
    "id": "403",
    "value": "test"
  },
  {
    "id": "404",
    "value": "Test 1",
    "image_id": "9105ba5937e340fb6bac58e2edd6359e5180b90b",
          "image_url": "http://local.crowdtwist.com/img/v2/9105ba5937e340fb6bac58e2edd6359e5180b90b/100/100/0/image.jpg"
  },
  {
    "id": "405",
    "value": "Test 4|Test 3",
    "image_id": "44f25a7ef823952efc3d231459a2da9f0489d209|9573321255a9793f0984937883677427d39bebd6",
          "image_url": "http://local.crowdtwist.com/img/v2/44f25a7ef823952efc3d231459a2da9f0489d209/100/100/0/image.jpg|http://local.crowdtwist.com/img/v2/9573321255a9793f0984937883677427d39bebd6/100/100/0/image.jpg"
  }
  ]
}
curl -X POST
'https://api.crowdtwist.com/v2/survey/23/?api_key=QWERTYUIOP&id_type=email'
{
  "user_id": 3,
  "survey_responses":[
  {
    "id": "403",
    "value": "test"
  },
  {
    "id": "404",
    "value": "Test 1",
    "image_id": "9105ba5937e340fb6bac58e2edd6359e5180b90b",
          "image_url": "http://local.crowdtwist.com/img/v2/9105ba5937e340fb6bac58e2edd6359e5180b90b/100/100/0/image.jpg"
  },
  {
    "id": "405",
    "value": "Test 4|Test 3",
    "image_id": "44f25a7ef823952efc3d231459a2da9f0489d209|9573321255a9793f0984937883677427d39bebd6",
          "image_url": "http://local.crowdtwist.com/img/v2/44f25a7ef823952efc3d231459a2da9f0489d209/100/100/0/image.jpg|http://local.crowdtwist.com/img/v2/9573321255a9793f0984937883677427d39bebd6/100/100/0/image.jpg"
  }
  ]
}


Sample Successful Response: Status Code 200

{
  "activity_id": 12345,
  "date_created": 143216432,
  "name": "survey activity name",
  "num_points": 100,
  "extra_data": {
    "survey_type": "monthly"
  }
}
{
  "activity_id": 12345,
  "date_created": 143216432,
  "name": "survey activity name",
  "num_points": 100,
  "extra_data": {
    "survey_type": "monthly"
  }
}

Sample Error Response: Status Code 400

{
  "error": "param_error",
  "message": "Missing the #user_id parameter."
}
{
  "error": "param_error",
  "message": "Missing the #user_id parameter."
}