How to use api or other to manage ban/unban

the only way to ban/unban a user is via a chat command.