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. (Using translation from Bukhārī 2044)
كَانَ رَسُولُ اللهِ ﷺ يَعْتَكِفُ فِي كُلِّ رَمَضَانَ عَشْرَةَ أَيَّامٍ فَلَمَّا كَانَ الْعَامُ الَّذِي قُبِضَ فِيهِ اعْتَكَفَ عِشْرِينَ يَوْمًا