How to Perform Filtered Search for Events in Custom Objects?

Hey, @Fred4 :waving_hand: Welcome to the community. To clarify, you are not missing an option with the Search API. You’ll need to use the Associations API to return the objects IDs. The thing to note here is that the Associations API doesn’t offer filtering or search operators. If you need to utilize those, you have to look at making multiple requests. One to the Search API to use filters and search operators on your Custom Object, and then one to use those IDs and use the Associations API to get the related company IDs. The other option is to look into GraphQL if you have a Content Hub — Professional or Enterprise subscription.

I made a quick example of what the response will look like using the Associations API with a Custom Object.

Steps:

  • I have an existing Custom Object called Cats
  • It has two records
  • I have multiple test companies
  • I associated 6 companies to one of my cat records

Request

curl --request GET \
 --url 'https://api.hubapi.com/crm/v4/objects/cats/13466364256/associations/companies?limit=500' \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

Response

HTTP 200

{
 "results": [
 {
 "toObjectId": 11685858563,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 },
 {
 "toObjectId": 11685858582,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 },
 {
 "toObjectId": 13861282304,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 49,
 "label": "cat_co"
 },
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 },
 {
 "toObjectId": 15709311259,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 49,
 "label": "cat_co"
 },
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 },
 {
 "toObjectId": 16053398365,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 49,
 "label": "cat_co"
 },
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 },
 {
 "toObjectId": 20461937810,
 "associationTypes": [
 {
 "category": "USER_DEFINED",
 "typeId": 49,
 "label": "cat_co"
 },
 {
 "category": "USER_DEFINED",
 "typeId": 51,
 "label": null
 }
 ]
 }
 ]
}

If I misunderstood what you are trying to accomplish, please let me know.

Have fun building! — Jaycee