Filter by respondent attributes

Filter responses by respondent attributes and return attributes with each response.

When listing responses, you can filter by the user attributes you passed to PollHero via identify(), and have these attributes returned.

Return attributes

With attributes[], you define which attributes come back in respondent.attributes, at most 50:

curl -G "https://app.poll-hero.com/api/v1/surveys/{survey_id}/responses" \
  -H "Authorization: Bearer ph_xxxxxxxx" \
  --data-urlencode "attributes[]=email" \
  --data-urlencode "attributes[]=customer_type"
"respondent": {
  "id": "b1f4c2d0-7a35-4c1e-8f7b-2f6f0e1f9a44",
  "attributes": [
    { "name": "email", "value": "customer@example.com" },
    { "name": "customer_type", "value": "new" }
  ]
}
  • Values are always strings, for example "true" or "1249.99".
  • Empty attributes are left out.
  • Attributes you filter on are returned automatically.

Filters

A filter has the form filter[<attribute>][<operator>]=<value>:

ExampleMeaning
filter[customer_type]=newshort form of [eq]
filter[total_purchases][gte]=3at least 3 purchases
filter[has_subscription][eq]=truecustom attribute
filter[country][in]=DE,AT,CHone of the values
filter[email][exists]=falsewithout email address
filter[plan->name]=pronested custom attribute
  • Several filters are combined with AND. At most 10 conditions per request. filter[x][gte]=1&filter[x][lte]=5 counts as two.
  • Negative operators (ne, not_contains, exists=false) also match respondents that were never identified.
  • filter[country] filters by the country attribute from identify(), not by the country of the response.

Attribute names

KindNames
Fixed attributesemail, customer_id, customer_type, total_revenue, total_purchases, total_aov, country, language
Custom attributesKeys of the data you pass to identify(). Separate nested keys with ->, e.g. plan->name.

Operators

OperatorMeaning
eqequal (default when no operator is given)
nenot equal
containscontains the text
not_containsdoes not contain the text
inone of the values, separated by commas
gt, gtegreater than, greater than or equal
lt, lteless than, less than or equal
existstrue: the attribute is set. false: the attribute is missing.

For custom attributes, true and false are compared as boolean values and numbers as numbers. Fixed text attributes such as email or country are compared as text.

Pages with filters

With attribute filters, the API checks only a limited number of responses per request. A page can therefore hold fewer records than requested, or none at all, although there are more matches. Only links.next counts: keep paging as long as it is not null.

On this page