Skip to main content

Questions

Overview

Questions make up the parts of survey or form components. They are contained within surveys through survey chats.

additional resources

These are just some of the most basic API requests. For a complete list of endpoints, consult our API documentation on Swagger.

Get Questions

Returns all questions within the company.

GET /questions

Endpoint URL

https://www.cotalker.com/api/v2/questions

Headers

HeaderDescriptionRequiredValues
AdminAuthorizes the use of some options.Depends on the query parameters.true
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Query Parameters

ParameterDescriptionTypeRequiredNotes
limitLimits the amount of questions returned in the response.numberOptionalBy default, the limit is set to 10.
pageMakes the response display data from the indicated page number.numberOptionalBest used in combination with the "limit" parameter.
countAdds the counter field with the total amount of questions within the company.booleanOptional
ids
OR
_id
Returns questions with the IDs indicated in the array.ObjectId<COTQuestion>[ ]Optional
modifiedReturns questions with the indicated modification date in the modifiedAt field.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_gtReturns questions modified after the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_gteReturns questions with a value in the modifiedAt field equal to or greater than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_ltReturns questions modified before the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_lteReturns questions with a value in the modifiedAt field equal to or less than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
createdReturns questions with the indicated creation date in the createdAt field.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_gtReturns questions created after the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_gteReturns questions with a value in the createdAt field equal to or greater than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_ltReturns questions created before the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_lteReturns questions with a value in the createdAt field equal to or less than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
isActiveReturns questions according to their isActive status.stringOptionalOptions are: all, true, false
Requires the "Admin" header.
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Samples

This default request gets all the questions in the company.

curl --location --request GET 'https://www.cotalker.com/api/v2/questions' \
--header 'Authorization: Bearer $ACCESS_TOKEN'

Response Sample

Responses follow the COTQuestion data model.


Get a Question by Id

Returns the question indicated by the Id.

GET /questions/{id}

Endpoint URL

https://www.cotalker.com/api/v2/questions/{id}

Path Parameters

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the question that is to be returned.ObjectId<COTQuestion>Required

Headers

HeaderDescriptionRequiredValues
AdminAuthorizes the use of some options.Depends on the query parameters.true
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true
isActiveReturns the question if it coincides with the selected isActive status.stringOptionalOptions are: all, true, false.
Requires the "Admin" header to funcion properly.

Request Sample

curl --location --request GET 'https://www.cotalker.com/api/v2/questions/61a635c023ddfab3c0184c42' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN'

Response Sample

The response follows the COTQuestion data model.


Create a New Question

Creates a new question.

POST /questions

Endpoint URL

https://www.cotalker.com/api/v2/questions

Headers

HeaderDescriptionRequiredValues
AdminGrants administrative access to create a new survey chat.Requiredtrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
Content-TypeIndicates the body's format.Requiredapplication/json

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Body

Only required fields are listed below. For a complete schema description, please go to the COTQuestion data model. Unrequired fields that are not submitted are either filled in automatically or left blank.

ElementDescriptionTypeRequiredNotes
contentTypeIndicates COTQuestionContentType, i.e. survey component typestringRequiredList of question content types
displayDisplayed question title or field labelstring[ ]RequiredIts contents depend on the contentType and whether the data model corresponds to the title section of the question.

Request Sample

Survey chat created with the minimum required fields:

curl --location --request POST 'https://www.cotalker.com/api/v2/questions' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"display": [
"Input 4"
],
"contentType": "application/vnd.cotalker.survey+text"
}'

Response Sample

Go to COTQuestion for a complete description of the response.

{
"command": {
"commands": [],
"resetIdentifiers": [],
"values": []
},
"display": [
"Input 4"
],
"code": [],
"isActive": true,
"isSystemModel": false,
"_id": "61a65dfd61adbedb7d7511c3",
"contentType": "application/vnd.cotalker.survey+text",
"company": "6136968b580aaf2b0e49d844",
"identifier": "1638291417215hoo28",
"modifiedAt": "2021-11-30T16:56:57.219Z",
"textAlign": "left",
"__v": 0
}

