Skip to main content
Contributor I
October 4, 2024
Solved

Are all custom properties entered by API lists/array?

  • October 4, 2024
  • 5 replies
  • 171 views

If I add a custom property through website it is entered as I like it. In this case as a date.

If I enter it via the API is comes in as a list/array. 

I need this field to come in through the API as a date that I can use in flows/segments. How do I fix this?

    This topic has been closed for replies.
    Best answer by DavidSandel

    What is the format you’re trying to pass in? The form on a website can probably take in a ‘pretty’ date and format it automatically. But if you’re trying to pass in a ‘pretty’ date in through the API, it will likely interpret it as a list or text. It has to be in one of the supported formats:

    5 replies

    DavidSandel
    Partner - Silver
    Partner - Silver
    October 4, 2024

    What is the format you’re trying to pass in? The form on a website can probably take in a ‘pretty’ date and format it automatically. But if you’re trying to pass in a ‘pretty’ date in through the API, it will likely interpret it as a list or text. It has to be in one of the supported formats:

    Klaviyo Silver Master --> LowGravitySolutions.com
    PminichAuthor
    Contributor I
    October 4, 2024

    I’ve tried every one of those formats with no success.

    Here is the current payload and what I get back.

    {
    "data": {
    "type": "profile",
    "id": "XXXXXXXXX",
    "attributes": {
    },
    "properties": {
    "LapsedDate": "2024-10-04T00:00:00Z"
    },
    "meta": {
    "patch_properties": {
    "append": {
    "LapsedDate": "2024-10-04T00:00:00Z"
    }
    }
    }
    }
    }
    "properties": {
    "MailChimp Rating": 2,
    "LapsedDate": [
    "2024-10-04T00:00:00Z"
    ]
    }

     

    DavidSandel
    Partner - Silver
    Partner - Silver
    October 4, 2024

    Another dumb question, have you verified in the profile page or segment builder that it’s *not* being treated as a date after sending it in via API?

    Klaviyo Silver Master --> LowGravitySolutions.com
    PminichAuthor
    Contributor I
    October 4, 2024

    Yes I have confirmed that. If I put the date in manually it segments correctly. If I put the date in via API it is treated as text for the segmenting. 

    Manually it looks like 2024-10-04T00:00:00Z

    API it looks like [“2024-10-04T00:00:00Z”]

    If I take out the brackets and quotes manually from the api entered data it is treated like a date.

     

    Contributor II
    December 11, 2024

    I’m getting the same problem with ANY custom properties I try to add via API - example:

    https://developers.klaviyo.com/en/reference/create_or_update_profile

    $payload = [
    'data' => [
    'type' => 'profile',
    'attributes' => $attributes,
    'meta' => [
    'patch_properties' => [
    'append' => [
    'GN_custom' => 'value goes here',
    ],
    ],
    ],
    ],
    ];
    $response = $this->client->Profiles->createOrUpdateProfile($payload);


    I would expect my custom property `GN_custom` to have a value of "value goes here" but instead it is wrapped in an array like this ["value goes here"].

     

    At first I thought it was a problem with their PHP SDK that we’re using, but after debugging that it appears to be just the way the API endpoint handles custom properties. It’s broken.