Solved

Bulk subscribe profiles error: "An invalid field type was passed in."

  • 28 November 2023
  • 10 replies
  • 229 views

Badge

Hello,

I’m trying to call “profile-subscription-bulk-create-job” exactly as it is recommended in https://developers.klaviyo.com/en/reference/subscribe_profiles :

{
"data": {
"type": "profile-subscription-bulk-create-job",
"attributes": {
"custom_source": "Marketing Event",
"profiles": {
"data": [
{
"type": "profile",
"id": "01HDPB6Q6FWBQH3T3CRYRFJJRZ",
"attributes": {
"email": "morag@fakeshop.co.uk",
"phone_number": "+15005550006",
"subscriptions": {
"email": {
"marketing": {
"consent": "SUBSCRIBED"
}
},
"sms": {
"marketing": {
"consent": "SUBSCRIBED"
}
}
}
}
}
]
}
},
"relationships": {
"list": {
"data": {
"type": "list",
"id": "Y9LmPZ"
}
}
}
}
}

But Klaviyo returns an error:

{
"errors": [{
"id": "58642876-4801-42d9-9698-bbcefbd12745",
"status": 400,
"code": "invalid",
"title": "Invalid input.",
"detail": "An invalid field type was passed in.",
"source": {
"pointer": "/data"
},
"meta": {}
}
]
}

 Actually I’m not interested in SMS subscription and relationships and simply want to update subscription status from a 3rd party system but it returns same error.

{
"data": {
"type": "profile-subscription-bulk-create-job",
"attributes": {
"profiles": {
"data": [
{
"type": "profile",
"attributes": {
"email": "morag@fakeshop.co.uk",
"subscriptions": {
"email": {
"marketing": {
"consent": "SUBSCRIBED"
}
}
}
}
}
]
}
}
}
}

 

icon

Best answer by KeviSunshine 28 November 2023, 14:02

View original

10 replies

Userlevel 4
Badge +7

Hi @maxim,

I’m stumped. I figured it must be malformed JSON, but I just compared the example you shared with the example in the docs and they have the same exact structure…

The only things I can think of to check right now are the List ID, the phone number format, the email, and the profile ID.

Maybe try w/o the top-level `data` element too–just passing a top-level object with `{ type, attributes, relationships }`.

 

Let me know.

 

Cheers,

Kevin.

Badge

Hi  KeviSunshine,

Thanks for the suggestion. Unfortunately it does not work, the /data object is mandatory:

{
"errors": [{
"id": "bcfc61ce-b09b-48c3-82ff-2bcb2e37e8f4",
"status": 400,
"code": "invalid",
"title": "Invalid input.",
"detail": "An object with data is required",
"source": {
"pointer": "/data"
},
"meta": {}
}
]
}

I changed the profile ID, email, related list and even assigned same phone number so everything is most possibly close to the original request. I even tested when this profile is in the list and not in the list. The error is still the same.

I tried without any of this info just with data I need: email and its subscription status. Doesn’t work as well.

Userlevel 4
Badge +7

Hi @maxim,

It’s working for me… I’m getting a 202 Accepted response and I see my profile is now in a new list.

 

I took your bottom example (the simplified one) and just added the relationships and a list.

 

Maybe double check your endpoint, method, PK, etc.?

Badge

Hi @KeviSunshine,

Thank you for the help, I found the issue: by some reason I used API revision 2023-09-15 instead of 2023-10-15. So it returns 202 now:

 

But the subscription status wasn’t changed:

And this is actually what do I need to achieve: Email should be “Subscribed” instead of “Never subscribed”

Userlevel 4
Badge +7

Hi @maxim,

I just manually unsubscribed my profile, ran the API call, and it’s now showing as the green Subscribed…

 

I am not sure whether this is being affected by list opt-in statuses or account settings...

Badge

Hi @KeviSunshine,

Seems like I found what is the issue: when I’m calling bulk subscribe API Klaviyo sends email to the client to confirm profile subscription:

The subscription status will not be changed from “Never subscribed” to “Subscribed” unless customer will confirm by opening the link “Yes, I want to subscribe” from this email.

This is a thing I would like to avoid as profiles are imported from a 3rd party system. Also subscription status update comes from this 3rd party system so we just need to reflect it on Klaviyo without any confirmations. Is it possible to do so?

Userlevel 4
Badge +7

@maxim yeah, 100% possible!!

Go to your list’s settings and change it from double opt-in to single opt-in.

This is a very important feature of Klaviyo and there are a lot of articles about it (including the legal ramifications!).

https://help.klaviyo.com/hc/en-us/articles/115005251108

 

Cheers,

Kevin.

Badge

@KeviSunshine, thank you a lot for your help! Cheers!

Want to check if I need to send the name of the user, can I do that with this API?

Userlevel 4
Badge +7

Hi @Ora Group,

You don’t need to pass the name of the user – the email, phone number, or ID will be the identifiers of the profile.

However, you certainly can pass a name to set or update the profile’s first and last name.

Taking the example from above, that would look like this…


"email": "testing@example.com",
"phone_number": "+15555555555",
"first_name": "Kevi",
"last_name": "Sunshine"

Cheers,

Kevin.

Reply