Hello all, We'd like some help understanding and k...
# general
a
Hello all, We'd like some help understanding and knowing how to to query a resource instance for its associated users. We have a resource and resource instance setup, the resource instance was then shared with another user. We would like to query all the users who have access to that resource instance. We have tried doing it this way but it keeps returning a single user which is the user making the request
Copy code
`${apiUrl}/v2/facts/${projectId}/${envId}/role_assignments?tenant={}&resource_instance={}&user={}`;
o
getAuthorizedUsers @Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
To query all users who have access to a specific resource instance, you need to use the role assignments API with the
resource_instance
filter without specifying a user filter. (1) The correct API call format is:
Copy code
curl 'https://api.permit.io/v2/facts/{project_id}/{env_id}/role_assignments?resource_instance=document:photo' \
 -H 'authorization: Bearer API_SECRET_KEY'
When you include the
user
parameter in your query, you're filtering the results to only show assignments for that specific user. To get all users with access to the resource instance, remove the
user
parameter from your query. For local PDP queries, you can also use:
Copy code
permissions: RoleAssignmentRead = permit.pdp_api.role_assignments.list(
 resource_instance_key="document:onboarding-doc",
)
(2) This will return all role assignments for that resource instance, showing you every user who has been granted access.
To learn more, see the sources I considered: [[1] Overview](https://docs.permit.io/api/examples/filter-role-associations) [[2] Local Enforcement APIs](https://docs.permit.io/how-to/enforce-permissions/list-role-assignments)
a
That worked. Obrigado!
a
Thanks for the feedback, glad I was helpful.