The Messenger of Allah ﷺ said, "The buyer and seller each have the right to cancel the transaction as long as they have not parted, unless the sale was made with a stipulated option."
أخبرنا عمرو بن علي قال حدثنا يحيى عن عبيد الله قال حدثني نافع
أن رسول الله ﷺ قال البيعان بالخيار ما لم يفترقا أو يكون خيارا
Muslim narrated it in the Book of Sales, Chapter on the Establishment of the Option of the Session for the Two Parties to a Transaction, hadith no. 1531, from the hadith of Yahya Qattan. Bukhari narrated it in the Book of Sales, Chapter on How Long the Option Is Permissible, hadith no. 2107, from the hadith of Nafi, with the same content. It is also found in Kubra, hadith no. 6058.Ubaydullah is Ibn Umar, and Yahya is Qattan.