Questions
Create a question
Creates a new survey question and apply it to a survey.
/v1/questionRequest Body
| Name | Type | Description |
|---|---|---|
| survey | String | The unique survey id to apply the question to. |
| type | String | The question type. Options: |
| title | String | The question title. |
| subtitle | String | optional The question subtitle. |
| required | Boolean | optional Whether the question is required or not. |
| properties | Object | optional Special properties specific to each question type. |
| comments | String | optional Label for comments field, if |
Examples
curl https://api.surveyplanet.com/v1/question
--request POST
--header "Content-Type: application/json"
--header "Authorization: Bearer <ACCESS_TOKEN>"
--data '{"survey":"62b9db151489dd913aeaa22f", ...}'// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/question`, {
method: "POST"
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <ACCESS_TOKEN>",
}
body: JSON.stringify({"survey":"62b9db151489dd913aeaa22f", ...})
})
.then( response => response.json() )
.then( res => console.log(res.data) )
.catch( err => console.error(err) );# This code sample uses the 'requests' library: pip show requests
import requests
response = requests.post(
'https://api.surveyplanet.com/v1/question',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
data = {"survey":"62b9db151489dd913aeaa22f", ...}
)
print(response.text)Success response example
Success response example - Response
{
"status": 200,
"type": "ok",
"message": "Request worked as expected."
"data": {
"meta": {
"tags": []
},
"_id": "62b9db151489dd913aeaa22f",
"user": "62bb2ca2afac21b873847d81"
"title": "Which of these do you prefer?",
"subtitle": "Choose one.",
"type": "multiple_choice",
"required": false,
"comments": null,
"properties": {
"multi": false,
"random": true,
"labels": [
"Apples",
"Oranges",
"Peaches",
"Grapes"
]
},
"updated": "2021-05-05T20:44:04.528Z",
"created": "2018-11-13T19:46:22.564Z",
}
} Delete a question
Delete a survey question.
/v1/question/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The unique id of the question to delete. |
Examples
curl https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f
--request DELETE
--header "Content-Type: application/json"
--header "Authorization: Bearer <ACCESS_TOKEN>"// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f`, {
method: "DELETE"
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <ACCESS_TOKEN>",
}
})
.then( response => response.json() )
.then( res => console.log(res.data) )
.catch( err => console.error(err) );# This code sample uses the 'requests' library: pip show requests
import requests
response = requests.delete(
'https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
)
print(response.text)Success response example
Success response example - Response
{
"status": 200,
"type": "ok",
"message": "Request worked as expected."
"data": {
"meta": {
"tags": []
},
"_id": "62b9db151489dd913aeaa22f",
"user": "62bb2ca2afac21b873847d81"
"title": "Which of these do you prefer?",
"subtitle": "Choose one.",
"type": "multiple_choice",
"required": false,
"comments": null,
"properties": {
"multi": false,
"random": true,
"labels": [
"Apples",
"Oranges",
"Peaches",
"Grapes"
]
},
"updated": "2021-05-05T20:44:04.528Z",
"created": "2018-11-13T19:46:22.564Z",
}
} Get a question
Retrieves a single question by id.
/v1/question/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The unique id of the question to retrieve. |
Query Parameters
| Name | Type | Description |
|---|---|---|
| populate | String | optional Mongoose populate path(s) to expand on the question document. |
Examples
curl https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f
--header "Authorization: Bearer <ACCESS_TOKEN>"// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f`, {
headers: { Authorization: 'Bearer <ACCESS_TOKEN>' },
})
.then((response) => response.json())
.then((res) => console.log(res.data))
.catch((err) => console.error(err));# This code sample uses the 'requests' library: pip show requests
import requests
response = requests.get(
"https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f",
headers={"Authorization": "Bearer <ACCESS_TOKEN>"}
)
print(response.text)Success response example
Success response example - Response
{
"status": 200,
"type": "ok",
"message": "Request worked as expected."
"data": {
"meta": {
"tags": []
},
"_id": "62b9db151489dd913aeaa22f",
"user": "62bb2ca2afac21b873847d81"
"title": "Which of these do you prefer?",
"subtitle": "Choose one.",
"type": "multiple_choice",
"required": false,
"comments": null,
"properties": {
"multi": false,
"random": true,
"labels": [
"Apples",
"Oranges",
"Peaches",
"Grapes"
]
},
"updated": "2021-05-05T20:44:04.528Z",
"created": "2018-11-13T19:46:22.564Z",
}
} List all questions
Retrieves all the questions for a survey. Note: standard list arguments are not supported for this endpoint since all questions for a survey are returned and are sorted by index rather than the date the question was created.
/v1/questionsQuery Parameters
| Name | Type | Description |
|---|---|---|
| survey | String | The unique survey id to get the questions for. |
Examples
curl https://api.surveyplanet.com/v1/questions?survey=62e95f48c789f1ef695c0285
--header "Authorization: Bearer <ACCESS_TOKEN>"// For Node.js considering using the 'node-fetch' library: npm info node-fetch
const urlSearchParams = new URLSearchParams({ survey: '62e95f48c789f1ef695c0285' });
fetch(`https://api.surveyplanet.com/v1/questions?urlSearchParams`, {
headers: { Authorization: 'Bearer <ACCESS_TOKEN>' },
})
.then((response) => response.json())
.then((res) => console.log(res.data))
.catch((err) => console.error(err));# This code sample uses the 'requests' library: pip show requests
import requests
response = requests.get(
"https://api.surveyplanet.com/v1/questions",
headers={"Authorization": "Bearer <ACCESS_TOKEN>"}
params={"survey":"62e95f48c789f1ef695c0285"}
)
print(response.text)Success response example
Success response example - Response
{
"status": 200,
"data": [
{ "_id": "62b9e7467854aef07faa746a",...},
{ "_id": "55d8aa7f2c5105f22fea7cbf",...},
[...],
],
"more": true,
"type": "ok",
"message": "Request worked as expected."
} Update a question
Updates a survey question.
/v1/question/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The unique id of the question to update. |
Examples
curl https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f
--request POST
--header "Content-Type: application/json"
--header "Authorization: Bearer <ACCESS_TOKEN>"
--data '{"subtitle":"Choose as many as you like.", "properties.multi": true}'// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f`, {
method: "POST"
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <ACCESS_TOKEN>",
}
body: JSON.stringify({
"subtitle":"Choose as many as you like.",
"properties.multi": true
})
})
.then( response => response.json() )
.then( res => console.log(res.data) )
.catch( err => console.error(err) );# This code sample uses the 'requests' library: pip show requests
import requests
response = requests.post(
'https://api.surveyplanet.com/v1/question/62b9db151489dd913aeaa22f',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
data = {
"subtitle":"Choose as many as you like.",
"properties.multi": true
}
)
print(response.text)Success response example
Success response example - Response
{
"status": 200,
"type": "ok",
"message": "Request worked as expected."
"data": {
"meta": {
"tags": []
},
"_id": "62b9db151489dd913aeaa22f",
"user": "62bb2ca2afac21b873847d81"
"title": "Which of these do you prefer?",
"subtitle": "Choose one.",
"type": "multiple_choice",
"required": false,
"comments": null,
"properties": {
"multi": false,
"random": true,
"labels": [
"Apples",
"Oranges",
"Peaches",
"Grapes"
]
},
"updated": "2021-05-05T20:44:04.528Z",
"created": "2018-11-13T19:46:22.564Z",
}
}