# threadId in Inbox and messages API

**URL:** <https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [August 11, 2022, 8:29am UTC](https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790 "2022-08-11T08:29:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TraceTheStar](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@TraceTheStar](https://community.hubspot.com/u/TraceTheStar)\
**Post date:** [August 11, 2022, 8:29am UTC](https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790/1 "2022-08-11T08:29:55Z")

</div>

Hi, fellow Developers.

I need to export all the messages inside my Inbox threads and since I don’t see any quick button for exporting, I assume that we don’t have this feature in the normal hubspot menu. So as a result, after scouring the internet for a while. I found the documentation for accessing the Inbox API. However, I got stuck on the section where I need have the threadId in order to get into the messages inside my thread. So, I would like to know where I can find this `threadId`. I cannot seem to find it as I have tried all the other IDs from response of the /conversations/thread url API.

Any help will be greatly appreciated! Thanks!

Best,

TraceTheStar

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 11, 2022, 11:55pm UTC](https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790/2 "2022-08-11T23:55:10Z")

</div>

Hi, @TraceTheStar 👋 This one is a bit of an adventure for sure. Fortunately, everything we need is in the [Conversations inbox and messages APIs (BETA).](https://developers.hubspot.com/docs/api/conversations/conversations)

Our clue was down the page a bit _“When you make a successful request, **the response will include the thread ID** , which you can use to retrieve, update, or create a new message in a thread.”_ [Retrieve threads.](https://developers.hubspot.com/docs/api/conversations/conversations#threads-messages)

My quick test is likely different than you, but I think the underlying approach will get what you are after.

Request 1 — Get threadId

`GET /conversations/v3/conversations/threads`

The response includes a property called id which is actually the threadId in this case

 ![threadId.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/9/95a5295c1c92d656a7dbc7a9fd96024b0f70bcdb.png)

My request

```lia-code-sample
curl --request GET \
 --url https://api.hubapi.com/conversations/v3/conversations/threads \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

```

My response

```lia-code-sample
HTTP 200

{
 "results": [
 {
 "id": "3016120935",
 "createdAt": "2022-08-11T23:26:58.904Z",
 "status": "OPEN",
 "latestMessageTimestamp": "2022-08-11T23:28:36.188Z",
 "latestMessageSentTimestamp": "2022-08-11T23:28:36.188Z",
 "latestMessageReceivedTimestamp": "2022-08-11T23:26:58.969Z",
 "assignedTo": "A-10233975",
 "spam": false,
 "inboxId": "124212669",
 "associatedContactId": "551",
 "archived": false
 },
 {
 "id": "3016291208",
 "createdAt": "2022-08-11T23:23:48.172Z",
 "status": "OPEN",
 "latestMessageTimestamp": "2022-08-11T23:23:54.489Z",
 "latestMessageReceivedTimestamp": "2022-08-11T23:23:54.489Z",
 "spam": false,
 "inboxId": "124212669",
 "associatedContactId": "1",
 "archived": false
 },
 {
 "id": "3016313742",
 "createdAt": "2022-08-11T23:24:36.472Z",
 "closedAt": "2022-08-11T23:25:46.568Z",
 "status": "CLOSED",
 "latestMessageTimestamp": "2022-08-11T23:24:36.689Z",
 "latestMessageReceivedTimestamp": "2022-08-11T23:24:36.689Z",
 "assignedTo": "A-10233975",
 "spam": false,
 "inboxId": "124212669",
 "associatedContactId": "1",
 "archived": false
 }
 ],
 "paging": {
 "next": {
 "after": "MzAxNjMxMzc0Mg%3D%3D",
 "link": "https://api.hubapi.com/conversations/v3/conversations/threads?hs_static_app=endpoint-reference-ui&hs_static_app_version=1.974&after=MzAxNjMxMzc0Mg%3D%3D"
 }
 }
}

```

Request 2 — Get messageId

We can take the value for “id”: “3016120935” and get the associated messages from this endpoint:

`GET /conversations/v3/conversations/threads/{threadId}/messages`

My request

```lia-code-sample
curl --request GET \
 --url https://api.hubapi.com/conversations/v3/conversations/threads/3016120935/messages \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

```

My response

```lia-code-sample
HTTP 200

{
 "results": [
 {
 "id": "d3295feca7814dc0806ae1c96636d705",
 "createdAt": "2022-08-11T23:28:36.188Z",
 "updatedAt": "2022-08-11T23:28:36.188Z",
 "createdBy": "A-10233975",
 "client": {
 "clientType": "HUBSPOT"
 },
 "senders": [
 {
 "actorId": "A-10233975"
 }
 ],
 "recipients": [
 {
 "actorId": "V-551",
 "deliveryIdentifiers": []
 }
 ],
 "channelId": "1000",
 "channelAccountId": "79569651",
 "archived": false,
 "text": "this is a test",
 "richText": "<div style=\"text-align: left\">this is a test</div>",
 "attachments": [],
 "truncationStatus": "NOT_TRUNCATED",
 "status": {
 "statusType": "SENT"
 },
 "direction": "OUTGOING",
 "type": "MESSAGE"
 },
 {
 "id": "56b8f95f373149afa3cffaf6dddf1825",
 "createdAt": "2022-08-11T23:28:10.344Z",
 "updatedAt": "2022-08-11T23:28:10.344Z",
 "createdBy": "A-10233975",
 "client": {
 "clientType": "HUBSPOT"
 },
 "senders": [
 {
 "actorId": "A-10233975"
 }
 ],
 "recipients": [
 {
 "actorId": "V-551",
 "deliveryIdentifiers": []
 }
 ],
 "channelId": "1000",
 "channelAccountId": "79569651",
 "archived": false,
 "text": "hello",
 "richText": "<div style=\"text-align: left\">hello</div>",
 "attachments": [],
 "truncationStatus": "NOT_TRUNCATED",
 "status": {
 "statusType": "SENT"
 },
 "direction": "OUTGOING",
 "type": "MESSAGE"
 },
 {
 "id": "4a41191f2a0d406ebb208e06f42559b3",
 "createdAt": "2022-08-11T23:27:57.101Z",
 "updatedAt": "2022-08-11T23:27:57.101Z",
 "createdBy": "A-10233975",
 "client": {
 "clientType": "HUBSPOT"
 },
 "senders": [
 {
 "actorId": "A-10233975"
 }
 ],
 "recipients": [
 {
 "actorId": "V-551",
 "deliveryIdentifiers": []
 }
 ],
 "channelId": "1000",
 "channelAccountId": "79569651",
 "archived": false,
 "text": "hellp",
 "richText": "<div style=\"text-align: left\">hellp</div>",
 "attachments": [],
 "truncationStatus": "NOT_TRUNCATED",
 "status": {
 "statusType": "SENT"
 },
 "direction": "OUTGOING",
 "type": "MESSAGE"
 },
 {
 "id": "75dd0ade-60ca-4952-a49b-fc8fa94f7f92",
 "createdAt": "2022-08-11T23:26:59.661Z",
 "createdBy": "S-hubspot",
 "client": {
 "clientType": "SYSTEM"
 },
 "senders": [],
 "recipients": [],
 "archived": false,
 "assignedTo": "A-10233975",
 "type": "ASSIGNMENT"
 },
 {
 "id": "1c83f851-4814-4ce5-93b2-ef17b54ac339",
 "createdAt": "2022-08-11T23:26:59.621Z",
 "createdBy": "S-hubspot",
 "client": {
 "clientType": "SYSTEM"
 },
 "senders": [],
 "recipients": [],
 "archived": false,
 "newStatus": "OPEN",
 "type": "THREAD_STATUS_CHANGE"
 },
 {
 "id": "7c5bbeb0801f455c95b3e6fd85cc7d3d",
 "createdAt": "2022-08-11T23:26:58.969Z",
 "updatedAt": "2022-08-11T23:26:58.969Z",
 "createdBy": "V-551",
 "client": {
 "clientType": "SYSTEM"
 },
 "senders": [
 {
 "actorId": "V-551"
 }
 ],
 "recipients": [],
 "channelId": "1000",
 "channelAccountId": "79569651",
 "archived": false,
 "text": "Hello",
 "richText": "<div>Hello</div>",
 "attachments": [],
 "truncationStatus": "NOT_TRUNCATED",
 "status": {
 "statusType": "RECEIVED"
 },
 "direction": "INCOMING",
 "type": "MESSAGE"
 },
 {
 "id": "e5a4bc4685d74194becd81f8fdc03748",
 "createdAt": "2022-08-11T23:26:58.967Z",
 "createdBy": "S-hubspot",
 "client": {
 "clientType": "SYSTEM"
 },
 "senders": [
 {
 "actorId": "S-hubspot"
 }
 ],
 "recipients": [
 {
 "actorId": "V-551",
 "deliveryIdentifiers": []
 }
 ],
 "channelId": "1000",
 "channelAccountId": "79569651",
 "archived": false,
 "text": "Got any questions? I'm happy to help.",
 "type": "WELCOME_MESSAGE"
 }
 ],
 "paging": {
 "next": {
 "after": "MTY2MDI2MDQxODk2Ny0w",
 "link": "https://api.hubapi.com/conversations/v3/conversations/threads/3016120935/messages?hs_static_app=endpoint-reference-ui&hs_static_app_version=1.974&after=MTY2MDI2MDQxODk2Ny0w"
 }
 }
}

```

Essentially, you’ll need one call to get the threadIds and a second to get the messageIds. With that information, you can follow the documentation to [retrieve messages](https://developers.hubspot.com/docs/api/conversations/conversations#retrieve-messages).

Have fun coding! – Jaycee

---

<div class="post-metadata">

**Author:** ![TraceTheStar](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@TraceTheStar](https://community.hubspot.com/u/TraceTheStar)\
**Post date:** [August 12, 2022, 1:35am UTC](https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790/3 "2022-08-12T01:35:31Z")

</div>

Hi Jaycee!

Thank you very much for replying very quickly. I though that there should have been a variable with the name `threadId` in the response. I actually did use the `id` parameter that you state in your answer above, but I also included the ‘{}’ symbols which made mine look like this `/{123456789}/ 🤦‍♀️. So, fortunately I was very close to it, but unfortunately didn’t think of taking the curved braces away 😅. Anyway, thank you very much! Really appreciate the fast response!

Best,

TraceTheStar

---

<div class="post-metadata">

**Author:** ![JoshBodine](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/joshbodine/32/28756_2.png) [@JoshBodine](https://community.hubspot.com/u/JoshBodine)\
**Post date:** [June 30, 2023, 12:06am UTC](https://community.hubspot.com/t/threadid-in-inbox-and-messages-api/62790/4 "2023-06-30T00:06:38Z")

</div>

Jaycee,

Once I get the Message ID from a thread, is there any way yet to associate that message to a deal? I tried using the Associations API, but it seems that the ID that gets returned for a given message on a thread is a GUID and the Associations API is expecting a number. It seems as if there is an Email ID and a Message ID that are different and not sure how they correlate.
