Get all emails for a ticket

Hi, is there any endpoint or way to get a list of emails linked to a ticket? Like the one in the GUI? Like the screenshot below:

Hey @JSixsmith,

Yes, you can include a parameter “associations=emails” and include it when retrieving the ticket via the Tickets API. For instance if I had a ticket with ID “1606885847”. The request would be:

GET https://api.hubapi.com/crm/v3/objects/tickets/1606885847?associations=emails

This returns information about the ticket including an “associations” object which contains the IDs of all of the emails linked to the ticket. Example of this below:

"associations": {
 "emails": {
 "results": [
 {
 "id": "19317934782",
 "type": "ticket_to_email"
 },
 {
 "id": "19317934801",
 "type": "ticket_to_email"
 },
 {
 "id": "19318230762",
 "type": "ticket_to_email"
 }
 ]
 }

You can then use the IDs above to retrieve additional information about the emails. This is done using the Engagements API. So taking email with ID “19317934782” the request would be:

GET https://api.hubapi.com/crm/v3/objects/emails/19317934782?properties=hs_email_text
RESPONSE:
{
 "id": "19317934782",
 "properties": {
 "hs_createdate": "2023-08-04T09:07:28.284Z",
 "hs_email_text": "email 2",
 "hs_lastmodifieddate": "2023-08-04T09:07:28.284Z",
 "hs_object_id": "19317934782"
 },
 "createdAt": "2023-08-04T09:07:28.284Z",
 "updatedAt": "2023-08-04T09:07:28.284Z",
 "archived": false
}

You can also do this in batches if you are dealing with a larger number of emails.

Ah amazing, I was confused on the docs but thats so simple!

Thanks you!!!

No problem at all! :blush:

Question, is there a way to retrieve all of the emails that have been created since a specific date?
We have are implementing a process where we update a 3rd party app’s record with the information from the emails recieved in HubSpot. We have a custom field on the HubSpot ticket record that stores when we last processed the emails. We then want to retrieve all of the emails recieved since that point in time and process them. We then update the above mentioned date with the date of the created date of the last received record. Given that there can be numerous back and forth emails. Having to retrieve each email, one at a time, and compare them to the last processing date, can become very inefficient.