Solved

Can't use filters on "Get Segment Profiles"

  • 29 March 2023
  • 2 replies
  • 310 views

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

 

icon

Best answer by Fischeren 29 March 2023, 10:34

View original

2 replies

Badge +1

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

 

Userlevel 2
Badge +5

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

Reply