APIs & Integrations

SView
Participant

HubSpot get ownerId of the current user

How can we get an ownerId of the currently logged in user?

Context: we are creating engagements and notice that in HubSpot web UI newly created engagements are automatically assigned current user as owner (the one, whose name is in the top right corner). But, when api is used, the ownerId is null and not automatically assigned.

How can we get the same ownerId of the current user, that would be assigned to engagement through UI?

 

We currently have found this endpoint:

/oauth/v1/access-tokens/{token}

which in its response contains userId :

{
    ...
    "user_id"27106345
    ...
}
 
However, owner endpoints (from both new and old api) seem to not be able to find owner by user_id.
V3 api: /crm/v3/owners/27106345
V2 api: /owners/v2/owners/27106345
Both return error not found.
 
However if we request all owners through:
/crm/v3/owners/?limit=500
We can find owner with that user_id and there we can also find field 'id' (ownerId)
SView_0-1642694239150.png

This seems to work but it is very inefficient, since, as far as I'm concerned, HubSpot has unlimited number of users and owner's pagination is 500 (which indicates just how many owners there can be).

0 Upvotes
2 Replies 2
webdew
Guide | Diamond Partner
Guide | Diamond Partner

HubSpot get ownerId of the current user

Hi  @SView ,

Use the endpoint to get owner from the giver user id
https://developers.hubspot.com/docs/api/crm/owners#endpoint?spec=GET-/crm/v3/owners/{ownerId}
as ment...
https://prnt.sc/26kmswf

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards. 

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

HubSpot get ownerId of the current user

@SView , Are you adding the id property query param to your request?

idProperty=userId

0 Upvotes