Skip to main content
Contributor I
August 19, 2023
Solved

I cannot filter on email Get List Profiles

  • August 19, 2023
  • 4 replies
  • 343 views

Hi community,

 

I am trying to filter the Get List Profiles endpoint. However, it’s not working.

 

Here’s what I’ve got:

 

{{baseUrl}}/api/lists/:id/profiles/?fields[profile]=email&filter=equals(profile.email,"xxx")

 

The response I am getting is:

 

{
"errors": [
{
"id": "43cc5aa6-d5d4-4cb2-8f44-cb5cb6fb7f62",
"status": 400,
"code": "invalid",
"title": "Invalid input.",
"detail": "'profile.email' is not an allowed filter for this resource.",
"source": {
"parameter": "filter"
},
"meta": {}
}
]
}

 

Any idea what’s happening here?

 

Thanks

    This topic has been closed for replies.
    Best answer by Kim Strauch

    Hey @BilalHadiar! `equals` is not a supported filter operator for the Get List Profiles endpoint. 

    Try the following instead: 
    GET  {{baseUrl}}/api/lists/:id/profiles/?fields[profile]=email&filter=any(email,["xxx"])

    You’ll also want to URI encode the filter query param since your email addresses might contain non-url-safe characters. See our guide on filtering for more details: https://developers.klaviyo.com/en/docs/filtering_.

    4 replies

    Kim Strauch
    Klaviyo Employee
    Klaviyo Employee
    August 19, 2023

    Hey @BilalHadiar! `equals` is not a supported filter operator for the Get List Profiles endpoint. 

    Try the following instead: 
    GET  {{baseUrl}}/api/lists/:id/profiles/?fields[profile]=email&filter=any(email,["xxx"])

    You’ll also want to URI encode the filter query param since your email addresses might contain non-url-safe characters. See our guide on filtering for more details: https://developers.klaviyo.com/en/docs/filtering_.

    Contributor I
    August 20, 2023

    Thank you @Kim Strauch . I am still getting my hands dirty with the API. 

     

    Going back to the docs I see this:

     

    filter

    string

    For more information please visit https://developers.klaviyo.com/en/v2023-08-15/reference/api-overview#filtering
    Allowed field(s)/operator(s):
    emailany
    phone_numberany
    push_tokenany
    _kxequals

     

    It makes more sense now! 

     

    Thank you

    Bill

    Problem Solver I
    December 19, 2023

    @Kim Strauch and @BilalHadiar  and @Brian Turcotte 

     

    Okay i am using the 2023-12-15 api, and in the documentation it should be able to filter by equals on the email part

    $system->Klaviyo($env['klaviyo_api'], 'GET', $env['klaviyo_url'] . 'profiles/?filter=equals(email,'.urlencode($orderData['recipient-email']).')', false)

     

    But i get the same error
    array(1) { ["errors"]=> array(1) { [0]=> array(7) { ["id"]=> string(36) "3bf9a9c9-1b34-4d5a-875a-577e0106741a" ["status"]=> int(400) ["code"]=> string(7) "invalid" ["title"]=> string(14) "Invalid input." ["detail"]=> string(24) "Invalid filter provided." ["source"]=> array(1) { ["parameter"]=> string(6) "filter" } ["meta"]=> array(0) { } } } }

     

    I can get output if i just delete the ?filter parameter

    Kim Strauch
    Klaviyo Employee
    Klaviyo Employee
    December 21, 2023

    Hey there, I looked up the specific error ID you included in your post, and it looks like you’re making an API call to this URL that’s resulting in that error: 

    1: https://a.klaviyo.com/api/profiles/?filter=any(email,REDACTED_EMAIL). 

    If you were creating a URL like 
    2: https://a.klaviyo.com/api/profiles/?filter=equals(email,REDACTED_EMAIL) I think that would also fail.


    For (1), the value in the filter param needs to be an array, not a single email. For both (1) and (2), the string value needs to be quoted before being encoded.

    See our guide on filtering for more details and examples: https://developers.klaviyo.com/en/docs/filtering_ 

     

    Hopefully that helps!