Solved

Regarding klaviyo client subscription api of v2023


Badge +1

Hello I am using 2023 api that is this one https://a.klaviyo.com/client/subscriptions/?company_id=my company id to subscribe profiles in list I m able to that with postman but with node api I am getting 202 accepted but the data is not getting stored and also my list have single opt in enabled kindly help me with this I m not getting error but data not getting stored except data sent with postman.Any help would be appreciated. 

I have verified my body databy consoling there is no error in json format

icon

Best answer by David To 31 May 2023, 22:46

View original

12 replies

Userlevel 7
Badge +60

Hello @Abrar22,

Welcome to the Klaviyo Community!

If you’re getting a 202 status, that means the request has been received but not yet acted upon. This status is returned for requests that were accepted but are processed asynchronously. 

Glad you already ruled out double opt-in wasn’t the setting prevent users from ending up on the list. Since you also aren’t seeing the profile created in Klaviyo, this leads me to suspect you may have triggered our list bombing prevention system

I’ve recently shared some additional resources on this topic which you can find in the Community posts below:

I hope this helps!

David

UPDATE: Turns out my issue was with single vs double opt in settings on the lists I’m working with. Endpoint is working as expected 👍

 

Hi All,

 

I am seeing the same issue with Node. I am trying to update an existing profile to be subscribed to a list. I am getting a 202 back, however, nothing is changing within Klaviyo for the profile or subscription. 

 

I am following this documentation: https://developers.klaviyo.com/en/reference/subscribe_profiles
api version: 2023-02-22

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

 

here is my payload shape: 

const body = {
data: {
type: 'profile-subscription-bulk-create-job',
attributes: {
list_id: listId,
custom_source: 'Marketing Event',
subscriptions: [
{
channels: { email: ['MARKETING'] },
email,
profile_id: profileId,
},
],
},
},
};

Any help here would be greatly appreciated. 

Badge +1

Thank u for the response it worked out for me 

But the problem is when I am running on my server I was getting data that too only 10 mails after that no error but got stopped and I have been trying with different system and ips.kindly help.me out

Kindly provide a proper solution

Userlevel 7
Badge +60

Hey @JStones,

Thanks for sharing your update and for highlighting the solution that worked for you!

@Abrar22, if you’re trying to subscribe user from your server, you may want to use the https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ endpoint instead. 

As mentioned in our Create Client Subscription API reference, the https://a.klaviyo.com/client/subscriptions/ endpoint is meant to be used through publicly-browseable, client-side environments only. 

The https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ endpoint on the other hand is meant to subscribe one or more profiles to email marketing, SMS marketing, or both - allowing you to add users to a list in bulk. More details on this endpoint can be found in our Subscribe Profiles API reference.

David

Badge +1

Thank you for your response .I agree with you but using this api I won't be able to send custom properties like I was able to send from client subscription api.Is there a way to custom properties if yes then please help me with that by giving an example I am using the api in node so any help would be really appreciated 

Userlevel 7
Badge +60

Hey @Abrar22,

After making a call to the  https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ endpoint, you could make a subsequent call to the Update Profile endpoint to apply those custom profile properties. 

Alternatively, you could also just do this with in a single .CSV import. I would recommend taking a look at the following resources:

If you need hands-on help with any of these steps, I would further suggest reaching out and working alongside some of our wonderful Klaviyo Partners. You can contact our accreddited Partners through our Klaviyo Partner Directory.  

David

Badge +1

yes got you but the update client api is not working i mean i tried to manually pass data but it is giving me 400 error this is the link https://developers.klaviyo.com/en/reference/create_client_profile i am using node 
{
   "data": {
      "type": "profile",
      "attributes": {
         "email": "sarah.mason@klaviyo-demo.com",
         "phone_number": "+15005550006",
         "external_id": "63f64a2b-c6bf-40c7-b81f-bed08162edbe",
         "anonymous_id": "string",
         "first_name": "Sarah",
         "last_name": "Mason"
      }
   }
}
data i am trying to pass but it always gives 400 error i need a help

Badge +1

And i used this api https://a.klaviyo.com/api/profiles/{id}/ to update profile i have seen every data is passed perfectly and from postman i can send data but not from my node or thunder in vscode why so

 

Userlevel 7
Badge +60

Hey @Abrar22,

A 400 error code signifies a bad request as mentioned in the Response status codes section of our Rate limits, status codes, and errors Developer guide. This means that your request could be is missing a required parameter or has an invalid parameter.

Although the body of your request looks acceptable, this may indicate something in the header of your request is invalid or missing. 

Are you also sure you’re intent is to make a client side call -  the https://a.klaviyo.com/client/profiles/ endpoint is client side, instead of a server side call? If you intended to actually make a server-side call, you should actually be using the Create Profile https://a.klaviyo.com/api/profiles/ endpoint. 

Since it sounds like you’re still having trouble, I would strongly encourage you to review your whole setup alongside your developer. Or if you need an introduction to one, we have a number of Klaviyo Partners who excel in this area that you can reach out to via our Klaviyo Partner Directory

David

Badge +1

Hii thank u so much for the solution but I wanted to ask one more question is that I am trying to create list via the create list api the list gets created successfully but the problem is that the new list created has double opt in settings enabled by default but how can I make the list created single opt in by default or is there any method any help would be really appreciated

Hey @Abrar22,

A 400 error code signifies a bad request as mentioned in the Response status codes section of our Rate limits, status codes, and errors Developer guide. This means that your request could be is missing a required parameter or has an invalid parameter.

Although the body of your request looks acceptable, this may indicate something in the header of your request is invalid or missing. 

Are you also sure you’re intent is to make a client side call -  the https://a.klaviyo.com/client/profiles/ endpoint is client side, instead of a server side call? If intend to actually make a server-side call, you should actually be using the Create Profile https://a.klaviyo.com/api/profiles/ endpoint. 

Since it sounds like you’re still having trouble, I would strongly encourage you to review your whole setup alongside your developer. Or if you need an introduction to one, we have a number of Klaviyo Partners who excel in this area that you can reach out to via our Klaviyo Partner Directory

David

 

Badge +1

Hii thank u so much for the solution but I wanted to ask one more question is that I am trying to create list via the create list api the list gets created successfully but the problem is that the new list created has double opt in settings enabled by default but how can I make the list created single opt in by default or is there any method any help would be really appreciated

Userlevel 7
Badge +60

Hey @Abrar22,

Looks like you’ve also made a duplicate post pertaining to the same question which you can find my answer to below:

David

Reply