I'm having trouble with my WordPress/WooCommerce integration with Klaviyo's API. My setup handles user consent for marketing communications, but I'm facing issues with re-subscribing users who have previously unsubscribed.
Current Implementation
I've built a user flow that:
- Registers users in Klaviyo when they create an account and opt-in to marketing
- Updates their profile in Klaviyo when they update their WooCommerce profile
- Unsubscribes users from Klaviyo when they withdraw consent
- Re-subscribes users to Klaviyo when they opt back in after previously withdrawing consent
The issue is with the last step - once a user has unsubscribed, I can't seem to re-subscribe them properly.
Code Flow
When a user opts in:
- I call profile-import to create/update their profile
- I call profile-suppression-bulk-delete-job to try removing them from the suppression list
- I call profile-subscription-bulk-create-job to add them as a subscriber
When a user opts out:
- I call profile-subscription-bulk-delete-job to unsubscribe them
The Issue
After unsubscribing a user with profile-subscription-bulk-delete-job, calling profile-subscription-bulk-create-job later doesn't appear to update their subscription status. They remain in an unsubscribed state.
Additionally, the profile-suppression-bulk-delete-jobscall doesn't seem to actually remove profiles from being marked as "suppressed" in Klaviyo.
I've tried different API request structures following the documentation, but nothing seems to actually remove the suppression status or re-subscribe users properly. I have read other topics on this forum including the following:
But for whatever reason I can't get this to work. I am using the latest API endpoints which the above posts suggest is necessary. I have tried using the exact same endpoints as mentioned in the first thread and cannot get the profile to successfully resubscribe after unsubscribing the first time around.
Has anyone successfully implemented a workflow for re-subscribing previously unsubscribed users through the API? Are there any specific requirements or steps I'm missing for this use case?
Thanks in advance!
Hi @mikehs93
Thank you for posting in the Community!
You could try the following API instead.
If the profile is suppressed, use profile-suppression-bulk-delete-job to clear suppressions:
POST https://a.klaviyo.com/api/profile-suppression-bulk-delete-jobs/ { "data": { "type": "profile-suppression-bulk-delete-job", "attributes": { "profiles": { "data": t { "type": "profile", "attributes": { "email": "user@example.com" } } ] } } } }
Re-subscribe the user.
Next, use profile-subscription-bulk-create-job to update their consent and subscribe them:
POST https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ { "data": { "type": "profile-subscription-bulk-create-job", "attributes": { "custom_source": "Include source", "historical_import": true, "consented_at": "Include timestamp", "profiles": { "data": a { "type": "profile", "attributes": { "email": "Insert E-mail", "subscriptions": { "email": { "marketing": { "consent": "SUBSCRIBED" } } } } } ] } }, "relationships": { "list": { "data": { "type": "list", "id": "<your-list-id>" } } } } }
Hope that helps or else let me know! :-)
Christian Nørbjerg Enger
Partner & CPO
Web: Segmento.dk
LinkedIn: @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov
Thanks Christian, that’s exactly what I am doing.
The endpoints I’m using in order are:
-
profile-suppression-bulk-delete-jobs - to clear the suppression
-
profile-import - to create or update the profile
-
profile-subscription-bulk-create-jobs - to subscribe the profile to the list
Steps 2 and 3 work fine if it’s a new user or the user is just updating their data but not their subscription status. The problem is that step 1 does not fire correctly if the user has previously been unsubscribed via a “profile-subscription-bulk-delete-job” call.
I can provide my example code if that’s helpful?
@Christiannoerbjerg possible to get an update please? what am I doing wrong?
Hey @mikehs93,
Happy to provide you with some additional information to help figure this out. In case my suggestion doesn’t answer your question, I’d recommend sending over a couple request bodies that we can look at to see if anything in the request looks off. It would be useful to see examples of your profile-suppression-bulk-delete-jobs, profile-import and profile-subscription-bulk-create-jobs requests, with all private data redacted.
Can you check and see if the lists you’re resubscribing profiles to are single or double opt-in? If they’re double opt-in, the customer you’re resubscribing would receive a confirmation email to their inbox, where they’d need to confirm before being marked as subscribed. You also might want to check and see if your default opt-in setting is set to double opt-in. If this isn’t the issue, feel free to send those API request bodies along, and we can check and see what the problem is. Looking forward to your response.
-Byrne
Thanks @Byrne C, the list is double opt in so the current flow is:
- User subscribes via the website and triggers a request via the API
- Confirmation email is received and accepted
- Profile is correctly identified as subscribed on the Klaviyo side
- User unsubscribes via the website and triggers another request via the API
- Profile is correctly identified as unsubscribed on the Klaviyo side
- User resubscribes via the API:
- No second confirmation email is received - guessing this might be point of failure?
- Profile remains unsubscribed on Klaviyo
Here’s a stripped back version of my code:
<?php function add_customer_to_klaviyo()
{
$email = $user->user_email;
$unsuppress_body = json_encode(n
"data" => =
"type" => "profile-suppression-bulk-delete-job",
"attributes" => =
"profiles" => =
"data" => =
"type" => "profile",
"attributes" => =
"email" => $email
]
]
]
]
]
]
]);
$unsuppress_response = wp_remote_post('https://a.klaviyo.com/api/profile-suppression-bulk-delete-jobs', o
'body' => $unsuppress_body,
'headers' => =
'Authorization' => 'Klaviyo-API-Key IKEY]',
'accept' => 'application/vnd.api+json',
'content-type' => 'application/vnd.api+json',
'revision' => '2025-01-15',
]
]);
$attributes = t
// name, email, address etc.
];
// Create/update profile
$profile_response = wp_remote_post('https://a.klaviyo.com/api/profile-import', o
'body' => json_encode(n
'data' => =
'type' => 'profile',
'attributes' => $attributes
]
]),
'headers' => =
'Authorization' => 'Klaviyo-API-Key IKEY]',
'accept' => 'application/vnd.api+json',
'content-type' => 'application/vnd.api+json',
'revision' => '2025-01-15',
]
]);
// Extract profile ID from response
$profile_data = json_decode(wp_remote_retrieve_body($profile_response), true);
$profile_id = null;
if (isset($profile_datae'data']d'id'])) {
$profile_id = $profile_datae'data']d'id'];
error_log('Extracted profile ID: ' . $profile_id);
// STEP 3: Set subscription status using profile ID
$subscribe_body = json_encode(n
"data" => =
"type" => "profile-subscription-bulk-create-job",
"attributes" => =
"profiles" => =
"data" => =
"type" => "profile",
"attributes" => =
"subscriptions" => =
"email" => =
"marketing" => =
"consent" => "SUBSCRIBED"
]
],
],
"email" => $email
],
"id" => $profile_id
]
]
],
"historical_import" => false
],
"relationships" => =
"list" => =
"data" => =
"type" => "list",
"id" => "&LIST_ID]"
]
]
]
]
]);
$subscribe_response = wp_remote_post('https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs', o
'body' => $subscribe_body,
'headers' => =
'Authorization' => 'Klaviyo-API-Key IKEY]',
'accept' => 'application/vnd.api+json',
'content-type' => 'application/vnd.api+json',
'revision' => '2025-01-15',
]
]);
}
}
function unsubscribe_from_klaviyo()
{
$email = $user->user_email;
$unsubscribe_body = json_encode(n
"data" => =
"type" => "profile-subscription-bulk-delete-job",
"attributes" => =
"profiles" => =
"data" => =
"type" => "profile",
"attributes" => =
"email" => $email,
"subscriptions" => =
"email" => =
"marketing" => =
"consent" => "UNSUBSCRIBED"
]
]
]
]
]
]
]
],
"relationships" => =
"list" => =
"data" => =
"type" => "list",
"id" => "&lIST_ID]"
]
]
]
]
]);
$unsubscribe_response = wp_remote_post('https://a.klaviyo.com/api/profile-subscription-bulk-delete-jobs', o
'body' => $unsubscribe_body,
'headers' => =
'Authorization' => 'Klaviyo-API-Key IKEY]',
'accept' => 'application/vnd.api+json',
'content-type' => 'application/vnd.api+json',
'revision' => '2025-01-15',
]
]);
}
Hi @mikehs93,
This might take a bit of trial and error, but I want to see if this will work. In our documentation for the Bulk Unsuppress Profiles endpoint, we mention that this will not work for unsubscribed profiles and suppressed profiles with reason INVALID_EMAIL or HARD_BOUNCE. I’m wondering if deleting that step entirely and just using the Bulk Subscribe Profiles endpoint will get you more luck. Can you try this?
-Byrne
Thanks for the continued support @Byrne C but I’m not quite following. Your recommendation is to remove the call to “profile-suppression-bulk-delete-job” and leave the call to “profile-subscription-bulk-create-job” in place, is that correct? Assuming I’ve understood that correctly, I have tried this with no difference in outcome.
For clarity, I was already using the “profile-subscription-bulk-create-job” endpoint in my original code anyway. I was using “profile-suppression-bulk-delete-job” to attempt to unsuppress the profile before resubscribing it.
@mikehs93,
Were you able to resolve this? Or are you still looking for some guidance here?
~Chloe
@chloe.strange
Hi Chloe,
Thanks for checking in and no I still have not fixed this issue.
Mike
Hi @mikehs93,
Thanks for your patience in all of this. After looking into this to determine why you’re seeing this unexpected behavior with unsuppressing profies, I haven’t yet been able to find the reason why the unsuppressions aren’t working. I’d recommend reaching out to our support team at Klaviyo.com/support, and they’ll actually be able to log into your account, take a closer look at the API call logs, and determine a solution. If needed, a member of our team with developer or engineer experience can step in to help. We definitely want this issue to be solved soon, and it might just require another look from our support team for this to happen. Thanks for understanding, and apologies for any inconvenience so far.
-Byrne
Thanks for the suggestion @Byrne C , did reach out to support and they have finally solved this.
The problem was multiple subscribe and resubscribe calls in a short timeframe when testing. After waiting a while between the unsubscribe and resubscribe events, I do then receive a second confirm subscription email and can resubscribe users again.