Umar had vowed to perform a night of seclusion in the Sacred Mosque. He asked the Messenger of Allah ﷺ about it, and he instructed him to fulfill the seclusion.
أخبرنا محمد بن عبد الله بن يزيد قال حدثنا سفيان عن أيوب عن نافع
كان على عمر نذر في اعتكاف ليلة في المسجد الحرام فسأل رسول الله ﷺ عن ذلك فأمره أن يعتكف
Bukhari transmitted it in the Book of the Obligation of the Fifth, in the chapter on what the Prophet used to give to those whose hearts were to be won over, etc., no. 3144, and Muslim, no. 28/1656. See the previous hadith narrated from Ayub Sakhtiyani with this same wording, and it is also found in Kubra, no. 4763.