APIs & Integrations

saar1
Member

Retrieving emails list with an API call

Hi,
I’d like to get a list of all emails in my HS system.
I’d like to have the following information (for each mail):
mail_name total_received total_opened
"Don’t miss it!" 20 10
"last chance!" 15 8

After that i’d like to retrieve a list of mails and the users it was sent to:
mail_name sent_to
"Don’t miss it!" michael@test.com
"last chance!" david@test.com
"last chance!" jeff@test.com

Later i will join the two tables on my end.
Any ideas how can i do that? any help will be appreciated

Tnx a lot!

0 Upvotes
7 Replies 7
saar1
Member

Retrieving emails list with an API call

The two tables didn’t come out good. Hope this will clarify:

       **mail_name**     |    **total_received**    |    **total_opened**
      "Don't miss it!"   |      20                 |          10
      "last chance!"     |      15                 |        8

mail_name | sent_to
"Don’t miss it!" | michael@test.com
"last chance!" | david@test.com
"last chance!" jeff@test.com

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Retrieving emails list with an API call

Hi @saar1

Most of that data can be exported from within HubSpot:

How do I export my overall email performance data?

Navigate to Content > Email and click Export at the top of the table list of emails.


Otherwise, if you’re looking to automate this report using the API, you can get that data using the Email Events API. You’d need to get the data from each email separately:

Email Events Overview | Email Events API

An overview of the Email Events API.



0 Upvotes
saar1
Member

Retrieving emails list with an API call

Hi @dadams
Tnx for getting back to me.
So AFA i undesrand, there’s no way of retrieving all of the emails information (like i can do with the export) with a single API call

0 Upvotes
saar1
Member

Retrieving emails list with an API call

@dadams
Also, I’ve followed this link you’ve shared with me:

How do I export my overall email performance data?

Navigate to Content > Email and click Export at the top of the table list of emails.

I would like to know how i can schedule a job that will export this list everyday to my mailbox. Is it possible?
Tnx for the help

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Retrieving emails list with an API call

@saar1 we don’t currently have a way to automate or schedule the export, so if you want to automate this you’d need to use the API.

If you get the data for a single campaign, you do get the overall sending stats for that campaign, so you wouldn’t need to pull all of the events to get those stats, but you would need to get each campaign separately:

Get campaign data for a given campaign | Email Events API

GET /email/public/v1/campaigns/:campaign_id

0 Upvotes
saar1
Member

Retrieving emails list with an API call

@dadams

  1. What API call do i need to use in order to retrieve the Exact same result as if i’d get if I manually did the export (Go to content -> Email -> Sent - > export ) ?

  2. If I have multiple campaigns associated with a single campaign, how can i get the ‘open’, ‘delivered’ information for each mail individually when using this API: Get campaign data for a given campaign
    How would i differentiate between the different emails within the given campaign in the JSON i receive?

Tnx for the help,
Saar

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Retrieving emails list with an API call

@saar1 there isn’t a single API call that will return the same data you’d get in the export; you’d need to get the data for the separate campaigns then aggregate that into the report.

For separate campaigns for a single email, you’ll want to group the data by the contentId that you’d get when pulling the campaign data. The contentId represents the ID of the email that you’d see in the HubSpot app, since you may end up with multiple campaigns if you have separate sends for the same email.

0 Upvotes