The Messenger of Allah ﷺ said: “The two parties to a transaction have the option (of cancelling it) so long as they have not parted or there is a condition which gives the option to cancel.ʿ (Using translation from Aḥmad 393)
قَالَ رَسُولُ اللهِ ﷺ الْبَيِّعَانِ بِالْخِيَارِ مِنْ بَيْعِهِمَا مَا لَمْ يَتَفَرَّقَا أَوْ يَكُونُ بَيْعُهُمَا فِي خِيَارٍ