Hello.
Do we have an opportunity to do this action via API?
Yes, any action that can be performed through the UI can be performed throuth the API. Have a look at How to reverse engineer the Discourse API for details about how to find the correct route to call.