Questions

Create a question

Back to top

Creates a new survey question and apply it to a survey.

POST
/v1/question

Request Body

NameTypeDescription
surveyString

The unique survey id to apply the question to.

typeString

The question type. Options: multiple_choice, scale, range, date_time, scoring, form, essay, rating, or image.

titleString

The question title.

subtitleStringoptional

The question subtitle.

requiredBooleanoptional

Whether the question is required or not.

propertiesObjectoptional

Special properties specific to each question type.

commentsStringoptional

Label for comments field, if null no comments will be added to the question.

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

Back to top

Delete a survey question.

DELETE
/v1/question/:id

Parameters - Parameter

NameTypeDescription
idString

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

Back to top

Retrieves a single question by id.

GET
/v1/question/:id

Parameters - Parameter

NameTypeDescription
idString

The unique id of the question to retrieve.

Query Parameters

NameTypeDescription
populateStringoptional

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

Back to top

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.

GET
/v1/questions

Query Parameters

NameTypeDescription
surveyString

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

Back to top

Updates a survey question.

PUT
/v1/question/:id

Parameters - Parameter

NameTypeDescription
idString

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",
  }
}