Question Branch

Create a branch

Back to top

Creates a single question branch.

POST
/v1/branch

Request Body

NameTypeDescription
questionString

Unique id of the question the branch is triggered from.

descriptionStringoptional

Branch description.

quantifierString

Flags whether any or all of the conditions should be met.

Default value: any
conditionsObject[]

A list of conditions to be met in order for the results to be triggered.

conditions.responseString

property to match.

Default value: response
conditions.operatorString

Comparison operator. Must be one of: is, is not, begins with, does not begin with, ends with, does not end with, contains, does not contain, is greater than, is greater than or equal to, is less than, is less than or equal to, is equal to, is blank, or is not blank.

Default value: is
conditions.valueString

The value to be met for the condition to be satisfied.

resultsObject[]

A collection of action to take if the conditions are met.

results._idSting

Unique id of result.

results.propertySting

Question property applied to the value. Must be one of: number, or title, or subtitle, or tag, or type, or required, or default, or custom

results.valueSting

Value used by the action (e.g.: question number, title, tag, etc).

Default value: number
results.actionSting

Resulting action of the branch. Must be either skip, go, or end.

Default value: skip

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

Back to top

Removes a single question branch.

DELETE
/v1/branch/:id

Parameters - Parameter

NameTypeDescription
idString

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

Back to top

Retrieves all the branches for a survey question.

GET
/v1/branches

Query Parameters

NameTypeDescription
questionString

Unique id of the question the branch is triggered from.

reverseBooleanoptional

Sort list in reverse chronological order

afterStringoptional

The unique id which defines a cursor for paginating. When defined only retrieve list after this id.

beforeStringoptional

The unique id which defines a cursor for paginating. When defined only retrieve list before this id.

selectStringoptional

A URL encoded string of properties to include. If not specified all fields are returned. Use a - to exclude a specific field e.g:-title.

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

Back to top

Retrieves a single branch by id.

GET
/v1/branch/:id

Parameters - Parameter

NameTypeDescription
idString

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

Back to top

Updates a single question branch.

PUT
/v1/branch/:id

Parameters - Parameter

NameTypeDescription
idString

The unique id of the branch to update.

Request Body

NameTypeDescription
questionString

Unique id of the question the branch is triggered from.

descriptionStringoptional

Branch description.

quantifierString

Flags whether any or all of the conditions should be met.

Default value: any
conditionsObject[]

A list of conditions to be met in order for the results to be triggered.

conditions.responseString

property to match.

Default value: response
conditions.operatorString

Comparison operator. Must be one of: is, is not, begins with, does not begin with, ends with, does not end with, contains, does not contain, is greater than, is greater than or equal to, is less than, is less than or equal to, is equal to, is blank, or is not blank.

Default value: is
conditions.valueString

The value to be met for the condition to be satisfied.

resultsObject[]

A collection of action to take if the conditions are met.

results._idSting

Unique id of result.

results.propertySting

Question property applied to the value. Must be one of: number, or title, or subtitle, or tag, or type, or required, or default, or custom

results.valueSting

Value used by the action (e.g.: question number, title, tag, etc).

Default value: number
results.actionSting

Resulting action of the branch. Must be either skip, go, or end.

Default value: skip

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