How to opt a contact out of email via API by using C#


#1

How to unsubscribe a contact by using HubSpot API in C#?

Thanks,
Stephen


#2

I too am interested in this information.

Thanks,
Johnson


#3

Hey all,

You can unsubscribe contacts using the ‘Update email subscription status’ endpoint below. Keep in mind that this cannot be reversed.


#4

Hi Derek,
Does not seem like the unsubscribe API works as expected. I tried to unsubscribe a user using the below API. However, if I check the preferences, I see that the user is still subscribed. It worked yesterday for me.
Given below is the request:
http://api.hubapi.com/email/public/v1/subscriptions/micjohny@gmail.com?hapikey=d6b4fd6a-7b96-4c19-8e65-a933510edfc5

PUT http://api.hubapi.com/email/public/v1/subscriptions/micjohny@gmail.com?hapikey=<hapikey>
User-Agent: Fiddler
Host: api.hubapi.com
Content-Length: 114
{
    "subscriptionStatuses": [
        {
        "id": 1245662, "subscribed": false
    }
    ]
}


#5

The endpoint mentioned above is for specific subscription types. Sending a subscribed = false without a subscription ID returns an error. How does one do a general unsubscribe through the API?


#7

Hi @carrng,

This can be done by sending "unsubscribeFromAll": true in the body, as outlined in the example.


#8