Get emails sent to contacts associated with a deal

I’m trying to extract, through the API endpoint /crm/v3/objects/emails, one-on-one sales emails sent to contacts that are associated with a deal. I would also like, if possible, to filter on date ranges. Alternatively choose a pagination order that allows me to extract the latest X days.

I’m receiving the emails, with info and all, but I’m not sure how to get the “contact must be associated with a deal” correctly, or the date range.

Note, I’m not trying to extract marketing emails. Only one-on-one emails.

Hi, @DWesterholm :waving_hand: Thanks for your question. You’ve hit upon a limitation. You’ll need to look at breaking this up into multiple calls.

The endpoint you are referring to lacks the filtering capabilities you want, as you noted. And the Search API endpoints can do some-but-not-all of this, namely handling returning the associations in a single call while filtering the way you want or need to filter.

Ideas for workarounds might include:

  • Use a two-step approach: first, get the contacts associated with a deal, and then use those contact IDs to filter emails
  • Filter the results client-side by iterating over the returned data and only including those emails that fall within the needed date range(s)
  • Create a back-end process that aggregates this data over time, updating a data store with relevant emails and contacts

These all add layers of complexity and are not as straightforward as a single API call with a simple filter parameter.

Best,

Jaycee

Sounds like this should work, I’ll try it. Thanks!