APIs & Integrations

ARobson8
Member

Check ticket status associated with contact id returning 429

SOLVE

Hello, I'm facing a status 429 issue when checking the status of tickets associated with a contact via the API. I need to return only the open ticket associated with a phone number, if any.

I couldn't find a way in the HubSpot API to return only the ID of the ticket associated with a contact id that is open on the platform. The only way I could find to do this is to query all tickets (open or closed) associated with a contact's ID. The problem is that if the contact has many closed tickets, I need to send several requests to the hubpost api individually passing the ticket id associated with a contact to check the hs_pipeline_stage of each of these tickets to verify if the ticket is open, but if I send more than 10 requests within 1 second, I am temporarily banned by the hate limit with the following response in the request:

data: {
status: 'error',
message: 'You have reached your ten_secondly_rolling limit.',
errorType: 'RATE_LIMIT',
correlationId: '2507e73d-4339-4705-83ee-dc446341d6a9',
policyName: 'TEN_SECONDLY_ROLLING',
groupName: 'publicapi:private_app-api-calls-ten-secondly:3595377:44357029' }


Here is the flow of my nodejs api to search for an open ticket in hubspot:

First I return all tickets associated with a contact's id:

Request:
curl --location 'https://api.hubapi.com/crm/v3/objects/contacts/109384404784/associations/tickets'

Response:
{
"results": [
{
"id": "21848207900",
"type": "contact_to_ticket"
},
{
"id": "21848535583",
"type": "contact_to_ticket"
}
]
}

Then I need to query each ticket id to check the value of hs_pipeline_stage

Request:
curl --location 'https://api.hubapi.com/crm/v3/objects/tickets/21848535583'

Response:
{
"id": "21848535583",
"properties": {
"content": null,
"createdate": "2025-03-28T12:17:33.566Z",
"hs_lastmodifieddate": "2025-03-28T12:17:45.848Z",
"hs_object_id": "21848535583",
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_category": null,
"hs_ticket_priority": "HIGH",
"subject": "Test"
},
"createdAt": "2025-03-28T12:17:33.566Z",
"updatedAt": "2025-03-28T12:17:45.848Z",
"archived": false
}

How to return only the open ticket id associated with the contact id?

 
0 Upvotes
2 Accepted solutions
Jaycee_Lewis
Solution
Community Manager
Community Manager

Check ticket status associated with contact id returning 429

SOLVE

Hey, @ARobson8 👋 Have you already ruled out using the Search API? I know the pseudo-association options don't always work like folks expect, but in this case, we might be able to get you closer. You may need to build in an exponential backoff, regardless of what you end up using, but we can cross that bridge in the future. 

 

My quick test:

  • I have a test Contact Linda Belcher
  • I added 13 support tickets, but only 3 are "Open"
    CleanShot 2025-04-09 at 16.04.49@2x.png
  • I used the Search API
    https://api.hubapi.com/crm/v3/objects/tickets/search​

    Request body

    {
        "filterGroups": [
            {
                "filters": [
                    {
                        "propertyName": "associations.contact",
                        "operator": "EQ",
                        "value": "851"
                    },
                    {
                        "propertyName": "hs_pipeline",
                        "operator": "EQ",
                        "value": "0"
                    },
                    {
                        "propertyName": "hs_pipeline_stage",
                        "operator": "EQ",
                        "value": "1"
                    }
                ]
            }
        ],
        "sorts": [
            {
                "propertyName": "createdate",
                "direction": "DESCENDING"
            }
        ],
        "properties": [
            "hs_pipeline_stage",
            "subject",
            "content"
        ],
        "limit": 10
    }
  • Response returned only the three "Open" Tickets
    {
        "total": 3,
        "results": [
            {
                "id": "22271987324",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:58:36.500Z",
                    "hs_lastmodifieddate": "2025-04-09T21:58:42.910Z",
                    "hs_object_id": "22271987324",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr14"
                },
                "createdAt": "2025-04-09T21:58:36.500Z",
                "updatedAt": "2025-04-09T21:58:42.910Z",
                "archived": false
            },
            {
                "id": "22271986577",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:46:33.154Z",
                    "hs_lastmodifieddate": "2025-04-09T21:46:41.210Z",
                    "hs_object_id": "22271986577",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr13"
                },
                "createdAt": "2025-04-09T21:46:33.154Z",
                "updatedAt": "2025-04-09T21:46:41.210Z",
                "archived": false
            },
            {
                "id": "22285256561",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:46:07.084Z",
                    "hs_lastmodifieddate": "2025-04-09T21:46:11.076Z",
                    "hs_object_id": "22285256561",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr11"
                },
                "createdAt": "2025-04-09T21:46:07.084Z",
                "updatedAt": "2025-04-09T21:46:11.076Z",
                "archived": false
            }
        ]
    }​

It's not a perfect solution. For one, you'll need to either store the Contact's phone number as a custom Ticket property to have it returned in this response, since we are making a request to Tickets and not Contacts. 

 

Talk soon! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




View solution in original post

0 Upvotes
MichaelMa
Solution
Top Contributor

Check ticket status associated with contact id returning 429

SOLVE

Have you considered using Graphql? This seems like a great use-case for it since you can make your entire request with just 1 query.

 

