# API call or search query to retrieve the list of identities in a Role

**URL:** <https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261>\
**Category:** SHF Discussion and Questions\
**Created:** [August 16, 2021, 8:40am UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261 "2021-08-16T08:40:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shanmukh](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@Shanmukh](https://developer.sailpoint.com/discuss/u/Shanmukh)\
**Post date:** [August 16, 2021, 8:40am UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/1 "2021-08-16T08:40:23Z")

</div>

Hi Team,

Greetings of the Day!!

We have a requirement where we can retrieve the list of identities in a role or roles and the entitlements that are being provisioned by those roles to the identities that are part of those roles.

Requesting your valuable insights on this.

## Thank you.

Regards,  
Gali Shanmukh Chandra

---

<div class="post-metadata">

**Author:** ![lisa\_ivy](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lisa\_ivy](https://developer.sailpoint.com/discuss/u/lisa_ivy)\
**Post date:** [August 16, 2021, 1:16pm UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/2 "2021-08-16T13:16:56Z")

</div>

Hi Gali,

You will want to use the v3/search API to find this data. [Search | SailPoint Developer Community](https://developer.sailpoint.com/idn/api/v3/search)

You’ll execute the POST (api-url)/v3/search call with a few different bodies to get this data. First, execute the call to get the list of identities in the role (replace name\_of\_role with the role’s name):

```auto
{
  "indices": [
    "identities"
  ],
  "query": {
    "query": "@access(type:ROLE AND name:\"name_of_role\")"
  },
  "sort": ["name"],
  "queryResultFilter": {
      "includes": ["*"]
  }
}

```

Then you can execute the call to see which access profiles are included in the role:

```auto
{
  "indices": [
    "roles"
  ],
  "query": {
    "query": "name:\"name_of_role\""
  },
  "sort": ["name"],
  "queryResultFilter": {
      "includes": ["name","accessProfiles.name"]
  }
}

```

Use the access profile names that were returned to search for the entitlements within each of the access profiles:

```auto
{
  "indices": [
    "accessprofiles"
  ],
  "query": {
    "query": "name:\"name_of_access_profile\""
  },
  "sort": ["name"],
  "queryResultFilter": {
      "includes": ["name","entitlements.value"]
  }
}

```

Thanks,  
Lisa Ivy

---

<div class="post-metadata">

**Author:** ![Shanmukh](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@Shanmukh](https://developer.sailpoint.com/discuss/u/Shanmukh)\
**Post date:** [August 16, 2021, 1:39pm UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/3 "2021-08-16T13:39:12Z")

</div>

Hi Lisa,

Thanks for your quick reply. The first API call will help us a lot for our requirement. Although, we are retrieving list of identities which are part of roles that contains some common name. For example, @access(type:Role AND name:“\*ABCD\*”). This query will return some set of identities. Now our requirement is to fetch the entitlements from a particular source for these set of identities.

Requesting you to please provide your valuable feedback on this.

## Thank you.

Regards,  
Gali Shanmukh Chandra.

---

<div class="post-metadata">

**Author:** ![lisa\_ivy](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lisa\_ivy](https://developer.sailpoint.com/discuss/u/lisa_ivy)\
**Post date:** [August 16, 2021, 1:59pm UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/4 "2021-08-16T13:59:58Z")

</div>

You can see the entitlements associated with each identity in the data that’s returned back from the first call. In the queryResultFilter here, I selected a few fields that help show those details:

```auto

{
  "indices": [
    "identities"
  ],
  "query": {
    "query": "@access(type:ROLE AND name:\"name_of_role\")"
  },
  "sort": ["name"],
  "queryResultFilter": {
      "includes": ["name","firstName","lastName","attributes.uid","access.source.name","access.value"]
  }
}

```

---

<div class="post-metadata">

**Author:** ![Shanmukh](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@Shanmukh](https://developer.sailpoint.com/discuss/u/Shanmukh)\
**Post date:** [August 30, 2021, 2:35pm UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/6 "2021-08-30T14:35:51Z")

</div>

Hi Lisa,

Hope you are doing well.

Thanks for this API body. This has helped us a lot to fulfill our requirement.

Thank you very much for your assistance.

Regards,  
Shanmukh Gali.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:21pm UTC](https://developer.sailpoint.com/discuss/t/api-call-or-search-query-to-retrieve-the-list-of-identities-in-a-role/1261/7 "2023-07-19T14:21:59Z")

</div>


