Skip to main content

Surveys

Overview​

A survey is a way of gathering information from users through workflows, channels, bots, or even public surveys outside the Cotalker environment.

The /surveys API request works with survey data models (COTSurvey), which consolidate other data models: COTSurveyChat, COTQuestion, COTAnswer.

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 Surveys​

Returns all surveys within the company.

GET /surveys

Endpoint URL​

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

Headers​

HeaderDescriptionRequiredValues
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 surveys 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 surveys within the company.booleanOptional
answerReturns the ObjectId of the survey associated with the indicated answer.string[ ]OptionalAnswers are identified by the ObjectId in their uuid field.
selectSurveys are returned showing only the indicated fields.string[ ]OptionalFor example, GET /surveys?select=code, returns surveys displaying only the code field.
isActiveReturns surveys according to their isActive status.stringOptionalOptions are: all, true, false
searchReturns surveys with field values that begin with the search query.stringOptional
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Samples​

This default request gets all the surveys in the company.

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

Response Sample​

Responses follow the COTSurvey data model.


Get a Survey by Id​

Returns the survey indicated by the Id.

GET /surveys/{id}

Endpoint URL​

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

Path Parameters​

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the survey that is to be returned.ObjectId<COTSurvey>Required

Headers​

HeaderDescriptionRequiredValues
AdminGrants access to request the endpoint.Requiredtrue
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
populateReturns the survey with the chat field which contains all the survey's survey chats, i.e., all of the the survey's components.booleanOptional

Request Sample​

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

Response Sample​

The response follows the COTSurvey data model.


Create a New Survey​

Creates a new survey within the company.

POST /surveys

Endpoint URL​

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

Headers​

HeaderDescriptionRequiredValues
AdminGrants administrative access to create a new survey.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 COTSurvey data model. Unrequired fields that are not submitted are either filled in automatically or left blank.

ElementDescriptionTypeRequiredNotes
codeThe survey's unique identification namestringRequiredMaximum 60 characters; only lowercase letters, numbers, and underscore allowed; must be unique.
nameThe survey's displayed name in the administrative panelstringRequired
versionIndicates the survey version and determines what fields should be used; 1 uses fields prior to January 2019; 2 uses fields created after January 2019numberRequiredFields prior to January 2019: permissions, group, groupPermissions. Fields created after January 2019: permissionsV2, groupPermissionsV2, onlySubSurvey.

Request Sample​

Survey created with the minimum required fields:

curl --location --request POST 'https://www.cotalker.com/api/v2/surveys' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Work Order",
"code": "work_order_survey",
"version": 1
}'

Response Sample​

Go to COTSurvey for a complete description of the response.

{
"permissions": [],
"permissionsV2": [],
"groupPermissionsV2": [],
"onlySubSurvey": false,
"propertiesChannel": [],
"propertiesLimit": [],
"isActive": true,
"isSystemModel": false,
"version": 1,
"_id": "61a50f928843af3e1332c67f",
"name": "Work Order",
"code": "work_order_survey",
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-11-29T16:58:27.044Z",
"responders": [],
"modifiedAt": "2021-11-29T16:58:27.045Z",
"__v": 0
}

Update a Survey​

Updates or edits an existing survey.

PATCH /surveys/{id}

Endpoint URL​

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

Path Parameters​

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the survey that is to be modified.ObjectId<COTSurvey>Required

Headers​

HeaderDescriptionRequiredValues
AdminGrants administrative access to modify a survey.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 COTSurvey data model.

Request Sample​

This sample adds an access role objectId to the permissions field:

curl --location --request PATCH 'https://www.cotalker.com/api/v2/surveys/61a50f928843af3e1332c67f' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"permissions": "61a51e04e98c389d90eea21d"
}'

Response Sample​

Go to COTSurvey for a complete description of the response.

{
"permissions": [
"61a51e04e98c389d90eea21d"
],
"permissionsV2": [],
"groupPermissionsV2": [],
"onlySubSurvey": false,
"propertiesChannel": [],
"propertiesLimit": [],
"isActive": true,
"isSystemModel": false,
"version": 1,
"_id": "61a50f928843af3e1332c67f",
"name": "Work Order",
"code": "work_order_survey",
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-11-29T16:58:27.044Z",
"responders": [],
"modifiedAt": "2021-11-29T18:38:15.394Z",
"__v": 2
}