Bitcoind When sending a payment how can I know how many inputs and outputs there are? We're using bitcoind on our server.

When people withdraw from our system we want to have the correct miner fee.

I understand that we can get the good miner fee from txconfirmtarget or the API from: https://bitcoinfees.21.co/api

But when we send a transaction how do we know which miner fee to put if we want to enter it into the database?

EDIT:
I do notice this: bitcoin-cli estimatefee 2 but then how do we find out how many bytes are being sent?
When you use bitcoind's internal wallet and its related RPCs, it will automatically calculate the transaction fee for you and include that in the transaction. You can then retrieve the transaction fee used by using the gettransaction command. If you want the fee rate that was used, you can use the fee from gettransaction and divide that by the size returned by gettransaction.

Edit: To get the fee before you send, you can create the transaction with only the outputs you want (i.e. no inputs) with createrawtransaction. Then you can use fundrawtransaction to fill out the transaction with inputs. That will also give you the fee that the transaction is paying. Then you sign it with signrawtransaction and send it with sendrawtransaction. There is no other way as the other send* RPCs create the transaction, select coins, sign, and send all in one command.