I heard Messenger of Allah ﷺ saying, "Before Allah created the creations, He wrote a Book (wherein He has written): My Mercy has preceded my Anger." and that (Book) is written with Him over the Throne."
عَنِ النَّبِيِّ ﷺ قَالَ لَمَّا قَضَى اللَّهُ الْخَلْقَ كَتَبَ كِتَابًا عِنْدَهُ غَلَبَتْ أَوْ قَالَ سَبَقَتْ رَحْمَتِي غَضَبِي فَهْوَ عِنْدَهُ فَوْقَ الْعَرْشِ