Skip to main content
Solved

Can't use filters on "Get Segment Profiles"


Forum|alt.badge.img+1

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))

 

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"])`
  })

 

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 2 replies
  • Answer
  • 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"])`
  })

 


Forum|alt.badge.img+5
  • Problem Solver II
  • 23 replies
  • April 5, 2023

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