query test {
  CRM {
    contact(uniqueIdentifier: "id", uniqueIdentifierValue: "12345") {
      associations {
        ticket_collection__contact_to_ticket(limit: 100) {
          items {
            hs_object_id
            subject
            hs_pipeline_stage
          }
        }
      }
    }
  }
}

 

You can also apply a filter to the ticket_collection if you only want a specific set of tickets.

View solution in original post

0 Upvotes
3 Replies 3
MichaelMa
Solution
Top Contributor

Check ticket status associated with contact id returning 429

SOLVE

Have you considered using Graphql? This seems like a great use-case for it since you can make your entire request with just 1 query.

 

query test {
  CRM {
    contact(uniqueIdentifier: "id", uniqueIdentifierValue: "12345") {
      associations {
        ticket_collection__contact_to_ticket(limit: 100) {
          items {
            hs_object_id
            subject
            hs_pipeline_stage
          }
        }
      }
    }
  }
}

 

You can also apply a filter to the ticket_collection if you only want a specific set of tickets.

0 Upvotes
ARobson8
Member

Check ticket status associated with contact id returning 429

SOLVE

I need to get the hs_pipeline_stage because I check in the client's custom statuses for tickets if there is a match with the ids to know if a ticket is open or closed. Here is an example:


Request executed only once to check the custom hs_pipeline_stage of the client crm :

curl --location 'https://api.hubapi.com/crm/v3/pipelines/tickets'

Response:
{
"results":[
{
"label":"24h Customer Service",
"displayOrder":0,
"id":"24955700",
"stages":[
{
"label":"New",
"displayOrder":0,
"metadata":{
"ticketState":"OPEN",
"isClosed":"false"
},
"id":"57851009",
"createdAt":"2023-02-10T22:10:19.334Z", "updatedAt":"2025-02-28T12:59:58.826Z",
"writePermissions":"CRM_PERMISSIONS_ENFORCEMENT",
"archived":false
},
{
"label":"Negotiation finished",
"displayOrder":1,
"metadata":{
"ticketState":"CLOSED",
"isClosed":"false"
},
"id":"1",
"createdAt":"2023-02-10T22:10:19.334Z",
"updatedAt":"2025-02-28T12:59:58.826Z",
"writePermissions":"CRM_PERMISSIONS_ENFORCEMENT",
"archived":false
}
],
"createdAt":"2025-01-29T19:28:15.574Z",
"updatedAt":"2025-01-29T19:29:39.346Z",
"archived":false
}
]
}

 

How to return only the open ticket id associated with the contact id?

0 Upvotes
Jaycee_Lewis
Solution
Community Manager
Community Manager

Check ticket status associated with contact id returning 429

SOLVE

Hey, @ARobson8 👋 Have you already ruled out using the Search API? I know the pseudo-association options don't always work like folks expect, but in this case, we might be able to get you closer. You may need to build in an exponential backoff, regardless of what you end up using, but we can cross that bridge in the future. 

 

My quick test:

  • I have a test Contact Linda Belcher
  • I added 13 support tickets, but only 3 are "Open"
    CleanShot 2025-04-09 at 16.04.49@2x.png
  • I used the Search API
    https://api.hubapi.com/crm/v3/objects/tickets/search​

    Request body

    {
        "filterGroups": [
            {
                "filters": [
                    {
                        "propertyName": "associations.contact",
                        "operator": "EQ",
                        "value": "851"
                    },
                    {
                        "propertyName": "hs_pipeline",
                        "operator": "EQ",
                        "value": "0"
                    },
                    {
                        "propertyName": "hs_pipeline_stage",
                        "operator": "EQ",
                        "value": "1"
                    }
                ]
            }
        ],
        "sorts": [
            {
                "propertyName": "createdate",
                "direction": "DESCENDING"
            }
        ],
        "properties": [
            "hs_pipeline_stage",
            "subject",
            "content"
        ],
        "limit": 10
    }
  • Response returned only the three "Open" Tickets
    {
        "total": 3,
        "results": [
            {
                "id": "22271987324",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:58:36.500Z",
                    "hs_lastmodifieddate": "2025-04-09T21:58:42.910Z",
                    "hs_object_id": "22271987324",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr14"
                },
                "createdAt": "2025-04-09T21:58:36.500Z",
                "updatedAt": "2025-04-09T21:58:42.910Z",
                "archived": false
            },
            {
                "id": "22271986577",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:46:33.154Z",
                    "hs_lastmodifieddate": "2025-04-09T21:46:41.210Z",
                    "hs_object_id": "22271986577",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr13"
                },
                "createdAt": "2025-04-09T21:46:33.154Z",
                "updatedAt": "2025-04-09T21:46:41.210Z",
                "archived": false
            },
            {
                "id": "22285256561",
                "properties": {
                    "content": null,
                    "createdate": "2025-04-09T21:46:07.084Z",
                    "hs_lastmodifieddate": "2025-04-09T21:46:11.076Z",
                    "hs_object_id": "22285256561",
                    "hs_pipeline_stage": "1",
                    "subject": "testerrr11"
                },
                "createdAt": "2025-04-09T21:46:07.084Z",
                "updatedAt": "2025-04-09T21:46:11.076Z",
                "archived": false
            }
        ]
    }​

It's not a perfect solution. For one, you'll need to either store the Contact's phone number as a custom Ticket property to have it returned in this response, since we are making a request to Tickets and not Contacts. 

 

Talk soon! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 Upvotes