From Sahih Bukhari (Hadith 2111):
Narrated `Abdullah bin `Umar:Allah's Messenger (ﷺ) said, "Both the buyer and the seller have the option of canceling or confirming a bargain unless they separate, or the sale is optional." (See Hadith No)
Reference: Bukhari 2111