Get all Tasks related to all Deals (Freshsales API)

Overview: It seems like there is no good way to get all tasks related to any deal within the Freshsales system through the API.

Explanation:

  • The /tasks endpoint only gets tasks for the user the API Key is related to, so this endpoint can’t be used.
  • Since there is no way to get all Deals in the system (you can only get all Recent Deals or all Open Deals reliably), we’ve thought to use the /filtered_search endpoint to get all Deals in the system. We’ve thought to filter by the updated_at value, to only retrieve Deals that have been updated since the last time we made a call to the endpoint. It looks like, however, creating a task does not trigger an update to the Deal, so the deal doesn’t come up with this filter.
  • It is possible to, instead of filtering by updated_date, filter by created_date after 1900. We’d then receive all Deals in the system. But, when I try to include tasks, the tasks array doesn’t appear in the results (we’ve tried tasks and task). So, we’d have to then perform a request to the View a Deal endpoint for every Deal. This would be okay if we were able to use the updated_at filter, only receiving a few results every time, but this will have major performance issues using the created_at filter at scale.

Is there anything I’m missing? Or is there any plan to make this process easier? If we were able to filter on updated_at or include tasks in the filtered_search, this would be much simpler.

Request and Response Details below:

  • Request:
curl --location --request POST 'https://merge-482940851042357362.myfreshworks.com/crm/sales/api/filtered_search/deal?include=sales_account,deal_stage,owner,tasks&page=1' \
--header 'Authorization: Token token=<token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "filter_rule": [
        { 
            "attribute" : "updated_at",
            "operator":"is_after",
            "value":"2022-03-09T18:40:25.919486+00:00"
        }
    ]
}'
  • Response:
{
    "sales_accounts": [
        {
            "partial": true,
            "id": 22001964488,
            "name": "Monx (sample)",
            "avatar": null,
            "website": "monx.inc",
            "open_deals_amount": "5500.0",
            "open_deals_count": 1,
            "won_deals_amount": "50000.0",
            "won_deals_count": 1,
            "last_contacted": "2022-09-19T21:52:27Z",
            "record_type_id": "23008890967"
        },
        {
            "partial": true,
            "id": 22001942762,
            "name": "Widgetz.io (sample)",
            "avatar": null,
            "website": "widgetz.io",
            "open_deals_amount": "0.0",
            "open_deals_count": 0,
            "won_deals_amount": "75000.0",
            "won_deals_count": 1,
            "last_contacted": "2022-09-19T14:36:32Z",
            "record_type_id": "23008890967"
        },
        {
            "partial": true,
            "id": 22001964486,
            "name": "Xyli (sample)",
            "avatar": null,
            "website": "xyli.io",
            "open_deals_amount": "28300.0",
            "open_deals_count": 1,
            "won_deals_amount": "10000.0",
            "won_deals_count": 1,
            "last_contacted": null,
            "record_type_id": "23008890967"
        },
        {
            "partial": true,
            "id": 22001964487,
            "name": "Zeno (sample)",
            "avatar": null,
            "website": "zeno.com",
            "open_deals_amount": "0.0",
            "open_deals_count": 0,
            "won_deals_amount": "25000.0",
            "won_deals_count": 1,
            "last_contacted": null,
            "record_type_id": "23008890967"
        }
    ],
    "deal_stages": [
        {
            "partial": true,
            "id": 22000383612,
            "name": "Lost",
            "position": 7,
            "forecast_type": "Closed Lost",
            "updated_at": "2022-09-02T14:16:13Z",
            "deal_pipeline_id": 22000054725,
            "choice_type": 4,
            "probability": 0
        },
        {
            "partial": true,
            "id": 22000383611,
            "name": "Won",
            "position": 6,
            "forecast_type": "Closed Won",
            "updated_at": "2022-09-02T14:16:13Z",
            "deal_pipeline_id": 22000054725,
            "choice_type": 4,
            "probability": 100
        },
        {
            "partial": true,
            "id": 22000383607,
            "name": "Follow-up",
            "position": 2,
            "forecast_type": "Open",
            "updated_at": "2022-08-24T17:56:23Z",
            "deal_pipeline_id": 22000054725,
            "choice_type": 2,
            "probability": 100
        },
        {
            "partial": true,
            "id": 22000383606,
            "name": "New",
            "position": 1,
            "forecast_type": "Open",
            "updated_at": "2022-08-24T17:56:23Z",
            "deal_pipeline_id": 22000054725,
            "choice_type": 5,
            "probability": 100
        }
    ],
    "users": [
        {
            "id": 22000061404,
            "display_name": "Jack Cavalier",
            "email": "jack.cavalier@merge.dev",
            "is_active": true,
            "work_number": null,
            "mobile_number": null
        }
    ],
    "deals": [
        {
            "id": 22001156691,
            "name": "Lost Deal - Sad",
            "amount": "90000.0",
            "expected_close": null,
            "stage_updated_time": "2022-09-02T13:34:25Z",
            "probability": 0,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-02T13:33:31Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-02T13:33:32Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "90000.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964488,
            "deal_stage_id": 22000383612,
            "owner_id": 22000061404
        },
        {
            "id": 22001156690,
            "name": "Widgetz Deal - We makin $",
            "amount": "75000.0",
            "expected_close": null,
            "stage_updated_time": "2022-09-02T13:32:45Z",
            "probability": 100,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-02T13:32:24Z",
            "recent_note": "a new note! testing the updated date stuff - 9/9 - updated again\n",
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-02T13:32:25Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "75000.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001942762,
            "deal_stage_id": 22000383611,
            "owner_id": 22000061404
        },
        {
            "id": 22001156753,
            "name": "Sample Deal 3",
            "amount": "50000.0",
            "expected_close": "2022-04-10",
            "stage_updated_time": "2022-09-02T14:40:54Z",
            "probability": 40,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-02T14:40:54Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-02T14:40:55Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "50000.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964488,
            "deal_stage_id": 22000383611,
            "owner_id": 22000061404
        },
        {
            "id": 22001155026,
            "name": "New Deal for Zyli",
            "amount": "28300.0",
            "expected_close": "2022-09-23",
            "stage_updated_time": "2022-09-01T21:44:23Z",
            "probability": 100,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-01T21:43:24Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-01T21:43:25Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "28300.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964486,
            "deal_stage_id": 22000383607,
            "owner_id": 22000061404
        },
        {
            "id": 22001156752,
            "name": "Sample Deal 2",
            "amount": "25000.0",
            "expected_close": "2022-02-08",
            "stage_updated_time": "2022-09-02T14:40:54Z",
            "probability": 80,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-02T14:40:54Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-02T14:40:55Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "25000.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964487,
            "deal_stage_id": 22000383611,
            "owner_id": 22000061404
        },
        {
            "id": 22001156751,
            "name": "Sample Deal 1",
            "amount": "10000.0",
            "expected_close": "2022-01-11",
            "stage_updated_time": "2022-09-02T14:40:54Z",
            "probability": 70,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-02T14:40:54Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-02T14:40:55Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "10000.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964486,
            "deal_stage_id": 22000383611,
            "owner_id": 22000061404
        },
        {
            "id": 22001074166,
            "name": "Gold plan (sample)",
            "amount": "7000.0",
            "expected_close": "2022-08-31",
            "stage_updated_time": "2022-08-23T17:56:44Z",
            "probability": 100,
            "last_contacted_sales_activity_mode": "Phone",
            "created_at": "2022-08-19T17:56:43Z",
            "recent_note": "new call incoming for the deal",
            "web_form_id": null,
            "upcoming_activities_time": "2022-08-27T18:18:00Z",
            "collaboration": {},
            "last_assigned_at": "2022-08-19T17:56:43Z",
            "last_contacted_via_sales_activity": "2022-08-31T20:00:11Z",
            "base_currency_amount": "7000.0",
            "record_type_id": "23008890968",
            "sales_account_id": null,
            "deal_stage_id": 22000383606,
            "owner_id": 22000061404
        },
        {
            "id": 22001185395,
            "name": "deeeeal",
            "amount": "5500.0",
            "expected_close": null,
            "stage_updated_time": "2022-09-09T18:27:34Z",
            "probability": 100,
            "last_contacted_sales_activity_mode": null,
            "created_at": "2022-09-09T18:27:34Z",
            "recent_note": null,
            "web_form_id": null,
            "upcoming_activities_time": null,
            "collaboration": {},
            "last_assigned_at": "2022-09-09T18:27:35Z",
            "last_contacted_via_sales_activity": null,
            "base_currency_amount": "5500.0",
            "record_type_id": "23008890968",
            "sales_account_id": 22001964488,
            "deal_stage_id": 22000383606,
            "owner_id": 22000061404
        }
    ],
    "meta": {
        "total": 8
    }
}