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