Question Branch
Create a branch
Creates a single question branch.
/v1/branchRequest Body
| Name | Type | Description |
|---|---|---|
| question | String | Unique id of the question the branch is triggered from. |
| description | String | optional Branch description. |
| quantifier | String | Flags whether |
| conditions | Object[] | A list of conditions to be met in order for the results to be triggered. |
| conditions.response | String | property to match. Default value: response |
| conditions.operator | String | Comparison operator. Must be one of: |
| conditions.value | String | The value to be met for the condition to be satisfied. |
| results | Object[] | A collection of action to take if the conditions are met. |
| results._id | Sting | Unique id of result. |
| results.property | Sting | Question property applied to the value. Must be one of: |
| results.value | Sting | Value used by the action (e.g.: question number, title, tag, etc). Default value: number |
| results.action | Sting | Resulting action of the branch. Must be either |
Examples
curl https://api.surveyplanet.com/v1/branch
--request POST
--header "Content-Type: application/json"
--header "Authorization: Bearer <ACCESS_TOKEN>"
--data '{"question":"62b9db151489dd913aeaa22f", <...>'}// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/branch`, {
body: JSON.stringify({"question":"62b9db151489dd913aeaa22f", <...>)}
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.post(
'https://api.surveyplanet.com/v1/branch',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
data = {"question":"62b9db151489dd913aeaa22f", <...>}
)
print(response.text)Success response example
Success response example - Successful response
{
"status": 200,
"data": {
"_id": "62b9e7467854aef07faa746a",
"user": "54570f80968d6e492b0d9736",
"question": "62b9db151489dd913aeaa22f",
"created": "2022-06-27T17:22:14.241Z",
"updated": "2022-06-27T17:22:14.241Z",
"description": "If Apples is selected then end survey with custom success message An apple a day keeps the doctor away",
"quantifier": "any",
"conditions": [
{
"response": "Apples",
"operator": "is",
"value": "true"
}
],
"results": [
{
"action": "end",
"property": "custom",
"value": "An apple a day keeps the doctor away"
}
]
},
"type": "ok",
"message": "Request worked as expected."
} Delete a branch
Removes a single question branch.
/v1/branch/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | Unique id of the branch to delete. |
Examples
curl https://api.surveyplanet.com/v1/branch/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/branch/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/branch/62b9db151489dd913aeaa22f',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
)
print(response.text)Success response example
Success response example - Successful response
{
"status": 200,
"data": {
"_id": "62b9e7467854aef07faa746a",
"user": "54570f80968d6e492b0d9736",
"question": "62b9db151489dd913aeaa22f",
"created": "2022-06-27T17:22:14.241Z",
"updated": "2022-06-27T17:22:14.241Z",
"description": "If Apples is selected then end survey with custom success message An apple a day keeps the doctor away",
"quantifier": "any",
"conditions": [
{
"response": "Apples",
"operator": "is",
"value": "true"
}
],
"results": [
{
"action": "end",
"property": "custom",
"value": "An apple a day keeps the doctor away"
}
]
},
"type": "ok",
"message": "Request worked as expected."
} List all branches
Retrieves all the branches for a survey question.
/v1/branchesQuery Parameters
| Name | Type | Description |
|---|---|---|
| question | String | Unique id of the question the branch is triggered from. |
| reverse | Boolean | optional Sort list in reverse chronological order |
| after | String | optional The unique id which defines a cursor for paginating. When defined only retrieve list after this id. |
| before | String | optional The unique id which defines a cursor for paginating. When defined only retrieve list before this id. |
| select | String | optional A URL encoded string of properties to include. If not specified all fields are returned. Use a |
Examples
curl https://api.surveyplanet.com/v1/branches?question=62b9db151489dd913aeaa22f
--header "Authorization: Bearer <ACCESS_TOKEN>"// For Node.js considering using the 'node-fetch' library: npm info node-fetch
const urlSearchParams = new URLSearchParams({ question: '62b9db151489dd913aeaa22f' });
fetch(`https://api.surveyplanet.com/v1/branches?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/branches",
headers={"Authorization": "Bearer <ACCESS_TOKEN>"}
params={"question":"62b9db151489dd913aeaa22f"}
)
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."
} Retrieve a branch
Retrieves a single branch by id.
/v1/branch/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The unique id of the branch to retrieve. |
Examples
curl https://api.surveyplanet.com/v1/branch/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/branch/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/branch/62b9db151489dd913aeaa22f",
headers={"Authorization": "Bearer <ACCESS_TOKEN>"}
)
print(response.text)Success response example
Success response example - Successful response
{
"status": 200,
"data": {
"_id": "62b9e7467854aef07faa746a",
"user": "54570f80968d6e492b0d9736",
"question": "62b9db151489dd913aeaa22f",
"created": "2022-06-27T17:22:14.241Z",
"updated": "2022-06-27T17:22:14.241Z",
"description": "If Apples is selected then end survey with custom success message An apple a day keeps the doctor away",
"quantifier": "any",
"conditions": [
{
"response": "Apples",
"operator": "is",
"value": "true"
}
],
"results": [
{
"action": "end",
"property": "custom",
"value": "An apple a day keeps the doctor away"
}
]
},
"type": "ok",
"message": "Request worked as expected."
} Update a branch
Updates a single question branch.
/v1/branch/:idParameters - Parameter
| Name | Type | Description |
|---|---|---|
| id | String | The unique id of the branch to update. |
Request Body
| Name | Type | Description |
|---|---|---|
| question | String | Unique id of the question the branch is triggered from. |
| description | String | optional Branch description. |
| quantifier | String | Flags whether |
| conditions | Object[] | A list of conditions to be met in order for the results to be triggered. |
| conditions.response | String | property to match. Default value: response |
| conditions.operator | String | Comparison operator. Must be one of: |
| conditions.value | String | The value to be met for the condition to be satisfied. |
| results | Object[] | A collection of action to take if the conditions are met. |
| results._id | Sting | Unique id of result. |
| results.property | Sting | Question property applied to the value. Must be one of: |
| results.value | Sting | Value used by the action (e.g.: question number, title, tag, etc). Default value: number |
| results.action | Sting | Resulting action of the branch. Must be either |
Examples
curl https://api.surveyplanet.com/v1/branch/62b9db151489dd913aeaa22f
--request PUT
--header "Content-Type: application/json"
--header "Authorization: Bearer <ACCESS_TOKEN>"
--data '{"description":"This branch will take you where you need to go."'}// For Node.js considering using the 'node-fetch' library: npm info node-fetch
fetch(`https://api.surveyplanet.com/v1/branch/62b9db151489dd913aeaa22f`, {
method: "PUT"
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <ACCESS_TOKEN>",
}
body: JSON.stringify({"description":"This branch will take you where you need to go.")}
})
.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.put(
'https://api.surveyplanet.com/v1/branch/62b9db151489dd913aeaa22f',
headers = {
"Content-Type": "application/json"
"Authorization": "Bearer <ACCESS_TOKEN>"
}
data = {"description":"This branch will take you where you need to go."}
)
print(response.text)Success response example
Success response example - Successful response
{
"status": 200,
"data": {
"_id": "62b9e7467854aef07faa746a",
"user": "54570f80968d6e492b0d9736",
"question": "62b9db151489dd913aeaa22f",
"created": "2022-06-27T17:22:14.241Z",
"updated": "2022-06-27T17:22:14.241Z",
"description": "If Apples is selected then end survey with custom success message An apple a day keeps the doctor away",
"quantifier": "any",
"conditions": [
{
"response": "Apples",
"operator": "is",
"value": "true"
}
],
"results": [
{
"action": "end",
"property": "custom",
"value": "An apple a day keeps the doctor away"
}
]
},
"type": "ok",
"message": "Request worked as expected."
}