Skip to main content
Contributor I
March 29, 2023
Solved

Can't use filters on "Get Segment Profiles"

  • March 29, 2023
  • 2 replies
  • 502 views

I’m having an issue with the Get Segment Profiles API endpoint.

I’m getting the following error: "'equals' is not an allowed filter operator for email." however it says in the API docs that it is allowed?

I should also note that I use this exact setup for the ‘https://a.klaviyo.com/api/profiles/’ endpoint where the filter works fine.

How would i go about appending a filter where the request only returns a profile with a specific email if I can’t use the “equals” filter on emails?

  const options = {
method: 'GET',
headers: {
accept: 'application/json',
revision: '2023-02-22',
Authorization: `Klaviyo-API-Key ${process.env.KLAVIYO_PRIVATE_KEY}`
}
};

const params = new URLSearchParams({
'filter': `equals(email,"KNOWN_EMAIL_ADDRESS")`
});

const segmentID = 'SEGMENT_ID';

const segmentURL = `https://a.klaviyo.com/api/segments/${segmentID}/profiles/?${params}`

const { data: klaviyoSegment } = await fetch(segmentURL, options)
.then(res => res.json())
.catch(error => console.error(error))

 

    This topic has been closed for replies.
    Best answer by Fischeren

    Okay so I read the docs wrong, you can only use the any filter on emails for this endpoint.

    I solved this by changing my params to:

      const params = new URLSearchParams({
    'filter': `any(email,["KNOWN_EMAIL_ADDRESS"])`
    })

     

    2 replies

    FischerenAuthorAnswer
    Contributor I
    March 29, 2023

    Okay so I read the docs wrong, you can only use the any filter on emails for this endpoint.

    I solved this by changing my params to:

      const params = new URLSearchParams({
    'filter': `any(email,["KNOWN_EMAIL_ADDRESS"])`
    })

     

    Problem Solver II
    April 5, 2023

    @Fischeren Thanks so much for this. It works for me using Make (Formerly Integromat) creating a custom API.