A respondent is used to link a contact with a survey in the user account.

A single contact can be assigned to multiple surveys on the account.


Name

URL

Description

List of respondents

/respondents/:id_survey

Returns a list of respondents from the survey specified by the :id_survey parameter. Respondents are sorted alphabetically by email address.

Searching for respondents

/respondents/search/:id_survey

Searches for respondents by criteria

Adding a respondent to a survey

/respondents/add

Assigns a contact to a survey

Updating a respondent

/respondents/:surveyId/update

Updating respondents' data

Anonymizing a respondent

/respondents/:params/anonymize

Anonymization of respondent's data

Deleting a respondent

/respondents/delete

Removes a contact from a survey

Batch upload of respondents

/respondents/batch

Sending respondents in grouped batches, for which a single mailing can be created at the end



List of operations for the resource

Description of response parameters

Name/path

Description

Possible values

id

Respondent ID

token

A unique alphanumeric token up to 64 characters long that uniquely identifies the respondent and allows for a single completion of the survey, usable only when access is set with an individual link.

offline_distribution

Information on whether the invitation to complete the survey is sent by webankieta.pl or by the survey author. Passing the user_token in the link to complete the survey is also treated as distribution by the author.

0 – Link to the survey sent from webankieta.pl
1 – Link to the survey sent by the author (offline distribution of tokens)

date_generate

Date the respondent was added to the survey

date_invitaion_send

Date and time the invitation was sent

null – Invitation was not sent to the respondent
0000-00-00 00:00:00 – Invitation is waiting to be sent
2012-12-06 12:00:00 – Date and time the invitation was sent

date_survey_open

Date and time the survey was first opened. Parameter active only when access is set with an individual link for the respondent.

null – Survey was not opened by the respondent
2012-12-06 12:00:00 – Date and time the survey was opened

date_survey_answer

Date and time the survey was completed. Parameter active only when access is set with an individual link for the respondent.

null – Survey was not completed by the respondent
2012-12-06 12:00:00 – Date and time the survey was completed

answer_postponed

Whether the respondent's answer was postponed during completion. Parameter active only when access is set with an individual link for the respondent.

null – Survey not completed
0 – Completion not postponed
1 – Completion postponed

email

Respondent's e-mail address

label1

Value of the first optional attribute. Attribute active if the respondent is added from user contacts.

label2

Value of the second optional attribute. Attribute active if the respondent is added from user contacts.

label3

Value of the third optional attribute. Attribute active if the respondent is added from user contacts.

label4

Value of the fourth optional attribute. Attribute active if the respondent is added from user contacts.

label5

Value of the fifth optional attribute. Attribute active if the respondent is added from user contacts.

label6

Value of the sixth optional attribute. Attribute active if the respondent is added from user contacts.

label7

Value of the seventh optional attribute. Attribute active if the respondent is added from user contacts.

label8

Value of the eighth optional attribute. Attribute active if the respondent is added from user contacts.

label9

Value of the ninth optional attribute. Attribute active if the respondent is added from user contacts.

label10

Value of the tenth optional attribute. Attribute active if the respondent is added from user contacts.

label11

Value of the eleventh optional attribute. Attribute active if the respondent is added from user contacts.

label12

Value of the twelfth optional attribute. Attribute active if the respondent is added from user contacts.

label13

Value of the thirteenth optional attribute. Attribute active if the respondent is added from user contacts.

label14

Value of the fourteenth optional attribute. Attribute active if the respondent is added from user contacts.

label15

Value of the fifteenth optional attribute. Attribute active if the respondent is added from user contacts.

survey_link

Unique link to the survey intended for a given respondent. Parameter active only when access is set with an individual link for the respondent.


List of respondents

URL

(GET) https://app.customerhero.com/api/v2/respondents/:id_survey

Optional parameters (POST)

Name

Description

limit

Limit on the number of completions, default value is 500

offset

List offset


Example response

{
	"total":"20",
	"list":[{
		"id":100824,
		"token":"549E56",
		"date_token_generate":"2011-11-25 22:27:42",
		"date_invitaion_send":null,
		"date_survey_open":null,
		"date_survey_answer":null,
		"email":"jan@kowalski.pl",
		"label1":"Jan",
		"label2":"Kowalski",
		"label3":"600 700 800",
		"label4":"",
		"label5":"",
		"answer_postponed":null
	},{
		...
	}]
}

Returned errors

  • 401 Unauthorized – If the user references a foreign resource.

  • 404 Not Found – If a survey with the given :id_survey is not found.

  • 404 Not Found – If no respondents are found.

  • 406 Not Acceptable – If the :id_survey parameter is not passed.


Searching for respondents

URL

(GET) https://app.customerhero.com/api/v2/respondents/search/:id_survey


Optional parameters (POST)

Name

Description

limit

Limit on the number of completions, default value is 500

offset

List offset

token

Searching for a respondent by token

email

Searching for a respondent by email address

date_generate

Searching for a respondent by the date they were added to the survey. The date must be passed in YYYY-MM-DD format (e.g., 2011-11-20). All respondents added on that day will be found.

date_invitaion_send

