Hi,
Welcome to the community!
You’ll need to do this with the API. The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.
You may also find this guide helpful.
Ann