Skip to main content
Problem Solver I
September 7, 2023
Solved

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

  • September 7, 2023
  • 5 replies
  • 382 views

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?

    This topic has been closed for replies.
    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
    Klaviyo Alum
    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

    diegoecheAuthor
    Problem Solver I
    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.

    diegoecheAuthor
    Problem Solver I
    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"

    diegoecheAuthorAnswer
    Problem Solver I
    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
    Klaviyo Employee
    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