Export Tickets With Associated Email Activity

Which developer APIs will get me the Ticket and its associated emails with content exported?
Even this can be achieved with a combination of API calls that is alright. I just need to know the logical steps for calling the APIs and getting an export of emails associated with tickets.

Hi @stephen-msc,
Thank you for asking the Community!
I checked for you and I found these resources that might help you:
- Exports: Use the exports API to export records and property data from your HubSpot account
- The post from @johnelmer on this similar post “Exporting Timeline Activities”
- The post from @dennisedson on this post “Getting all associated activities to a Ticket”
I also wanted to invite a couple of subject matter experts to this conversation: Hi @zach_threadint, @mangelet and @Teun do you have suggestions to help @stephen-msc, please?
Also, if anybody else has anything to add and/or share, please feel free to join in the conversation :slightly_smiling_face:
Thanks a lot and have a great day!
Best,
Bérangère

Hi @stephen-msc :waving_hand:

Looks like there may be some 3rd party solutions that could help you achieve this (as per posts linked by @BérangèreL).

If you need/want to retrieve this data yourself via API, it’d be helpful if you’d clarify your use case a little. Specifically, are you interested in retrieving data for a specific Ticket (or batch of Tickets), or do you need to retrieve all Tickets (or maybe a certain subset of Tickets based on a search criteria)? This will help the community put together an example solution for you.

Hi Zach,
Thanks for reaching out to help with my problem.
Here is what I am looking to achieve …
I want to export tickets beloging to a couple of pipelines (eg. Production, Editorial Assistant) and with the ticket I want to get the associated email data (sender, receiver, email content, email date). If this cannot be achieved in one API call, I can write a script to iterate over a bunch of tickets and get the associate email data.
I have tried the folloiwng APIs -
For Tickets …
# GET /crm/v3/objects/tickets
# GET /crm/v3/objects/tickets/{ticketId}
For Emails …
# GET /crm/v3/objects/emails
# GET /crm/v3/objects/emails/{emailId}
I was hoping the last API endpoint with {emailId} would return the email content. But, that is not the case. Unless, there is some parameter that needs to be set to get the API to return email content as well.
So, using these APIs I am getting some properties but not the actual email content.
Basically what I need is an exported list of -
Ticket ID, Ticket Date, Associated Email(s) [Date, Sender, Receiver, Subject, Body]
Also, tried the ‘Export’ option within Hubspot Ticket list to get the associated emails with content. But, this also does not come in the exported data.
Hope this helps you get a better understanding of what I am looking for.
Appreciate your help and time.
Thanks.

Hi @stephen-msc :waving_hand:

I see, thanks for clarifying what you’re trying to achieve.

When using HubSpot’s GET {Object Type} API endpoints, you need to specify within a query string parameter which “properties” (i.e. data fields) you would like to be returned.

In order to do this, you’ll first need to find the internal property names for each of your target properties. You can find these internal property names within HubSpot’s UI > Settings > Data Management > Properties (for most properties) and via the Properties API (for all properties). For example:

GET /crm/v3/objects/EMAILS?properties=hs_email_html,hs_email_text&limit=100

Example response

{
 "results": [
 {
 "id": "23358886364",
 "properties": {
 "hs_createdate": "2024-01-11T05:10:54.131Z",
 "hs_email_html": "<div style=\"\" dir=\"auto\" data-top-level=\"true\"><p style=\"margin:0;\">test email</p></div>",
 "hs_email_text": "test email",
 "hs_lastmodifieddate": "2024-01-19T02:18:32.202Z",
 "hs_object_id": "23358886364"
 },
 "createdAt": "2024-01-11T05:10:54.131Z",
 "updatedAt": "2024-01-19T02:18:32.202Z",
 "archived": false
 }
 ]
}

You can see in the response the properties I requested in the “properties” query string parameter (hs_email_html and hs_email_text).

I hope that proves helpful. Please let me know if you have any follow-up questions.