Skip to main content
Solved

How to use fields[profile] while requesting events in API v2?

  • November 2, 2022
  • 3 replies
  • 369 views

Forum|alt.badge.img+3

Hi there,

We’re migrating our integration with Klaviyo to v2 and I faced the issue with retrieving such profile properties as first_name, last_name, email when collecting events.

API reference declares optional query param “fields[profile]”: https://developers.klaviyo.com/en/reference/get_events

But when I try to use this param:

GET https://a.klaviyo.com/api/events?sort=datetime&fields[profile]=first_name,last_name,email&filter=greater-or-equal(datetime,2022-10-20)

I got the error 400 Bad Request:

{
    "errors": [
        {
            "id": "cc99c0e8-a548-43ed-827b-793d82f78aad",
            "status": 400,
            "code": "invalid",
            "title": "Invalid input.",
            "detail": "'profile' is not an allowed field family for this resource.",
            "source": {
                "parameter": "fields"
            },
            "meta": {}
        }
    ]
}

 

Please advise how I can retrieve profile properties from /events endpoint? I would like don’t requesting /profiles endpoint for a some reasons.

Thanks in advance!

Best answer by Brian Turcotte

Hi @imp_dev!

 

Sorry for my delay in getting back around to this post - appending  &include=profiles  to the query string might resolve this issue:

 

https://a.klaviyo.com/api/events?sort=datetime&fields[profile]=first_name,last_name,email&filter=greater-or-equal(datetime,2022-10-20)&include=profiles

 

I’ve seen other users resolve similar issues this way, so I hope this helps!

 

-Brian

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

3 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @imp_dev and welcome to the Community!

 

If the use case is to retrieve Profile properties or information that isn’t intrinsically related to an event, then I would generally advise utilizing the Profiles endpoint which is essentially available for that exact purpose.

 

Are you comfortable sharing why you need to use the Events endpoint? If not, I totally understand, but it may help me to understand the parameters of your use case.

 

As far as the reason why the param is throwing an error, I will have to consult the documentation and potentially our engineering team for further information, and then I will update the thread. 

 

Thanks for using the Community!

-Brian

 


Forum|alt.badge.img+3
  • Author
  • Contributor IV
  • 8 replies
  • November 7, 2022

Hi Brian,

Thank you for answering!

Using v1 API, we retrieving Events details along with some Profile properties.

And we would like to make it using v2 API. Otherwise, using Profiles endpoint we should rework our datasets and dashboards for our clients.


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • December 29, 2022

Hi @imp_dev!

 

Sorry for my delay in getting back around to this post - appending  &include=profiles  to the query string might resolve this issue:

 

https://a.klaviyo.com/api/events?sort=datetime&fields[profile]=first_name,last_name,email&filter=greater-or-equal(datetime,2022-10-20)&include=profiles

 

I’ve seen other users resolve similar issues this way, so I hope this helps!

 

-Brian