Sahih al-Bukhari #2044
Retiring to a Mosque for Remembrance of Allah (I'tikaf) 33:19
Narrated Abu Huraira:
The Prophet (ﷺ) used to perform I`tikaf every year in the month of Ramadan for ten days, and when it was the year of his death, he stayed in I`tikaf for twenty days.