TLDR: Banks need to verify money wasn’t stolen and a few days is a nice buffer in case it takes a while.
The most important concept to understand, is that banks do not store money as some number in a file, because this would be easy to fake or could be deleted. Rather they store the history of all transactions in and out so they can validate if you really have enough money to withdraw for some purchase. This makes fraud much harder, as you you have to fake a lot more than just one number.
Because of this banks (and credit cards), have a window of time between when a transaction is posted and the bank is 100% sure it is legit. For a transfer between two accounts, the first account gets marked with “-$1000 on Friday at 3:23 pm, Transfer to XXXXXX”, the first bank immediately knows that if this is real, you shouldn’t have access to this money (or you could double-transfer it) so it disappears from your account, and the transaction is marked as “pending”.
The second bank receives a message saying “$1000 into Account XXXXXX on Friday at 3:23 pm”, and spends some time to make sure this money actually came from the other bank and not some faulty or hacked message. This is pretty quick generally but at worst can take a few days if some flags get tripped, so they always give you the worst case. In addition, there may be some data backup or full balance check (sum all the transactions to double check all the accounts are good) that’s happening which will need to happen first.
After both banks have verified this is legit, they finalize the transaction and it gets posted to both accounts transaction history, and the money is moved into the other account.
Latest Answers