# How to Filter Users by Team ID Using the Users Search API

**URL:** <https://community.hubspot.com/t/how-to-filter-users-by-team-id-using-the-users-search-api/123261>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [January 3, 2025, 7:23am UTC](https://community.hubspot.com/t/how-to-filter-users-by-team-id-using-the-users-search-api/123261 "2025-01-03T07:23:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SudheerN](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@SudheerN](https://community.hubspot.com/u/SudheerN)\
**Post date:** [January 3, 2025, 7:23am UTC](https://community.hubspot.com/t/how-to-filter-users-by-team-id-using-the-users-search-api/123261/1 "2025-01-03T07:23:26Z")

</div>

I am working with the Users Search API and want to filter users based on their team ID. In the API response, I receive the following fields

- primaryTeamId: “55685825”
- secondaryTeamIds: [“55681645”]

My goal is to retrieve all users belonging to a specific team ID. How should I structure my query to get all the users associated with a particular team (whether it’s their primary or secondary team)?

Any help or guidance would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![SteveHTM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevehtm/32/22074_2.png) [@SteveHTM](https://community.hubspot.com/u/SteveHTM)\
**Post date:** [January 3, 2025, 4:50pm UTC](https://community.hubspot.com/t/how-to-filter-users-by-team-id-using-the-users-search-api/123261/2 "2025-01-03T16:50:45Z")

</div>

@SudheerN - for a similar type of challenge in one of my recent projects, I started using the Team API call:  
[https://api.hubapi.com/settings/v3/users/teams](https://api.hubapi.com/settings/v3/users/teams)

This returns the user IDs who are primary and secondary to each team - so it’s easy to loop through to build a lits of all teams with which a user has one or other membership.

Hope this helps!

Steve
