Custom Object API Using Search (Need Pipeline, Stage, etc..)

Could someone please help? What I’m trying to do for one of our teams at work is to use the search api for a custom object and obtain the total number per stage of the specific pipeline, circled below:

I am able to do this when it’s a deal and not a custom object by using the deals/search endpoint and the following body:

This doesnt work for custom objects but I need the same functionality. Is this possible?

What I can do is pull the total number of all stages per custom object using /objecttypeID/search. But I have no idea how to format the body of the api request, as nothing seems to work. I need to search the custom object and be able to input in the body the pipeline, pipeline stage.

Any guidance would be appreciated. Thank you!

Hi @AHafer,

I recorded a video running through how you can search for custom objects based on the stage they’re in within the pipeline. Ultimately the process is as follows…

1. We first need to get the IDs of the pipeline stages so that we can format our search query correctly. This can be done by calling this endpoint. What is returned is a pipeline with the various stages and their corresponding IDs. We can use these when searching for custom objects in the next step.

GET https://api.hubapi.com/crm/v3/pipelines/2-131659417
Header Authorization Bearer {token}
Response

{
 "results": [
 {
 "label": "Projects",
 "displayOrder": 0,
 "id": "460437978",
 "stages": [
 {
 "label": "Stage 1",
 "displayOrder": 0,
 "metadata": {
 "isClosed": "false",
 "state": "OPEN"
 },
 "id": "705535178",
 "createdAt": "2024-07-25T14:11:31.766Z",
 "updatedAt": "2024-07-25T14:11:55.606Z",
 "archived": false,
 "writePermissions": "CRM_PERMISSIONS_ENFORCEMENT"
 },
 {
 "label": "Stage 2",
 "displayOrder": 1,
 "metadata": {
 "isClosed": "true",
 "state": "CLOSED"
 },
 "id": "705535179",
 "createdAt": "2024-07-25T14:11:31.766Z",
 "updatedAt": "2024-07-25T14:11:55.606Z",
 "archived": false,
 "writePermissions": "CRM_PERMISSIONS_ENFORCEMENT"
 },
 {
 "label": "Stage 3",
 "displayOrder": 2,
 "metadata": {
 "isClosed": "false",
 "state": "OPEN"
 },
 "id": "705535180",
 "createdAt": "2024-07-25T14:11:55.606Z",
 "updatedAt": "2024-07-25T14:11:55.606Z",
 "archived": false,
 "writePermissions": "CRM_PERMISSIONS_ENFORCEMENT"
 },
 {
 "label": "Stage 4",
 "displayOrder": 3,
 "metadata": {
 "isClosed": "false",
 "state": "OPEN"
 },
 "id": "705535181",
 "createdAt": "2024-07-25T14:11:55.606Z",
 "updatedAt": "2024-07-25T14:11:55.606Z",
 "archived": false,
 "writePermissions": "CRM_PERMISSIONS_ENFORCEMENT"
 }
 ],
 "createdAt": "2024-07-25T14:11:31.766Z",
 "updatedAt": "2024-07-25T14:11:55.606Z",
 "archived": false
 }
 ]
}

2. We create our search query to find custom objects in stage X, Y or Z. This can be done by calling this endpoint. The {objectTypeId} will differ for you, it’s visible from within the URL when you are viewing the custom object pipeline. Alternatively you can get it via this endpoint.

POST https://api.hubapi.com/crm/v3/objects/{objectTypeId}/search
Header Authorization Bearer {token}
Body:
{
 "filterGroups": [
 {
 "filters": [
 {
 "propertyName": "hs_pipeline_stage",
 "operator": "EQ",
 "value": "705535181"
 }
 ]
 }
 ]
}

Response:
{
 "total": 1,
 "results": [
 {
 "id": "6549317821",
 "properties": {
 "hs_createdate": "2024-07-25T14:12:21.939Z",
 "hs_lastmodifieddate": "2024-07-25T14:13:40.565Z",
 "hs_object_id": "6549317821"
 },
 "createdAt": "2024-07-25T14:12:21.939Z",
 "updatedAt": "2024-07-25T14:13:40.565Z",
 "archived": false
 }
 ]
}

Also I find this article quite helpful at helping to understand how to correctly setup your search filters when searching for CRM objects via the API. I hope this helps!

Jack

So incredibly helpful! Thank you so much. The filter body worked! I must have originally used “Pipeline_Stage” instead of “hs_pipeline_stage”. Awesome, thanks again!!