APIs & Integrations

turner_bass
Participant

Viewing the subscription types a contact is subscribed to

How can I tell that a user is subscribed to an email subscription via the API? For example, I know that this is the returned object when I view the subscription status for a contact:

{
    "subscribed": false,
    "markedAsSpam": false,
    "portalId": 62515,
    "bounced": false,
    "email": "jerry@example.org",
    "subscriptionStatuses": [],
    "status": "unsubscribed"
}

But how do I know which specific subscriptions they are a part of? It would seem like the subscriptionStatuses property would contain all of the subscriptions and the contact's subscription state for each. However, when I have subscribed a contact to one of my subs, this property is not updated. I can also see that the API log on my custom integration shows a 200 response.

The subscribed property on this object has been set to true but there still aren't any statuses.

Is there something else I need to be doing?

4 Replies 4
turner_bass
Participant

Viewing the subscription types a contact is subscribed to

This helped, but something that I think is worth pointing out (which I just noticed) is that my request payload had the contract names incorrect and I still got a 200 OK response back. That was the cause for most of my confusion. Here's my integration's request:

{
   "SubscriptionStatuses" : [
      {
         "Id" : 5359532,
         "Subscribed" : true,
         "OptInState" : "OPT_IN"
      }
   ]
}

I still received

{
   "success" : true
}
0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

Viewing the subscription types a contact is subscribed to

Hi @turner.bass, as per the docs, "A null value in this circumstance signifies a contact whose subscription preferences have never been changed, and therefore are not opted out of that type."

If a contact's subscription status has never changed, the subscriptionStatuses property array would be blank. If the contact updates their subscription status to elect to receive only one or a few email subscription types, the definition will be returned. If the value is null for a specific type, nothing will be returned.

0 Upvotes
turner_bass
Participant

Viewing the subscription types a contact is subscribed to

Okay I see. There is actually something wrong with my integration. I tested again calling the API endpoint directly and saw the correct data. My problem was in the call to subscribe the contact. This was helpful though! Thank you

cbarley
HubSpot Alumni
HubSpot Alumni

Viewing the subscription types a contact is subscribed to

No prob Turner! Glad to help

0 Upvotes