We use Klaviyo on several different sites to sign users up for Email and SMS mailing lists, and I’ve recently started work on refactoring our API calls to use the latest endpoints (coming from v2). In the past, subscribing users to lists and adding custom properties only took a single call, but with the recent updates it appears that we now have to:
- Create the new user profile and add custom properties
- Subscribe that newly created user to the target list
All of this is working as expected when using email, but when I try to create a new user with only the phone_number field, and no email or id, I get the following error:
{
id: 'e5988f66-18e7-4927-bdb2-7a1165a48958',
status: 400,
code: 'invalid',
title: 'Invalid input.',
detail: 'One or more identifiers is required',
source: [Object],
links: {},
meta: {}
}
Is this expected behavior?
The profile creation is being triggered with the createOrUpdateProfile command from the node.js library: https://github.com/klaviyo/klaviyo-api-node
Here is an example payload for what’s being sent to the endpoint:
{
"type":"profile",
"attributes":{
"$consent":"web",
"subscriptions":{
"sms":{
"marketing":{
"consent":"SUBSCRIBED"
}
}
},
"phone_number":"+19125554444",
"properties":{
"form_version":"x.x.x",
"form_id":"form-id",
"origin":"https://www.thewebsite.com"
}
}
}
Again, the above payload works fine when using email in place of phone_number (and changing the subscriptions.sms property to email)
Any insight is appreciated - thanks in advance,
Teddy