I'm encountering an issue with integrating the timestamp in Klaviyo using the new API:
The date-time field appears to be passed correctly, but Klaviyo displays only the current date without the exact time. Example:
- Activity details: Timestamped at
2024-10-30T00:00:00Z
and recorded on2024-10-30T07:08:55Z
.
I've tried multiple date functions, including gmdate("Y-m-d\TH:i:s\Z")
, (new DateTime("now", new DateTimeZone("UTC")))->format("Y-m-d\TH:i:s\Z")
, and (new DateTime("now", new DateTimeZone("UTC")))->format("c")
. However, I keep receiving the error: "Historical email subscription does not have a valid consented_at timestamp" — despite passing "historical_import" => true
as required.
Interestingly, if I hardcode the date with a timestamp like "2023-10-30T07:16:47Z"
, the data passes without issues.
Since I’ve been using Klaviyo integrations for years without this issue, I believe it may relate to recent API updates. Any insights on how to ensure the exact time is passed and recorded accurately? Thank you!
API Endpoint:
https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/
$requestData['data'] = [
"type" => "profile-subscription-bulk-create-job",
"attributes" => [
"profiles" => [
"data" => [
[
"type" => "profile",
"attributes" => [
"email" => $email,
"subscriptions" => [
"email" => [
"marketing" => [
"consent" => "SUBSCRIBED",
"consented_at" => date("Y-m-d")
]
]
]
]
]
]
],
"historical_import" => true
],
"relationships" => [
"list" => [
"data" => [
"type" => "list",
"id" => $listId
]
]
]
];