How can I use the apple store connect rest api to download provisioning files from multiple teams?

I would like to be able to have a script do what Xcode does when it allows me to choose a team and then update the development certificate for that team and download the provisioning files.

I can do this for my own app where I have generated an API key but I would like to do this for other teams where I only have developer access.