https://www.canada.ca/en/revenue-agency/services/tax/individuals/topics/tax-free-savings-account/making-replacing-withdrawals-a-tfsa.html
Replacing withdrawals
If you decide to replace or re-contribute all or a part of your withdrawals into your TFSA in the same year, you can only do so if you have available TFSA contribution room. If you re-contribute but do not have contribution room, you will have over-contributed to your TFSA in the year. You will be subject to a tax equal to 1% of the highest excess TFSA amount in the month, for each month that the excess amount stays in your account.
For more information on withdrawing amounts from your TFSA, contact your TFSA issuer.
Example
Since opening her TFSA in 2009, Jenny has contributed the maximum TFSA dollar limit each year. At the end of 2021, she has no TFSA contribution room left. In 2022, Jenny makes a $6,000 contribution, the TFSA dollar limit for 2022. Later that year, she withdraws $3,000 for a trip. Unfortunately, her plans change and she cannot go. There are choices Jenny could make regarding her TFSA withdrawal as described bellows.
If Jenny wishes to re-contribute part or all of the $3,000 she withdrew, she will have to wait until the beginning of 2023 to do so. The $3,000 will be added to her TFSA contribution room at the beginning of 2023.
If she re-contributes any of the withdrawn amount before 2023, she will have an excess amount in her TFSA and will be charged a tax equal to 1% of the highest excess TFSA amount for each month that the excess stays in her account.