https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/responses?apiKey={{apiKey}}
The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.
{
"responseSet": [
{
"questionID": 12345678,
"answerValues": [
{
"answerID": 123456789
}
}
]
},
{
"questionID": 12345679,
"answerValues": [
{
"answerID": 100000001,
"value": {
"text": "FirstName"
}
}
]
},
{
"questionID": 83734737,
"answerValues": [
{
"answerID": 100000002,
"value": {
"text": "LastName"
}
}
]
},
{
"questionID": 83734738,
"answerValues": [
{
"answerID": 100000003,
"value": {
"text": "123-456-7890"
}
}
]
},
{
"questionID": 83734739,
"answerValues": [
{
"answerID": 100000004,
"value": {
"text": "respondentemail@emaildomain.com"
}
}
]
}
]
}
{
"ipAddress": "192.168.0.1",
"timestamp": "05 Oct, 2020 02:51:51 PM PDT",
"location": {
"country": null,
"region": "16",
"latitude": 0.0,
"longitude": 0.0,
"radius": 0.0,
"countryCode": "IN"
},
"duplicate": false,
"timeTaken": 41,
"responseStatus": "Completed",
"externalReference": "",
"customVariables": {
"custom1": null,
"custom2": null,
"custom3": null,
"custom4": null,
"custom5": null
},
"language": "English",
"currentInset": "",
"operatingSystem": "WINDOWS_10",
"osDeviceType": "COMPUTER",
"browser": "CHROME8",
"responseSet": [
{
"questionID": 12345678,
"questionDescription": " ",
"questionCode": "Q1",
"questionText": "How often do you conduct surveys?",
"imageUrl": null,
"answerValues": [
{
"answerID": 123456789,
"answerText": "Always",
"value": {
"scale": "1",
"other": "",
"dynamicExplodeText": "",
"text": "",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 12345679,
"questionDescription": "Contact Information",
"questionCode": "Q2_1",
"questionText": "First Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000001,
"answerText": "FIRST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "FirstName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734737,
"questionDescription": " ",
"questionCode": "Q2_2",
"questionText": "Last Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000002,
"answerText": "LAST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "LastName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734738,
"questionDescription": " ",
"questionCode": "Q2_3",
"questionText": "Phone",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000003,
"answerText": "PHONE",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "123-456-7890",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734739,
"questionDescription": " ",
"questionCode": "Q2_4",
"questionText": "Email Address",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000004,
"answerText": "EMAIL",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "respondentemail@emaildomain.com",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
}
]
}
curl --request POST \
--url 'https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/responses?apiKey={{apiKey}}' \
--header 'Content-Type: application/json' \
--data '{
"ipAddress": "192.168.0.1",
"timestamp": "05 Oct, 2020 02:51:51 PM PDT",
"location": {
"country": null,
"region": "16",
"latitude": 0.0,
"longitude": 0.0,
"radius": 0.0,
"countryCode": "IN"
},
"duplicate": false,
"timeTaken": 41,
"responseStatus": "Completed",
"externalReference": "",
"customVariables": {
"custom1": null,
"custom2": null,
"custom3": null,
"custom4": null,
"custom5": null
},
"language": "English",
"currentInset": "",
"operatingSystem": "WINDOWS_10",
"osDeviceType": "COMPUTER",
"browser": "CHROME8",
"responseSet": [
{
"questionID": 12345678,
"questionDescription": " ",
"questionCode": "Q1",
"questionText": "How often do you conduct surveys?",
"imageUrl": null,
"answerValues": [
{
"answerID": 123456789,
"answerText": "Always",
"value": {
"scale": "1",
"other": "",
"dynamicExplodeText": "",
"text": "",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 12345679,
"questionDescription": "Contact Information",
"questionCode": "Q2_1",
"questionText": "First Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000001,
"answerText": "FIRST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "FirstName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734737,
"questionDescription": " ",
"questionCode": "Q2_2",
"questionText": "Last Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000002,
"answerText": "LAST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "LastName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734738,
"questionDescription": " ",
"questionCode": "Q2_3",
"questionText": "Phone",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000003,
"answerText": "PHONE",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "123-456-7890",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734739,
"questionDescription": " ",
"questionCode": "Q2_4",
"questionText": "Email Address",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000004,
"answerText": "EMAIL",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "respondentemail@emaildomain.com",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
}
]
}'
import requests
url = "https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/responses"
querystring = {"apiKey":"{{apiKey}}"}
payload = "{\"ipAddress\":\"192.168.0.1\",\"timestamp\":\"05 Oct, 2020 02:51:51 PM PDT\",\"location\":{\"country\":null,\"region\":\"16\",\"latitude\":0,\"longitude\":0,\"radius\":0,\"countryCode\":\"IN\"},\"duplicate\":false,\"timeTaken\":41,\"responseStatus\":\"Completed\",\"externalReference\":\"\",\"customVariables\":{\"custom1\":null,\"custom2\":null,\"custom3\":null,\"custom4\":null,\"custom5\":null},\"language\":\"English\",\"currentInset\":\"\",\"operatingSystem\":\"WINDOWS_10\",\"osDeviceType\":\"COMPUTER\",\"browser\":\"CHROME8\",\"responseSet\":[{\"questionID\":12345678,\"questionDescription\":\" \",\"questionCode\":\"Q1\",\"questionText\":\"How often do you conduct surveys?\",\"imageUrl\":null,\"answerValues\":[{\"answerID\":123456789,\"answerText\":\"Always\",\"value\":{\"scale\":\"1\",\"other\":\"\",\"dynamicExplodeText\":\"\",\"text\":\"\",\"result\":\"\",\"fileLink\":\"\",\"weight\":0}}]},{\"questionID\":12345679,\"questionDescription\":\"Contact Information\",\"questionCode\":\"Q2_1\",\"questionText\":\"First Name\",\"imageUrl\":null,\"answerValues\":[{\"answerID\":100000001,\"answerText\":\"FIRST_NAME\",\"value\":{\"scale\":\"\",\"other\":\"\",\"dynamicExplodeText\":\"\",\"text\":\"FirstName\",\"result\":\"\",\"fileLink\":\"\",\"weight\":0}}]},{\"questionID\":83734737,\"questionDescription\":\" \",\"questionCode\":\"Q2_2\",\"questionText\":\"Last Name\",\"imageUrl\":null,\"answerValues\":[{\"answerID\":100000002,\"answerText\":\"LAST_NAME\",\"value\":{\"scale\":\"\",\"other\":\"\",\"dynamicExplodeText\":\"\",\"text\":\"LastName\",\"result\":\"\",\"fileLink\":\"\",\"weight\":0}}]},{\"questionID\":83734738,\"questionDescription\":\" \",\"questionCode\":\"Q2_3\",\"questionText\":\"Phone\",\"imageUrl\":null,\"answerValues\":[{\"answerID\":100000003,\"answerText\":\"PHONE\",\"value\":{\"scale\":\"\",\"other\":\"\",\"dynamicExplodeText\":\"\",\"text\":\"123-456-7890\",\"result\":\"\",\"fileLink\":\"\",\"weight\":0}}]},{\"questionID\":83734739,\"questionDescription\":\" \",\"questionCode\":\"Q2_4\",\"questionText\":\"Email Address\",\"imageUrl\":null,\"answerValues\":[{\"answerID\":100000004,\"answerText\":\"EMAIL\",\"value\":{\"scale\":\"\",\"other\":\"\",\"dynamicExplodeText\":\"\",\"text\":\"respondentemail@emaildomain.com\",\"result\":\"\",\"fileLink\":\"\",\"weight\":0}}]}]}"
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
{
"response": {
"responseID": 12345678,
"surveyID": 7654321,
"surveyName": "Test Survey",
"ipAddress": "192.168.0.1",
"timestamp": "05 Oct, 2020 02:51:51 PM PDT",
"location": {
"country": null,
"region": "16",
"latitude": 0.0,
"longitude": 0.0,
"radius": 0.0,
"countryCode": "IN"
},
"duplicate": false,
"timeTaken": 41,
"responseStatus": "Completed",
"externalReference": "",
"customVariables": {
"custom1": null,
"custom2": null,
"custom3": null,
"custom4": null,
"custom5": null
},
"language": "English",
"currentInset": "",
"operatingSystem": "WINDOWS_10",
"osDeviceType": "COMPUTER",
"browser": "CHROME8",
"responseSet": [
{
"questionID": 12345678,
"questionDescription": " ",
"questionCode": "Q1",
"questionText": "How often do you conduct surveys?",
"imageUrl": null,
"answerValues": [
{
"answerID": 123456789,
"answerText": "Always",
"value": {
"scale": "1",
"other": "",
"dynamicExplodeText": "",
"text": "",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 12345679,
"questionDescription": "Contact Information",
"questionCode": "Q2_1",
"questionText": "First Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000001,
"answerText": "FIRST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "FirstName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734737,
"questionDescription": " ",
"questionCode": "Q2_2",
"questionText": "Last Name",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000002,
"answerText": "LAST_NAME",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "LastName",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734738,
"questionDescription": " ",
"questionCode": "Q2_3",
"questionText": "Phone",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000003,
"answerText": "PHONE",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "123-456-7890",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
},
{
"questionID": 83734739,
"questionDescription": " ",
"questionCode": "Q2_4",
"questionText": "Email Address",
"imageUrl": null,
"answerValues": [
{
"answerID": 100000004,
"answerText": "EMAIL",
"value": {
"scale": "",
"other": "",
"dynamicExplodeText": "",
"text": "respondentemail@emaildomain.com",
"result": "",
"fileLink": "",
"weight": 0.0
}
}
]
}
]
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"surveyID": {
"type": "integer"
},
"ipAddress": {
"type": "string",
"format": "ipv4"
},
"language": {
"type": "string"
},
"duplicate": {
"type": "boolean"
},
"responseStatus": {
"type": "string"
},
"operatingSystem": {
"type": "string"
},
"customVariables": {
"type": "object",
"properties": {
"custom3": {
"type": "null"
},
"custom4": {
"type": "null"
},
"custom1": {
"type": "null"
},
"custom2": {
"type": "null"
},
"custom5": {
"type": "null"
}
},
"additionalProperties": false
},
"externalReference": {
"type": "string"
},
"osDeviceType": {
"type": "string"
},
"timeTaken": {
"type": "integer"
},
"currentInset": {
"type": "string"
},
"surveyName": {
"type": "string"
},
"browser": {
"type": "string"
},
"location": {
"type": "object",
"properties": {
"country": {
"type": "null"
},
"countryCode": {
"type": "string"
},
"latitude": {
"type": "number"
},
"region": {
"type": "string"
},
"radius": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"additionalProperties": false,
"required": [
"countryCode",
"latitude",
"region",
"radius",
"longitude"
]
},
"responseSet": {
"type": "array",
"items": {
"type": "object",
"properties": {
"questionDescription": {
"type": "string"
},
"questionID": {
"type": "integer"
},
"questionCode": {
"type": "string"
},
"imageUrl": {
"type": "null"
},
"answerValues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"answerID": {
"type": "integer"
},
"answerText": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"result": {
"type": "string"
},
"other": {
"type": "string"
},
"fileLink": {
"type": "string"
},
"scale": {
"type": "string"
},
"dynamicExplodeText": {
"type": "string"
},
"weight": {
"type": "number"
},
"text": {
"anyOf": [
{
"type": "string",
"format": "email"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false,
"required": [
"result",
"other",
"fileLink",
"scale",
"dynamicExplodeText",
"weight",
"text"
]
}
},
"additionalProperties": false,
"required": [
"answerID",
"answerText",
"value"
]
}
},
"questionText": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"questionDescription",
"questionID",
"questionCode",
"answerValues",
"questionText"
]
}
},
"responseID": {
"type": "integer"
},
"timestamp": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"surveyID",
"ipAddress",
"language",
"duplicate",
"responseStatus",
"operatingSystem",
"customVariables",
"externalReference",
"osDeviceType",
"timeTaken",
"currentInset",
"surveyName",
"browser",
"location",
"responseSet",
"responseID",
"timestamp"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "BAD_REQUEST",
"httpStatusCode": 400,
"id" : "1000",
"message": "Invalid URL parameters",
"resourceUrl":"resource_url"
}
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"docs": {
"type": "string"
},
"resourceUrl": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"httpStatusCode": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"docs",
"resourceUrl",
"name",
"id",
"message",
"httpStatusCode"
]
}
},
"additionalProperties": false,
"required": [
"error"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "UNAUTHORIZED",
"httpStatusCode": 401,
"id" : "1010",
"message": "Incorrect API Key",
"resourceUrl":"resource_url"
}
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"docs": {
"type": "string"
},
"resourceUrl": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"httpStatusCode": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"docs",
"resourceUrl",
"name",
"id",
"message",
"httpStatusCode"
]
}
},
"additionalProperties": false,
"required": [
"error"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "FORBIDDEN",
"httpStatusCode": 403,
"id" : "1013",
"message": "The user does not have permission to access the resource",
"resourceUrl":"resource_url"
}
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"docs": {
"type": "string"
},
"resourceUrl": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"httpStatusCode": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"docs",
"resourceUrl",
"name",
"id",
"message",
"httpStatusCode"
]
}
},
"additionalProperties": false,
"required": [
"error"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "NOT_FOUND",
"httpStatusCode": 404,
"id" : "1040",
"message": "The resource that you're trying to access doesn't exist",
"resourceUrl":"resource_url"
}
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"docs": {
"type": "string"
},
"resourceUrl": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"httpStatusCode": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"docs",
"resourceUrl",
"name",
"id",
"message",
"httpStatusCode"
]
}
},
"additionalProperties": false,
"required": [
"error"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "INTERNAL_SERVER_ERROR",
"httpStatusCode": 500,
"id" : "1026",
"message": "We are not able to process your request",
"resourceUrl":"resource_url"
}
}
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"docs": {
"type": "string"
},
"resourceUrl": {
"type": "string"
},
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"httpStatusCode": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"docs",
"resourceUrl",
"name",
"id",
"message",
"httpStatusCode"
]
}
},
"additionalProperties": false,
"required": [
"error"
]
}
},
"additionalProperties": false,
"required": [
"response"
]
}