Hadithcore
Mishkat al-Masabih, 1038

Ibn ‘Abbas said that the Prophet (ﷺ) prostrated himself when reciting <i>Sad</i> (Al-Qur’an; 38) and said, "David made this prostration in repentance, but we do it out of gratitude.” Nasa’i transmitted it.

وَعَنِ ابْنِ عَبَّاسٍ قَالَ: إِنَّ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ سَجَدَ فِي (ص) وَقَالَ: سَجَدَهَا دَاوُدُ تَوْبَةً وَنَسْجُدُهَا شُكْرًا. رَوَاهُ النَّسَائِيُّ

References1 variant
In-Book Reference
Book 4, Hadith 456