Answers API
API Description
In order to use the API you must have the valid environment-specific username and password. Before any API requests, you need to obtain an API KEY. You will get a valid API KEY by using the VoC authentication API
The API KEY must be sent in the request authorization header element. If the API KEY value is valid then API request will be successful (http status code 200), otherwise it will fail (http status code 401). All API requests must be made over HTTPS.
API Endpoints
| Environment | Endpoint |
|---|---|
| Production | https://api.confidently.fi/api/responses/prod/v2/{surveyId}/answers |
| Test | https://api.confidently.fi/api/responses/test/v2/{surveyId}/answers |
Note: Test environment can print max 10 answerGroup
API request header
| Header | Value |
|---|---|
| Authorization | x-api-key APIKEY |
API request parameters
| Parameter | Description | Mandatory |
|---|---|---|
| surveyId | The unique id of the survey | X |
| startDate | Answers from date | X |
| endDate | Answers until date (default max 7 days difference) | |
| details | Show additionals (answerValues) |
API response
| Element | Description | Type |
|---|---|---|
| surveyId | The survey unique id | long |
| surveyName | Name of the survey | string |
| answers | All answers under the survey | array |
| answerGroupID | The answer group unique id | long |
| responses | array | |
| questionId | The question unique id | long |
| answerId | The answer unique id | long |
| answerDate | When the answer is given. Example: 2017-12-03T00:00:00.00Z | date time |
| answer | The answer of the question | string |
| freeTextAnswer | The text answer of the question | string |
| userId | Unique id | long |
| responder | The responder of the answer | string |
| answerValues | All additionals as specified by answerGroupId | array |
| answerGroupID | This id connects to the answer group unique id | long |
| values | All values under the answerGroupId | array |
| userId | Unique id | long |
| description | Description of the value e.g. agent or organization | string |
| value | Value | string |
| timestamp | When answer value is created. Example: 2017-12-03T00:00:00.00Z | date time |
API request and response example
curl -X GET "https://api.confidently.fi/api/responses/test/v2/survey/3974/answers?startDate=2019-09-09&endDate=2019-09-12&details=true" -H "Authorization: x-api-key {APIKEY}"Successful API request returns results in JSON format.
{
"surveyId": 3974,
"surveyName": "VoC SMS Survey Demo",
"answers": [
{
"answerGroupId": 3559834502,
"responses": [
{
"questionId": 11445,
"answerId": 3559834502,
"answerDate": "2019-09-10T09:18:46.794Z",
"answer": "9",
"userId": xxxx,
"responder": "xxxx"
}
]
}
],
"answerValues": [
{
"answerGroupId": 3559834502,
"values": [
{
"userId": xxxx,
"description": "Country",
"value": "Sweden",
"timestamp": "2019-09-10T09:18:46.794Z"
}
]
}
]
}