APIs & Integrations

lynton
Contributor | Elite Partner
Contributor | Elite Partner

Get Email Events Timestamp filters not working

We are trying to query historical email events from last year. We’re making the following request:

https://api.hubapi.com/email/public/v1/events?startTimestamp=1477872000000&endTimeStamp=147804480000...

Instead of returning events within the range of the requested timestamps (10/31-11/2/16), the API is returning events with a created date of 4/27/17. This is concerning because we’re dealing with a fairly large (100k+) database with a lot of email activity, and we don’t want to do 6 months worth of paging just to get the events we’re looking for. Is this expected behavior from the API?

0 Upvotes
6 Replies 6
lynton
Contributor | Elite Partner
Contributor | Elite Partner

Get Email Events Timestamp filters not working

@pmanca you are right about that! It’s working with the correct url params, startTimestamp and endTimestamp.

Do you think the documentation is misleading? I spoke to two other integration vendors who were wrapping these APIs with different workarounds thinking that either the recipient or campaign id were required:

Events can be looked up in bulk using either ‘recipient’ or both ‘appId’ and ‘campaignId’, and optionally any combination of the above properties, via this endpoint.
-https://developers.hubspot.com/docs/methods/email/email_events_overview

Thanks again for your help troubleshooting. It’s great to know we can use the start/end timestamps without other url filters.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Get Email Events Timestamp filters not working

@lynton What do you think would be a clearer way of stating it? I would be happy to update the docs if it can help clarify how certain endpoints can be used.

0 Upvotes
lynton
Contributor | Elite Partner
Contributor | Elite Partner

Get Email Events Timestamp filters not working

@pmanca thanks for the quick response. We have no problem paging through the records, but if we have to do 6 months of paging just to find the data we need, it’s a lot of wasted API calls that could be saved by a proper date filter.

I found a discrepancy in the api docs. On https://developers.hubspot.com/docs/methods/email/email_events_overview: “Events can be looked up in bulk using either ‘recipient’ or both ‘appId’ and ‘campaignId’, and optionally any combination of the above properties, via this endpoint.”

But then on the get_events page (https://developers.hubspot.com/docs/methods/email/get_events), the only "required parameter’ is the oauth token, which leads developers to believe all other parameters are optional. Hence why we were expecting the date filtering to work in our example.

Here’s the problem with making the campaign ID required in the get_events endpoint: there’s no way to get campaigns by date. Even the campaign payload has no date field telling us when the campaign was created, sent, updated, etc. The timestamps all come back empty.

So with the current API design, the only way to get email events within a date range is to first page through every email campaign, then call get_events with the campaign id and date filters. Can this be improved?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Get Email Events Timestamp filters not working

@lynton I was able to reproduce the issue on my end and I have notified our internal Engineering team(about the date filtering not working). I will let you know when this is resolved.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Get Email Events Timestamp filters not working

@lynton The issue with your call is that you have a capital ‘S’ which needs to be a lowercase ‘s’ in timestamp.

it should be written as below:
https://api.hubapi.com/email/public/v1/events?startTimestamp=1477872000000&endTimestamp....

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Get Email Events Timestamp filters not working

@lynton The fact that it is returning emails out side of the time scope doesn’t seem right to me. i’ll write down an action item for me tomorrow to test that out on my end.

As for the paging it is really the only way to do it from our end. If we tried to send everything over in 1 network call you would get a timeout and not get any information. We have to keep the payload size to a reasonable limit to ensure a reliable endpoint/API

0 Upvotes