K
Kinde2mo ago
pio0otrek

search user scope / org boundary

Hello Team, Is there a way to limit scope of search to users of organization? https://docs.kinde.com/api/v1/search/users Regards!
2 Replies
Koosha-Kinde
Koosha-Kinde2mo ago
Hi, Thanks for reaching out,

Regarding the Scopes, Yes you can scope user search to a single organization. Recommended: use an org-scoped M2M token when calling the same search endpoint. Tokens from an org-scoped M2M app are restricted to that org, so /api/v1/search/users only returns that org’s users
# Search within one org (server-enforced via org-scoped M2M token)
curl -H "Authorization: Bearer $ORG_SCOPED_TOKEN" \
"https://<your_domain>.kinde.com/api/v1/search/users?query=*&page_size=50"
# Search within one org (server-enforced via org-scoped M2M token)
curl -H "Authorization: Bearer $ORG_SCOPED_TOKEN" \
"https://<your_domain>.kinde.com/api/v1/search/users?query=*&page_size=50"

If you only have a global M2M token: call search and filter results to users whose organizations array contains your org_code.
# Global token -> fetch + filter by organizations in your app
curl -H "Authorization: Bearer $GLOBAL_TOKEN" \
"https://<your_domain>.kinde.com/api/v1/search/users?query=*&expand=organizations&page_size=50"
# Global token -> fetch + filter by organizations in your app
curl -H "Authorization: Bearer $GLOBAL_TOKEN" \
"https://<your_domain>.kinde.com/api/v1/search/users?query=*&expand=organizations&page_size=50"

Let me know if this helps, Thanks
pio0otrek
pio0otrekOP2mo ago
thx

Did you find this page helpful?