Sahih Muslim 409 a
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ . فَقُولُوا اللَّهُمَّ رَبَّنَا لَكَ الْحَمْدُ . فَإِنَّهُ مَنْ وَافَقَ قَوْلُهُ قَوْلَ الْمَلاَئِكَةِ غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ "
Abu Huraira reported:
The Messenger of Allah (ﷺ) said: When the Imam says:" Allah listens to him who praises Him." you should say:" O Allah, our Lord for You is the praise." for if what anyone says synchronises with what the angels say, his past sins will be forgiven.
Full reference and source
Sahih Muslim 409 a In-book : Book 4, Hadith 75 USC-MSA web (English) : Book 4, Hadith 809 (deprecated)
View source on Sunnah.com (opens in a new tab)