APIs & Integrations

JSixsmith
Member

Get all emails for a ticket

SOLVE

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:

 

Screen Shot 2023-08-04 at 09.57.45 am.png

0 Upvotes
1 Accepted solution
coldrickjack
Solution
Guide

Get all emails for a ticket

SOLVE

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.

View solution in original post

0 Upvotes
3 Replies 3
coldrickjack
Solution
Guide

Get all emails for a ticket

SOLVE

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.

0 Upvotes
JSixsmith
Member

Get all emails for a ticket

SOLVE

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

 

Thanks you!!!

coldrickjack
Guide

Get all emails for a ticket

SOLVE

No problem at all! 😊

0 Upvotes