Email API says "You cannot subscribe an unsubscribed address.",


#1

I am trying to subscribe users after site registration but I am having difficulty with the API.

I use this API to update the user https://developers.hubspot.com/docs/methods/email/update_status

Right after the user signs up, I submit an HTTP request with the JSON BODY:

`"subscriptionStatuses" => array( array(
"id" => SUB_ID, // Subscription ID.
"subscribed" => 'true', 
"legalBasis" => "PERFORMANCE_OF_CONTRACT",
"optState" => 'OPT_IN',
"legalBasisExplanation" => "We need to send them these emails as part of our agreement with them.") )`

The request body response the following message You cannot subscribe an unsubscribed address.

So, I switch the subscribed value to false and the response returns 'success:true' and I can see the user's subscription under 'Communication subscriptions' but on the timeline it says 'Unsubscribed from the NAME_OF_SUBSCRIPTION communication subscription'

This is throwing me for a loop and I have a few questions

  1. What is the purpose of the ‘subscribe’ key? What should it be set to when subscribing a user for the first time?
  2. Is there another request I should submit before to not receive this error 'You cannot subscribe an unsubscribed address.'?

#2

Hi @kailanw,

That error will occur if you're trying to subscribe an email address that has explicitly unsubscribed. If HubSpot receives an explicit unsubscribe (either from a contact, in-app, or via the API) then the email address is not allowed to be re-subscribed via the API in order to prevent abuse. You shouldn't see this issue for all email addresses; it should only affect the email addresses that are explicitly opted out.

To try and address your specific questions:

  1. The subscribed key represents whether you're subscribing or unsubscribing the email address to a particular subscription type (denoted by the included id).
  2. In general, no; you should only see that error when the email address in question has already been unsubscribed. If you can give me some specific examples (either contact records in HubSpot, or your Hub ID and an example email address) I'd be happy to dig into this further.

#3

Thank you for your reply and the clarification on certain things.

During my initial tests, the moment a contact is created then the update_status is used and that is where the error message is returned.

This is a user that was added with the "subscribed" value set to false https://app.hubspot.com/contacts/470774/contact/193285792/?interaction=note

This is an example of a new contact that should not have ever been unsubscribed so my expectation is that if I set the "subscribed" option to true then they should be subscribed for the first time.

https://app.hubspot.com/contacts/470774/contact/193343848/


#4

Hi @kailanw,

Keep in mind that subscription status is tied to an email address, not a contact; if a contact unsubscribes and is later deleted, re-creating that contact will not change the subscription status of the email address.

That said, both of the contacts you linked appear to have been deleted; do you have other examples?