Searching for a respondent by the date the invitation was sent. The date must be passed in YYYY-MM-DD format (e.g., 2011-11-20). All respondents to whom an invitation was sent on that day will be found.

date_survey_open

Searching for a respondent by the date the survey was first opened. The date must be passed in YYYY-MM-DD format (e.g., 2011-11-20). All respondents who opened the survey on that day will be found.

date_survey_answer

Searching for a respondent by the date the survey was first completed. The date must be passed in YYYY-MM-DD format (e.g., 2011-11-20). All respondents who completed the survey on that day will be found.

label1

Searching for a respondent by the value of attribute 1

labelx

Searching for a respondent by the value of attribute x



Example response

{
	"total":"20",
	"list":[{
		"id":100824,
		"token":"549E56",
		"date_token_generate":"2011-11-25 22:27:42",
		"date_invitaion_send":null,
		"date_survey_open":null,
		"date_survey_answer":null,
		"email":"jan@kowalski.pl",
		"label1":"Jan",
		"label2":"Kowalski",
		"label3":"600 700 800",
		"label4":"",
		"label5":"",
		"answer_postponed":null
	},{
		...
	}]
}

Returned errors

  • 401 Unauthorized – If the user references a foreign resource.

  • 404 Not Found – If a survey with the given :id_survey is not found.

  • 404 Not Found – If no respondents are found.

  • 406 Not Acceptable – If the :id_survey parameter is not passed.


Adding a respondent to a survey

URL

(GET) https://app.customerhero.com/api/v2/respondents/add


Parameters (POST)

Name

Description

id_survey

ID of the survey to which we are assigning the contact

id_contact

ID of the contact being assigned to the survey

date_invitaion_send

Date the invitation was sent to the respondent (sending occurred on the client application side).
Optional parameter



Example response

{ 
"id_respondent":"101019" 
}

Returned errors

  • 401 Unauthorized – If the user references a foreign resource (survey/contact).

  • 404 Not Found – If a survey with the given :id_survey is not found.

  • 404 Not Found – If a contact with the given :id_contact is not found.

  • 406 Not Acceptable – If the :id_survey parameter is not passed.

  • 406 Not Acceptable – If the :id_contact parameter is not passed.

  • 409 Conflict – If the contact was previously added to the survey.


Updating a respondent

  • The endpoint supports only respondents from email sending.

  • Update processing takes place in an offline process, so changes may not be visible immediately.

  • We accept a maximum of 100 respondent records per request.

URL

(POST) https://app.customerhero.com/api/v2/respondents/:surveyId/update

(POST) https://app.customerhero.com/api/v3/respondents/:surveyId/update


Parameters (GET)

Name

Description

surveyId

ID of the survey to which the respondent belongs



Parameters (BODY)

{
    "respondents":[
        {
            "id": 142042042,
            "email": „najnowszy@webankieta.pl",
            "labels": [
                {"id": 1, "value":"archive"},
                {"id": 2, "value":"archive"},
                {"id": 3, "value":"archive"}
            ]
        },
        {
            "id": 142042043,
            "email": „nowy@webankieta.pl",
            "labels": [
                {"id": 3, "value":"null"},
                {"id": 2, "value":"null"},
                {"id": 1, "value":"null"}
            ]
        },
        {
            "id": 142042044,
            "email": „j,kowalski@webankieta.pl",
            "labels": [
                {"id": 15, "value":"test value"},
                {"id": 2, "value":"poland"},
                {"id": 3, "value": null}
            ]
        }
    ]
}

Response codes
202 - the update was accepted for processing.


Anonymizing a respondent

  • The endpoint supports respondents from email sending and own distribution

  • Update processing takes place offline, so changes may not be visible immediately.

  • If you want to anonymize respondents by batchId, you must remember it on your side beforehand to use it in the request.

URLs

Anonymization of all respondents in the survey

(POST) https://app.customerhero.com/api/v2/respondents/:surveyId/anonymize

Anonymization of all respondents from a given import (batchId)

(POST) https://app.customerhero.com/api/v2/respondents/:surveyId/batch/:batchId/anonymize

Anonymization of all respondents from the specified mailing.

(POST) https://app.customerhero.com/api/v2/respondents/:surveyId/mailing/:mailingId/anonymize


Parameters (BODY) - version for e-mail sending

{
   "fields": [ 
      "email", 1, 2, 3, 5
   ] 
}

Parameters (BODY) - version for own distribution

{
   "fields": [ 
      1, 3, 5
   ] 
}


In the fields array, we pass the fields that are to be anonymized.

The consecutive numbers are the attribute numbers you want to anonymize.

If you want to anonymize attributes 1, 3, and 5, you pass only these numbers to the fields array.

After anonymization:

  • the e-mail value is changed to anonymous@xyz.abc

  • the value of the attributes is changed to xyzabc


Deleting a respondent

URL

(GET) https://app.customerhero.com/api/v2/respondents/delete

Parameters (POST)

Name

Description

id_survey

ID of the survey to which the respondent belongs

id_respondent

Respondent ID


Example response

{ 
"status":"ok" 
}

