We’re using the JSON:API method to subscribe/unsubscribe users.
We store a “wants_email_updates” flag in our database, and when the user changes this value we either subscribe them, or unsubscribe them.
We have a list set up in Klaviyo that is single opt-in.
We subscribe them with a payload similar to:
$this->request('POST', '/profile-subscription-bulk-create-jobs', [
'data' => [
'type' => 'profile-subscription-bulk-create-job',
'attributes' => [
'profiles' => [
'data' => [
[
'type' => 'profile',
'attributes' => [
'email' => $email,
'subscriptions' => [
'email' => [
'marketing' => [
'consent' => 'SUBSCRIBED',
'consented_at' => now()->toJSON(),
],
],
],
],
],
],
],
],
'relationships' => [
'list' => [
'data' => [
'type' => 'list',
'id' => $this->listId,
],
],
],
],
]);
Then we unsubscribe them via a payload similar to:
$this->request('POST', '/profile-subscription-bulk-delete-jobs', [
'data' => [
'type' => 'profile-subscription-bulk-delete-job',
'attributes' => [
'profiles' => [
'data' => [
[
'type' => 'profile',
'attributes' => [
'email' => $email,
],
],
],
],
],
'relationships' => [
'list' => [
'data' => [
'type' => 'list',
'id' => $this->listId,
],
],
],
],
]);
However, once the user unsubscribes from the list via our UI, It globally suppresses them.
So if we call our “subscribe” function again using the request above, it doesn’t seem to do anything.
But I can go into the klaviyo UI and manually resubscribe them to the list via using the button provided.
How can we automatically resubscribe users via the JSON:API who have previously opted out and now want to opt in?
Thanks