POST: https://{{env}}.survey2connect.com/v2/api/surveys/survey_id/create-response

The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.

"Content-Type": "application/json"
type: Api Key  
Key: x-api-key 
token: value from portal 

Request Parameters

{{surId}}: Unique Survey ID

Request Body

{
    "collector_id": "648ac090604b8c19045d601e",
    "responses": [
        {
            "custom_variables": {
                "email": "demo_user@example.com",
                "fName": "John",
                "lName": "Doe",
                "mobile": "9999999999",
                "gender": "male"
            },
            "questions": [
                {
                    "_id": "648ab726604b8c19045d56f1",
                    "answer": [{
                        "row_id": "63ee06faa4e134342509c22c"
                    }]
                }
            ]
        }
    ]
}

The flow and methodologies are explained below:

Field Type Mandatory Description
Collector_id string Yes Id of the collector used
responses array Yes Contains all the details about the response
questions array Yes Contains all the answers for the survey questions

Each REST API request returns an HTTP status code. For successful requests, it returns HTTP 200 status code. For failed requests, it returns HTTP 4XX or 5XX status codes. The status codes are explained below:

HTTP status codes:

Status Code Description
200 Request payload has all necessary keys. Messages will send in response data
400 Invalid URL parameters
401 The authorization token provided was invalid
500 We couldn’t process your request

Request Sample

curl --location --request POST 'https://az1.survey2connect.com/v2/api/surveys/survey_id/create-response' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOiJzM3E1OWF2cFdIcXVKa0I0MjRpcFpqQVN0dXAzQzFkZEhVM3k2TjNZSXRjPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI0MTIxMDc1NC01ODVkLTRjNmQtODc2NC02Mzg0NzJkYTRhODEiLCJ6b25laW5mbyI6InByb2RfYXoxIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImN1c3RvbTpwYXNzd29yZFRvQmVSZXNldCI6ImZhbHNlIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmFwLXNvdXRoLTEuYW1hem9uYXdzLmNvbVwvYXAtc291dGgtMV9zalNzc2JrOXYiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOmZhbHNlLCJjdXN0b206dUlkIjoiNjExYmEzNTcwZjdhNDEyNDYxM2MyMzg2IiwiY29nbml0bzp1c2VybmFtZSI6IjQxMjEwNzU0LTU4NWQtNGM2ZC04NzY0LTYzODQ3MmRhNGE4MSIsImF1ZCI6Ijg1azh1b2RqODBpazUzb2F0cDRycWJsYmMiLCJldmVudF9pZCI6IjE1NWYzNDA5LTkxOTQtNGIwOC05NzI1LTk1ZjEyOTViMGRjMSIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNjY5MTgzOTQ3LCJjdXN0b206c3RhdHVzIjoiYWN0aXZlIiwibmFtZSI6IlRlc3QgRCIsInBob25lX251bWJlciI6Iis5MTc0MTc0NjExNzYiLCJleHAiOjE2NjkyNzAzNDcsImN1c3RvbTpyb2xlIjoiYnJhbmRBZG1pbiIsImlhdCI6MTY2OTE4Mzk0NywiZW1haWwiOiJkYXZpbmRlci5zQHN1cnZleTJjb25uZWN0LmNvbSJ9.TCnoiWVPKpMQq9ygME2y-arC653tbTu8Rpm6ziyWDjAhkfiEP42LiGYPAOHJrPb_G5AzGlbKeKeDhx7DCKKGb9ZVg36ltiCOH3KapscL2PB_6qeKDXZfGTDUjUqxVjsuFXeLVGRIUpmgEjQq3f8lnKLEBHPspwvbxZ7jcSuk9BAO2VDAtdPulmiYF7NhfBQ2xXdpYaJiJxJPkdz-vZfvofRITKTu8XgozT0IRTHJ5lP3yYLc9asDflYNs-np2g4bwn8St_lEOT6abhOpoH6DpHT1yNaP7w1zQ3U0lXCaZ4imGp7ETZ5kYpuRMuJ8bINUCZHyi8uQF-rZkv6Fk6-Gmg' \
--data-raw '{
--data-raw '{
    "collector_id": "64a5a4cb3961bc1a83d084c0",
    "responses": [
        {
            "custom_variables": {
                "email": "demo_user@example.com",
                "fName": "John",
                "lName": "Doe",
                "mobile": "9999999999",
                "gender": "male"
            },
            "questions": [
                {
                    "_id": "64a5a452ca03ef1abdbf3ff4",
                    "answer": [{
                        "row_id": "64a5a452ca03ef1abdbf3ff5"
                    }]
                }
            ]
        }
    ]
}'
var myHeaders = new Headers(); 
myHeaders.append("Authorization", "Bearer eyJraWQiOiJzM3E1OWF2cFdIcXVKa0I0MjRpcFpqQVN0dXAzQzFkZEhVM3k2TjNZSXRjPSIsImFs); 
myHeaders.append("Content-Type", "application/json"); 
var raw = JSON.stringify({ 
   "collector_id": "64a5a4cb3961bc1a83d084c0",
  "responses": [
    {
      "custom_variables": {
        "email": "demo_user@example.com",
        "fName": "John",
        "lName": "Doe",
        "mobile": "9999999999",
        "gender": "male"
      },
      "questions": [
        {
          "_id": "64a5a452ca03ef1abdbf3ff4",
          "answer": [
            {
              "row_id": "64a5a452ca03ef1abdbf3ff5"
            }
          ]
        }
      ]
    }
  ]
});
var requestOptions = { 
  method: 'POST', 
  headers: myHeaders, 
  body: raw, 
  redirect: 'follow' 
}; 
fetch("https://az1.survey2connect.com/v2/api/surveys/63281de56d497d12b49199c1/response-count", requestOptions) 
  .then(response => response.text()) 
  .then(result => console.log(result))    .catch(error => console.log('error', error));  

Responses

{
      "responses": [
       {
           "responseId": "64a2a2dce1a8e02a5bbde8a1",
           "created": "2023-07-03T10:28:44.297Z"
        }
      ],
       "message": "Responses are created"
}
{ 
    "error": { 
        "name": "Unauthorized", 
        "message": "The authorization token was not provided." 
    } 
} 
{   
    "error": {   
         "name": "Internal Server Error",   
         "message": "We were not able to process your request"   
    }   
} 

Get Response Count

POST: https://{{env}}.survey2connect.com/v2/api/surveys/{{surId}}/response-count The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.…

Get Responses (CSV format)

POST: https://{{env}}.survey2connect.com/v2/api/surveys/{{surId}}/responses/csv The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.…

Get Responses (JSON Format)

POST: https://{{env}}.survey2connect.com/v2/api/surveys/{{surId}}/responses/json The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.…

Ask a human

Can't Find What You're Looking For?