Skip to main content
Solved

Is creation by profile email still allowed in the latest api version?

  • September 7, 2023
  • 5 replies
  • 336 views

Forum|alt.badge.img+4

I'm very confused by the update in the changelog from https://developers.klaviyo.com/en/docs/changelog_#relationship-standardization

We
use the API to create events on behalf of our customers, and we identify the profiles by email.

I tried updating our API to the latest version , and I'm getting an error:

'{"errors":[{"id":"8f145b8b-43ae-401f-9cee-15983ceaa522","status":400,"code":"invalid","title":"Invalid
        input.","detail":"One of `attributes`, `relationships` or `id` must be included
        in the request payload.","source":{"pointer":"/data"},"meta":{}}]}'

I find the API documentation not very clear. There aren't examples of adding the event through email that was possible, or maybe I'm missing something?

Best answer by diegoeche

Actually, figured it out…


I didn't put the metric event name in the attributes. But gosh, the error message could have been clearer. Instead of "pointer/data" maybe tell me /pointer/metric/data.
 

5 replies

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • September 7, 2023

Hi @diegoeche!
 

May I ask which endpoint in particular you have been using to accomplish this use case? This will help myself and other Community members understand the issue better.

 

Best,

Brian


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 4 replies
  • September 7, 2023

Yes, of course. Thank you Brian. I forgot proof-reading this a bit better.

So, right now I'm calling:

POST on:
"https://a.klaviyo.com/client/events/#{auth}"
With a payload like:


```

      body = {
        data: {
          type: "event",
          attributes: {
            profile: profile,
            metric: {name: event_name},
            properties: properties
          }
        }
      }

```

This is "2022-10-17". I use the email as the profile identifier.

Where profile is:
{
          email: "diego@example.com",
}
and properties, whatever we want to send within the event:

We want to update to "2023-08-17":

And I'm sending something like:

```

      body = {
        data: {
          type: "event",
          attributes: {
            profile: {
              data: {
                type: :profile
                # Docs say I need the klaviyo profile id, but we use email.
                # id: <klaviyo-id>
                attributes: profile
              }
            }
            metric: {
              data: {
                type: metric,
                name: event_name
              }
            },
            properties: properties
          }
        }
      }
```

I'm getting this error:

One of `attributes`, `relationships` or `id` must be included

So it feels to me, that newer version don't allow me to create an event using the email as an identifier.


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 4 replies
  • September 7, 2023

Hi @diegoeche!
 

May I ask which endpoint in particular you have been using to accomplish this use case? This will help myself and other Community members understand the issue better.

 

Best,

Brian

I'd love to edit the title as in: "Is event creation by profile email"


Forum|alt.badge.img+4
  • Author
  • Problem Solver I
  • 4 replies
  • Answer
  • September 7, 2023

Actually, figured it out…


I didn't put the metric event name in the attributes. But gosh, the error message could have been clearer. Instead of "pointer/data" maybe tell me /pointer/metric/data.
 


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2455 replies
  • September 8, 2023

Hey @diegoeche,

Glad to hear you figured out the solution!

I’ll certainly share that feedback with our Product team - especially the ones responsible for our APIs to offer a more clarified error message. 

Thanks for being a part of our Klaviyo Community!

David