Update a Question

Updates or edits an existing question.

PATCH /questions/{id}

Endpoint URL

https://www.cotalker.com/api/v2/questions/{id}

Path Parameters

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the question that is to be modified.ObjectId<COTQuestion>Required

Headers

HeaderDescriptionRequiredValues
AdminGrants administrative access to modify a question.Requiredtrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
Content-TypeSets the body's format.Requiredapplication/json

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Body

Only the fields that are being updated or added are required to be put into the body. For a complete schema description, please go to the COTQuestion data model.

Request Sample

This sample sets up conditional display questions inserting a command object:

curl --location --request PATCH 'https://www.cotalker.com/api/v2/questions/61a66fdc9e7c38b758a0b93d?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"command": {
"commands": [],
"resetIdentifiers": [],
"isCommanded": "item_list",
"values": [
{
"_id": "615af821b0ca3100073e4f1a",
"op": "eq",
"target": "op_1"
}
]
}
}'

Response Sample

Go to COTQuestion for a complete description of the response.

{
"command": {
"commands": [],
"resetIdentifiers": [],
"values": [
{
"_id": "615af821b0ca3100073e4f1a",
"op": "eq",
"target": "op_1"
}
],
"isCommanded": "item_list"
},
"display": [
"Input 1"
],
"code": [],
"isActive": true,
"isSystemModel": false,
"_id": "61a66fdc9e7c38b758a0b93d",
"contentType": "application/vnd.cotalker.survey+text",
"company": "6136968b580aaf2b0e49d844",
"identifier": "1638287705330orcsk",
"modifiedAt": "2021-11-30T18:21:24.335Z",
"textAlign": "left",
"__v": 0,
"isReadOnly": false
}

QR Code & NFC function

Gather information for your surveys through QR code scan and NFC by adding the corresponding values in the question's code field.

note
  • Only functional on mobile devices.
  • Configurable only through API requests.
POST /questions

Endpoint URL

https://www.cotalker.com/api/v2/questions

Headers

HeaderDescriptionRequiredValues
AdminGrants administrative access to create a new question.Requiredtrue
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
Content-TypeIndicates the body's format.Requiredapplication/json

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Body

FieldDescriptionTypeRequiredNotes
codeCode depends on the content type. Below is the code for scanning QR & NFC in surveys.string[ ]RequiredObjects within the array must be written in string format.
code[index].scanobjectRequired
code[index].scan.enabledtrue activates the feature.booleanRequired
code[index].scan.sourceIndicates the input source.string[ ]RequiredValid options: qr and/or nfc.
code[index].scan.forcetrue allows only QR Code or NFC input. false permits manual text input, also.booleanRequired
contentTypeIndicates how the system should interpret the data.stringRequiredMust be set to: application/vnd.cotalker.survey+textinput
identifierUnique identification namestringRequiredMaximum 60 characters; only lowercase letters, numbers, and underscore allowed; must be unique.

Request Sample

curl --location --request POST 'https://www.cotalker.com/api/v2/questions?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"code": [
"{\"scan\":{\"enabled\":true,\"source\":[\"qr\",\"nfc\"],\"force\":true}}"
],
"display": [
"input 3"
],
"identifier": "qr_nfc_input",
"contentType": "application/vnd.cotalker.survey+textinput"
}'

Response Sample

Go to COTQuestion for a complete description of the response.

{
"_id": "61a78c177f130200079de9d3",
"command": {
"commands": [],
"resetIdentifiers": [],
"values": []
},
"display": [
"input 3"
],
"code": [
"{\"scan\":{\"enabled\":true,\"source\":[\"qr\",\"nfc\"],\"force\":true}}"
],
"isActive": true,
"isSystemModel": false,
"identifier": "qr_test",
"contentType": "application/vnd.cotalker.survey+textinput",
"company": "6136968b580aaf2b0e49d844",
"modifiedAt": "2021-12-01T14:52:07.636Z",
"__v": 0
}