Survey
Endpoint for exporting survey data (censuses and surveys).
📥 Postman Collection
URLs
| Method | URL | Action | Description |
|---|---|---|---|
| GET | /api/survey | List | Lists all available surveys |
| GET | /api/survey/{id}/structure | View | Exports the structure (questions) of a survey |
| GET | /api/survey/{id}/answers | View | Exports the answers of a survey |
Production:
{connect-producao}/api/surveyStaging:
{connect-homologacao}/api/surveyAuthentication
All requests require an access token obtained from the Security endpoint. The token must be sent in the AccessToken header.
List Surveys
Request
Endpoint: GET {connect-producao}/api/survey
Headers:
AccessToken: {access_token}Success Response
Status: 200 OK
json
{
"header": {
"codigo": 1,
"msg": "ok."
},
"data": [
{
"surveyId": "123",
"surveyNome": "Satisfaction Survey"
}
]
}Export Structure
Request
Endpoint: GET {connect-producao}/api/survey/{id}/structure
Headers:
AccessToken: {access_token}Parameters:
id(path): Survey ID
Success Response
Status: 200 OK
json
{
"header": {
"codigo": 1,
"msg": "ok."
},
"data": [
{
"chapterId": 1,
"chapterNome": "Chapter 1",
"reg": [
{
"regId": "1",
"regNome": "Question 1"
}
]
}
]
}Export Answers
Request
Endpoint: GET {connect-producao}/api/survey/{id}/answers
Headers:
AccessToken: {access_token}Parameters:
id(path): Survey IDpage(query): Page number (default: 1)pageSize(query): Page size (default: 500)
Success Response
Status: 200 OK
json
{
"header": {
"codigo": 1,
"msg": "ok."
},
"data": {
"page": 1,
"pageSize": 500,
"totalPages": 10,
"answers": [
{
"answerDate": "2025-01-01T00:00:00Z",
"userId": 123456,
"respostas": {}
}
]
}
}Implementation Example
javascript
async function listSurveys(accessToken) {
const response = await fetch('{connect-producao}/api/survey', {
method: 'GET',
headers: {
'AccessToken': accessToken
}
});
if (!response.ok) {
throw new Error(`Error ${response.status}: ${response.statusText}`);
}
return await response.json();
}
async function exportStructure(surveyId, accessToken) {
const response = await fetch(`{connect-producao}/api/survey/${surveyId}/structure`, {
method: 'GET',
headers: {
'AccessToken': accessToken
}
});
if (!response.ok) {
throw new Error(`Error ${response.status}: ${response.statusText}`);
}
return await response.json();
}
async function exportAnswers(surveyId, page, pageSize, accessToken) {
const response = await fetch(`{connect-producao}/api/survey/${surveyId}/answers?page=${page}&pageSize=${pageSize}`, {
method: 'GET',
headers: {
'AccessToken': accessToken
}
});
if (!response.ok) {
throw new Error(`Error ${response.status}: ${response.statusText}`);
}
return await response.json();
}