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