With bitcoin-cli you just call sendtoaddress or sendmany with the tx amount and the software will automatically calculate the necessary fee. You can retrieve the amount afterward with gettransaction if you need to record it.
Also you can call estimatefee before to get an estimate, but it could be different from the actual amount used due to changing network conditions, etc.
If you absolutely insist to control the exact fee amount yourself you would need to use createrawtransaction, signrawtransaction, sendrawtransaction.
yeah I do that right now but I used the gui yesterday and saw that you can set the deduct from amount option in the gui but I cant figure out how to use it via api
I only use my node to redistribute my mining income automaticly and allways keep around 0.015 in the walle for fees but I like the deduct from amount future way more