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

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

Thanks,
Stephen

I too am interested in this information.

Thanks,
Johnson

Hey all,

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

Update email subscription status for an email address | Email API

PUT /email/public/v1/subscriptions/:email_address

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
 }
 ]
}

[

HupSpot_Email_Unsubscribe_Issue_1.png1284x776 42.1 KB

](https://community.hubspot.com/legacyfs/online/uploads/default/original/2X/0/011336239dcdd04540c1e756ff6aec491ffd62ed.png)

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?

Hi @carrng,

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