APIs & Integrations

EBHamer
Member

Dynamic list creation via the API

I am trying to create a dynamic list via the API.  I have done this successfully in the past.  In this case, I would like to exclude all contacts that have the "Unsubscribed from all email" property set.  The JSON I am using is this:

 

{
"operator": "IS_EMPTY",
"property": "hs_unsubscribed_from_all_email",
"filterFamily": "Email",
"type": "string"
}

 

but it is generating an error.  What is the correct JSON in this case?

 

Thanks,

 

Eric Hamer

0 Upvotes
1 Reply 1
WendyGoh
HubSpot Employee
HubSpot Employee

Dynamic list creation via the API

Hey @EBHamer,

 

The internal value for contact property - Unsubscribed from all email is hs_email_optout, as such, could you try using this internal value and try POST contacts/v1/lists, with the following POST body

{
    "name": "tweeters",
    "dynamic": true,
    "portalId": portalId,
    "filters": 
    [
        [{
"operator": "IS_EMPTY",
"property": "hs_email_optout",
"filterFamily": "Email",
"type": "string"
}]
    ]
}
   

and see if it works?

 

If it doesn't, could you share with me the error that you're seeing on your end?

 

0 Upvotes