API query for retrieving provisioning policy for all sources

Our goal is to get a list of provisioning polices for all our sources. This is because I want to know the HR attributes being used to create account on the target systems for example, employee UID, phone number, business unit, etc. when IDN creates account for new user.

Currently, one can use the following APIs but one has to first retrieve the source IDs for individual sources and then use another call to get the provisioning policy. This is time consuming. Is there another way?
https://{tenant}.api.identitynow.com/v3/sources/{sourceId}/provisioning-policies

I don’t think there is a way to get the provisioning policies without first retrieving the source ID, but couldn’t a simple script be written to go through these process using the API to list all sources, then simply fetching the provisioning policies for each?

Hi Philip, are you suggesting using the API to list all sources and adding that to a script which then calls provisioning policies for the listed sources?

Yes, that is correct. A script in something like Python or PowerShell that will first call the list sources API to get all of the sources in your tenant, then loop through each source and call the get provisioning policy API for each source. The output can be saved to a file.

Thank you, Colin! Are there any sample scripts you can share?

This will get you started. Make sure to install the requests module for python first:

python3 -m pip install requests
import requests
import json

accessToken = ''
org = ''

sources_url = f'https://{org}.api.identitynow.com/v3/sources'
sources = requests.request("GET", sources_url, headers={ 'Authorization': 'Bearer ' + accessToken }).json()

for source in sources:
        provisioning_policy_url = f'https://{org}.api.identitynow.com/v3/sources/{source["id"]}/provisioning-policies'
        provisioning_policies = requests.request("GET", provisioning_policy_url, headers={ 'Authorization': 'Bearer ' + accessToken }).json()
        print(provisioning_policies)

Thank you very much, Colin! This gave us what we needed.