Skip to main content

Hi,

I’m unit testing my code that uses the https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ endpoint. It’s a simple method to subscribe a single profile to a subs list. I’m testing against my test account.

Here’s the json: {"data":{"type":"profile-subscription-bulk-create-job","attributes":{"profiles":{"data":[{"type":"profile","attributes":{"email":"MY_EMAIL_ADDRESS_HERE","subscriptions":{"email":{"marketing":{"consent":"SUBSCRIBED"}}}}}]},"custom_source":"profile-subscription-bulk-create-job call on site"},"relationships":{"list":{"data":{"type":"list","id":"TVBgA3"}}}}}

My code just fires off a curl call with plain vanilla PHP. I get an empty response, as expected, and it comes with a 202 response, as expected. The dox (https://developers.klaviyo.com/en/reference/subscribe_profiles) say this means it was successful.

However, when I look at the profile on the dashboard it hasn’t changed, and no confirmation email was sent. My profile still just says ‘never subscribed’.

Is this expected for a test account, or should I test against some of my profiles on my live account?

(PS: I get the same results for trying to unsubscribe a profile using the endpoint profile-subscription-bulk-delete-jobs).

Many thanks,

Gareth

Hi Gareth,

This is not expected. I’ve used this endpoint a ton of times and haven’t seen this before. I primarily use single opt-in lists so I am not sure if that’s a confounding factor here.

I just tested with your exact request body and it worked. I suppressed my profile from email, called the endpoint, and I am now Subscribed to email. I didn’t change anything with your request body other than the email and list ID.

 

 

 

 

Cheers,

Kevin.


@KeviSunshine thank you, I appreciate you going to the trouble to verify that for me.

I think I’d better (at this point triple) check that I’m using the correct key, list ID and profile email. Failing that I’ll just have to test it with live site credentials and see if it fires proper.


Yeah, that’d be my advice too– there must be at least one test profile in your live site, and you could probably just swap out the list ID and private key to point to the live site for a quick test of the code.

Out of curiosity, how are you doing test credentials? Do you have a separate, test instance of Klaviyo? 


We’ve got a test account. Managed with the same login, but different keys etc.


Having run my unit tests again and looking at the API logs in my test account, only 3 calls are logged there out of 19 tests. Digging deeper into the code looks like some of the tests are set to override with production keys no matter what key I supply, so not an issue with Klaviyo, it was the test harness at fault.