queue tasks

Hello, how are you? I have another question: Is it possible to query the queue of tasks associated with a business through the HubSpot API?”

Hi, @KMirama :waving_hand: You can do this for sure. The method will depend on your subscription. Either with GraphQL (Sales Hub or Service Hub Enterprise subscription) or by using our endpoints (all accounts), likely will require multiple calls.

If you are using our endpoints, you can use the Companies API to return associations. Then take those IDs and query the matching Engagement endpoint (Tasks in this case) to get the details for the Tasks.

Example of the first request:

  • I have a Company called McChicken

  • I created three Tasks and associated them to McChicken

  • Request

    curl --request GET \
     --url 'https://api.hubapi.com/crm/v3/objects/companies/20461937810?associations=tasks&archived=false' \
     --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    

    Response

    HTTP 200
    
    {
     "id": "20461937810",
     "properties": {
     "createdate": "2024-04-25T16:33:48.608Z",
     "domain": null,
     "hs_lastmodifieddate": "2024-07-30T21:36:48.325Z",
     "hs_object_id": "20461937810",
     "name": "McChicken Inc"
     },
     "createdAt": "2024-04-25T16:33:48.608Z",
     "updatedAt": "2024-07-30T21:36:48.325Z",
     "archived": false,
     "associations": {
     "tasks": {
     "results": [
     {
     "id": "57316161566",
     "type": "company_to_task"
     },
     {
     "id": "57316163092",
     "type": "company_to_task"
     },
     {
     "id": "57316164420",
     "type": "company_to_task"
     }
     ]
     }
     }
    }​
    

A second call to the Tasks endpoint is needed to get the details for the tasks. This is because the associated object properties are not returned in the initial call. And neither the Search API nor the batch endpoints will return associations in the way you need them to.

Have fun building! — Jaycee