APIs & Integrations

HOrdonez
Participant

Get Owner of a Contact by Contact API Endpoint.

SOLVE

Dear all,

 

I would like to ask if it is possible to obtain the owner of a contact by calling the contacts API. 

 

client.crm.contacts.basic_api.get_page()

 

I saw in the past you could by adding "hubspot_owner_id" into properties, some people recommended to cross Apis with Owner, but I couldn't find a clear way either.

 

I would like to ask if there is any way to get the list of properties that I can add to the request.

 

Thank you in advance.

0 Upvotes
1 Accepted solution
zaklein
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Get Owner of a Contact by Contact API Endpoint.

SOLVE

Hi @HOrdonez 

Relating to your original question --> yes, you can retrieve information about the owner of a Contact record, using the Contact API. For example:

GET
https://api.hubapi.com/crm/v3/objects/CONTACT/{{CONTACT_ID}}?properties=hubspot_owner_id,hubspot_owner_assigneddate,hubspot_team_id&hapikey={{HAPIKEY}}

Example Response Body:
{
    "id": {{CONTACT_ID}},
    "properties": {
        "createdate": "2019-01-30T12:55:07.451Z",
        "hs_object_id": {{CONTACT_ID}},
        "hubspot_owner_assigneddate": "2021-08-26T14:30:29.555Z",
        "hubspot_owner_id": {{CONTACT_OWNER_ID}},
        "hubspot_team_id": {{CONTACT_OWNER_TEAM_ID}},
        "lastmodifieddate": "2021-10-28T16:12:15.677Z"
    },
    "createdAt": "2019-01-30T12:55:07.451Z",
    "updatedAt": "2021-10-28T16:12:15.677Z",
    "archived": false
}

Likewise, specific property values can be retrieved when requesting lists or batches of Contacts via the API.

As @dennisedson mentioned, you can use the Get All Properties endpoint to inspect all available properties relevant to record ownership. Here are some I found that might be of interest (descriptions for each can be found in the API response):

  • hubspot_owner_id
  • hubspot_owner_assigneddate
  • hs_all_owner_ids
  • hs_user_ids_of_all_owners
  • hubspot_team_id
  • hs_all_team_ids
  • owneremail  (marked as legacy, returned null for me)
  • ownername  (marked as legacy, returned null for me)

 

Relating to your follow up question in this thread --> yes, it is possible to use the CRM Search API endpoint to retrieve a list of Contact records based on when they were last modified. For example:

POST
https://api.hubapi.com/crm/v3/objects/CONTACT/search?hapikey={{HAPIKEY}}

Request Body (JSON):
{
    "limit": 5,
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "lastmodifieddate",
                    "operator": "GTE",
                    "value": "1635435000000"
                }
            ]
        }
    ]
}

For anyone not overly familiar with the CRM Search API --> "GTE" is the endpoint's "greater than or equal to" operator, and "1635435000000" reflects the example target datetime in Unix epoch time (milliseconds). I generally use EpochConverter for generating test timestamps like this.

Finally, the Contact property being searched on in the above example is "lastmodifieddate", not to be confused with "hs_lastmodifieddate". The latter is a hidden property which, based on some very quick testing, cannot be used within CRM Search API filters. 

Hope this helps 🙂

All the best,

Zach

View solution in original post

5 Replies 5
zaklein
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Get Owner of a Contact by Contact API Endpoint.

SOLVE

Hi @HOrdonez 

Relating to your original question --> yes, you can retrieve information about the owner of a Contact record, using the Contact API. For example:

GET
https://api.hubapi.com/crm/v3/objects/CONTACT/{{CONTACT_ID}}?properties=hubspot_owner_id,hubspot_owner_assigneddate,hubspot_team_id&hapikey={{HAPIKEY}}

Example Response Body:
{
    "id": {{CONTACT_ID}},
    "properties": {
        "createdate": "2019-01-30T12:55:07.451Z",
        "hs_object_id": {{CONTACT_ID}},
        "hubspot_owner_assigneddate": "2021-08-26T14:30:29.555Z",
        "hubspot_owner_id": {{CONTACT_OWNER_ID}},
        "hubspot_team_id": {{CONTACT_OWNER_TEAM_ID}},
        "lastmodifieddate": "2021-10-28T16:12:15.677Z"
    },
    "createdAt": "2019-01-30T12:55:07.451Z",
    "updatedAt": "2021-10-28T16:12:15.677Z",
    "archived": false
}

Likewise, specific property values can be retrieved when requesting lists or batches of Contacts via the API.

As @dennisedson mentioned, you can use the Get All Properties endpoint to inspect all available properties relevant to record ownership. Here are some I found that might be of interest (descriptions for each can be found in the API response):

  • hubspot_owner_id
  • hubspot_owner_assigneddate
  • hs_all_owner_ids
  • hs_user_ids_of_all_owners
  • hubspot_team_id
  • hs_all_team_ids
  • owneremail  (marked as legacy, returned null for me)
  • ownername  (marked as legacy, returned null for me)

 

Relating to your follow up question in this thread --> yes, it is possible to use the CRM Search API endpoint to retrieve a list of Contact records based on when they were last modified. For example:

POST
https://api.hubapi.com/crm/v3/objects/CONTACT/search?hapikey={{HAPIKEY}}

Request Body (JSON):
{
    "limit": 5,
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "lastmodifieddate",
                    "operator": "GTE",
                    "value": "1635435000000"
                }
            ]
        }
    ]
}

For anyone not overly familiar with the CRM Search API --> "GTE" is the endpoint's "greater than or equal to" operator, and "1635435000000" reflects the example target datetime in Unix epoch time (milliseconds). I generally use EpochConverter for generating test timestamps like this.

Finally, the Contact property being searched on in the above example is "lastmodifieddate", not to be confused with "hs_lastmodifieddate". The latter is a hidden property which, based on some very quick testing, cannot be used within CRM Search API filters. 

Hope this helps 🙂

All the best,

Zach

dennisedson
HubSpot Product Team
HubSpot Product Team

Get Owner of a Contact by Contact API Endpoint.

SOLVE

@HOrdonez , you can hit the properties endpoint to get all of the available properties for an object

HOrdonez
Participant

Get Owner of a Contact by Contact API Endpoint.

SOLVE

Thank you @dennisedson. Really useful the property feature.

Do you know if it's possible to filter contacts by modification date, it doesn't appear here:
https://developers.hubspot.com/docs/api/crm/search

 

Or if there is other way to do it?

Thank you in advance.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Get Owner of a Contact by Contact API Endpoint.

SOLVE

It might be worth looking at webhooks which can watch for changes of properties

@zaklein , what would you do?

0 Upvotes
HOrdonez
Participant

Get Owner of a Contact by Contact API Endpoint.

SOLVE

Thank you for your answer @dennisedson. I would just like to filter the API call by some timestamp in order to don't have to bulk all the data every time. 

 

Having the infrastructure to deal with a Webhook is a bit more complex, but if this is the best practices you recommend. I can work on it.

 

I will wait @zaklein answer as well.

0 Upvotes