Skip to main content

Feels like a basic question but I can’t seem to stack multi filters to my campaign API request. I want to be able to get all email campaigns for this month so I have something like this:

 

and(equals(messages.channel,'email'),greater-or-equal(created_at,'2024-08-01T00:00:00-07:00'))

 

and the url request looks like

 curl --request GET \curl --request GET \
     --url 'https://a.klaviyo.com/api/campaigns/?filter=equals%28messages.channel%2C%27email%27%29%2Cgreater-or-equal%28updated_at%2C%272024-08-01T00%3A00%3A00-07%3A00%27%29' \
     --header 'Authorization: Klaviyo-API-Key XXXXXXXXX' \
     --header 'accept: application/json' \
     --header 'revision: 2024-07-15'

 

When running it though, I get invalid filter. I feel like this is a simple fix but i am not seeing it. Any assistance would be great.

Hey @cLin

Try removing the quotes from the datetime in your filter, i.e. and(equals(messages.channel,'email'),greater-or-equal(created_at,2024-08-01T00:00:00-07:00))
 

Datetimes should be specified without quotes. See our guide on filters for some examples: https://developers.klaviyo.com/en/docs/filtering_ 

Ideally we can provide a more helpful error message for this in the future, as it’s tricky to catch otherwise! 


Ah...ok that makes sense. The filters are working now.


Hey @cLin

Try removing the quotes from the datetime in your filter, i.e. and(equals(messages.channel,'email'),greater-or-equal(created_at,2024-08-01T00:00:00-07:00))
 

Datetimes should be specified without quotes. See our guide on filters for some examples: https://developers.klaviyo.com/en/docs/filtering_ 

Ideally we can provide a more helpful error message for this in the future, as it’s tricky to catch otherwise! 

Is it the same for flows? I tried this and got a similar error, I also tried updated_at in case that was a misspelling.

 

 https://a.klaviyo.com/api/flows/?filter=greater-or-equal(updated,2024-08-01T00:00:00-07:00)` resulted in a `400 Bad Request` response:
{"errors": {"id":"dc4f8e79-bf79-4801-8be7-500c59c18e5c","status":400,"code":"invalid","title":"Invalid input.","detail": (truncated...)


Reply