Returned errors

  • 401 Unauthorized – If the user references a foreign resource (survey/contact).

  • 404 Not Found – If a survey with the given :id_survey is not found.

  • 404 Not Found – If a respondent with the given :id_respondent is not found.


Batch upload of respondents

The process is intended to enable the sending of respondents in grouped batches, for which a single mailing can be created at the end. The entire process briefly looks as follows:

We create a new so-called batch (POST webankieta.pl/api/v2/respondents/batch). After successfully creating the batch, we will receive its id under which we will group individual batches (patches) of respondents.

1. CREATION - POST

(POST) customerhero.com/api/v2/respondents/batch

Parameters (POST)

Name

Description

survey_id

ID of the survey to which we will import respondents

Example response

{ 
   "batch_id":"89f7fcdb-c8c9-4414-8ec7-423780f66901" 
}

2. RETRIEVING - GET

(GET) customerhero.com/api/v2/respondents/batch

Parameters (GET)

Name

Description

batch_id

Batch ID



Returned values in json:

Name

Description

id

Batch ID

account_id

Account ID

survey_id

Survey ID

patches

List of IDs of associated patches



Returned errors

  • 401 Unauthorized – If the user references a foreign resource (survey/contact).

  • 400 An error occurred – If the operation fails

Troubleshooting:

  • We know of cases where many of the same e-mail addresses are imported in a single batch. When sending a mailing using the created batch, all messages are sent at once - it may happen that the mail server blocks these messages due to potential SPAM (many of the same messages in one second). We suggest minimizing the existence of multiple identical email addresses in a batch within a single sending.

We add subsequent packages (patches) of respondents to the previously created batch (POST webankieta.pl/api/v2/respondents/patch). Each package must be sent with the batch_id parameter equal to the previously created one, the recommended number of respondents in one package is 20 pieces.

3. SENDING A PACKAGE OF RESPONDENTS - POST

(POST) customerhero.com/api/v2/respondents/patch

Parameters:

Name

Description

batch_id

Batch ID

respondents

Array of respondents (recommended amount up to 20 pieces)



Body (x-www-form-urlencoded):

respondents[0,1,...,n]

0,1,...,n - respondent's ordinal number in the request

email

Respondent's e-mail

labels

Array of respondent's attribute values (max 15)



Returned values:

Name

Description

patch_id

Patch ID



Example of use:

A JSON data portion must be converted into a format for passing parameters via URL. For example:

{
"batch_id": "example_batch_id",
"respondents": [
   {
      "email": "jan.kowalski@webankieta.pl",
      "labels": [
         "Warszawa",
         "Support"
      ]
   },
   {
      "email": "tomasz.nowak@webankieta.pl",
      "labels": [
         "Łódź",
         "IT"
      ]
   },
   {
      "email": "zenon.martyniuk@webankieta.pl",
      "labels": [
          "Warszawa",
          "IT"
       ]
   }
   ]
}


It should be converted to this form:

batch_id=example_batch_id&respondents[0]
[email]=jan.kowalski%40webankieta.pl&respondents[0][labels]
[0]=Warszawa&respondents[0][labels][1]=Support&respondents[1]
[email]=tomasz.nowak%40webankieta.pl&respondents[1][labels]
[0]=%C5%81%C3%B3d%C5%BA&respondents[1][labels][1]=IT&respondents[2]
[email]=zenon.martyniuk%40webankieta.pl&respondents[2][labels]
[0]=Warszawa&respondents[2][labels][1]=IT


We pass this portion of data in the request as x-www-form-urlencoded in a POST request.

If a GET request is executed - the system will try to perform another operation.

cURL example:

curl --location 'https://www.webankieta.pl/api/v2/respondents/patch?survey_id=XYZ&batch_id=xxxxxxx' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer xxxxx' \
--data-urlencode 'respondents%5B0%5D%5Bemail%5D=test@test.pl' \
--data-urlencode 'respondents%5B0%5D%5Blabels%5D%5B0%5D=hr' \
--data-urlencode 'respondents%5B0%5D%5Blabels%5D%5B1%5D=wrocław'


JSON conversion to this format can be done, for example, using sample Javascript code:

function jsonToUrlEncoded(element,key,list) {
  list = list || [];
  if(typeof(element)=='object'){
    for (var idx in element)
    jsonToUrlEncoded(element[idx],key?key+'['+idx+']':idx,list);
  } else {
    list.push(key+'='+encodeURIComponent(element));
  }
return list.join('&');
}

console.log(jsonToUrlEncoded( {OBJECT} ));


In place of {OBJECT}, we must insert the JSON object that we want to convert into the format we need.

4. RETRIEVING RESPONDENTS - GET

(GET) customerhero.com/api/v2/respondents/patch

Parameters (GET)

Name

Description

patch_id

Patch ID



Returned json values:

Name

Description

respondents

List of respondent IDs created within a given patch


Returned errors

  • 401 Unauthorized – If the user references a foreign resource (survey/contact).

  • 400 An error occurred – If the operation fails

If we have already added all respondents, we can order the sending of invitations for all of them by providing the earlier batch_id (POST customerhero.com/api/v2/mailing/batch). Documentation regarding this step can be found here.