If your underlying requirement is just to periodically rotate the APIM subscription keys that you have linked to products / APIs, and you want to do this in an automated manner, I think this article may be of help. It uses PowerShell in an automation runbook to automate periodic key rotation for product subscriptions in APIM, and could easily be extended and adapted as needed.
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.