You can do anything from the API that you can do from the UX – Reverse engineer the Discourse API.
Ideally you’d use discourse_connect to connect Discourse to whatever it is that manages your subscriptions, but if that’s not feasible, you can have it update stuff via the API.