Skip to main content
Solved

Adding/Updating Profiles via API Email status "Never Subscribed"


Forum|alt.badge.img+1
  • Contributor I
  • 7 replies

I am using the latest dated revision of this API endpoint:

https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/

I am including in the payload:

"subscriptions": {
                                "email": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                },
                                "sms": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                }
                            }

 

Previously I was using the February 2024 revision of the API and all my testing was successfully getting profiles created/updated with Email Status - “Subscribed”

The only change I am aware I made was updated to revision May 2024. Now profiles created/updated are showing Email Status = “Never subscribed”

This is a SINGLE OPT-IN list. What could be going wrong?

 

Best answer by Kim Strauch

Hey @MaxT, stricter validation rules were added in the 2024-05-15 revision of the API.

If you do not have a sending number configured for the region — based on your example with a +1, I’m guessing this is for the US — the API will reject with a 400. This is because you cannot modify consent for this phone # given the account’s setup.


If you want to create a profile with email + phone_number but only update email marketing consent, you should remove the “sms” block from your payload like so:

{
    "data": {
        "type": "profile-subscription-bulk-create-job",
        "attributes": {
            "profiles": {
                "data": [
                    {
                        "type": "profile",
                        "id": "01J068W6SV0D5EJ7YPXXXXXXX",
                        "attributes": {
                            "email": "marXXXX@gmail.com",
                            "phone_number": "+1386235XXXX",
                            "subscriptions": {
                                "email": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        },
        "relationships": {
            "list": {
                "data": {
                    "type": "list",
                    "id": "TcXXXX"
                }
            }
        }
    }
}

 

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 7 replies
  • June 12, 2024

So I see now that the error returned is saying it is not a supported region for phone number?

 

{
    "errors": [
        {
            "id": "9cb12681-2dcd-432f-b5a4-1611d43e3c6d",
            "status": 400,
            "code": "invalid",
            "title": "Invalid input.",
            "detail": "Phone number is valid but is not in a supported region for this account. Please configure a sending number for this region.",
            "source": {
                "pointer": "/data/attributes/profiles/data/0/attributes/phone_number"
            },
            "links": {},
            "meta": {}
        }
    ]
}

 

 

Here is the payload I am sending with personal info masked. Why is it rejecting this phone number?

 

{
    "data": {
        "type": "profile-subscription-bulk-create-job",
        "attributes": {
            "profiles": {
                "data": [
                    {
                        "type": "profile",
                        "id": "01J068W6SV0D5EJ7YPXXXXXXX",
                        "attributes": {
                            "email": "marXXXX@gmail.com",
                            "phone_number": "+1386235XXXX",
                            "subscriptions": {
                                "email": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                },
                                "sms": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        },
        "relationships": {
            "list": {
                "data": {
                    "type": "list",
                    "id": "TcXXXX"
                }
            }
        }
    }
}


Kim Strauch
Klaviyo Employee
Forum|alt.badge.img+9
  • Klaviyo Employee
  • 91 replies
  • Answer
  • June 12, 2024

Hey @MaxT, stricter validation rules were added in the 2024-05-15 revision of the API.

If you do not have a sending number configured for the region — based on your example with a +1, I’m guessing this is for the US — the API will reject with a 400. This is because you cannot modify consent for this phone # given the account’s setup.


If you want to create a profile with email + phone_number but only update email marketing consent, you should remove the “sms” block from your payload like so:

{
    "data": {
        "type": "profile-subscription-bulk-create-job",
        "attributes": {
            "profiles": {
                "data": [
                    {
                        "type": "profile",
                        "id": "01J068W6SV0D5EJ7YPXXXXXXX",
                        "attributes": {
                            "email": "marXXXX@gmail.com",
                            "phone_number": "+1386235XXXX",
                            "subscriptions": {
                                "email": {
                                    "marketing": {
                                        "consent": "SUBSCRIBED"
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        },
        "relationships": {
            "list": {
                "data": {
                    "type": "list",
                    "id": "TcXXXX"
                }
            }
        }
    }
}

 


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 7 replies
  • June 13, 2024

Hi @Kim Strauch,

Yes, this does solve my problem. I removed the  "sms": {"marketing": {"consent": "SUBSCRIBED"}}

code from my payload and now getting Email Status “Subscribed” for all Profiles.

However, I am pretty surprised a breaking change would be made like this after only 3 months. Yes, I know I could have left my code using Feb 2023 revision, but was hoping Klaviyo would make breaking changes only in rare circumstances. Klaviyo is going to keep us devs busy in the next few years;)

My 2 cents.