Offering salah in the Ka’bah is valid regardless of whether it is an obligatory prayer or a supererogatory prayer. Ibn ‘Umar reports: “The Messenger of Allah entered the house [the Ka’bah] with ‘Usamah ibn Zaid, Bilal, and ‘Uthman ibn Talhah and they closed the door behind themselves. When they opened the door, I was the first to come upon them and I asked Bilal: ‘Did the Messenger of Allah pray [while he was inside]?’ He said: ‘Yes, between the two Yemeni pillars.'” This is related by Ahmad, al-Bukhari, and Muslim.
Section : Prayer in the Ka’bah.