Getting deals by ownerID

Hi folks,

I’ve got a few queries I’d like answered and I have a feeling I’m losing the wood for the trees.

First of all, what’s the easiest way to find the user ids of users in my organisation? I’ve managed to get a few by using this code from the docs:

try:
 api_response = client.crm.owners.owners_api.get_page(limit=100, archived=False)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling owners_api->get_page: %s\n" % e)

…but this seems unwieldy to say the least. Is there a better way to bulk check these ids?

Additionally, is there an elegant way to find deals by owner? In our previous CRM, we were able to query deals by account ID, but I’m having trouble finding something like this. Any help with these two questions would be greatly appreciated.

@Millard

That seems like the correct way to get the users.

What do you mean by “bulk check?”

For the second part, you can use the CRM search and filter by hs_owner_id

This will return only deals with that specific owner

Hi Dennis,

Thanks for your reply. By bulk check, I meant if there was a request to just get all the ID’s with a list of names, but I’ve been able to find this with this (admittedly wonky) code:

try:
 api_response = client.crm.owners.owners_api.get_page(limit=100, archived=False)
 i = 0

 while i < 10:
 pprint("Name: " + api_response.results[i].first_name + " " + api_response.results[i].last_name + ", ID: " + str(api_response.results[i].user_id))
 i += 1

except ApiException as e:
 print("Exception when calling owners_api->get_page: %s\n" % e)

I’m aware that this will only get the first 10 users, but for now, I think this will be enough.

I will report back if I have any issues with the endpoint you mentioned. I am surprised that I wasn’t able to find this with my initial look through the docs. I think I indeed lost the wood for the trees on that one :sweat_smile:

Thank you again for your kind response!