Hadithcore
Mishkat al-Masabih, 94
graded· Zubair `Aliza'i

‘Ubada b. as-Samit reported God’s messenger as saying, “The first thing God created was the pen. He told it to write and when it asked Him what it should write He told it to write what was decreed, so it wrote what had taken place and what would take place to all eternity.” Tirmidhi transmitted it, saying that this is a tradition whose <i>isnad</i> is <i>gharib</i>.

وَعَن عبَادَة بن الصَّامِت قَالَ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسلم يَقُول «إِنَّ أَوَّلَ مَا خَلَقَ اللَّهُ الْقَلَمُ فَقَالَ اكْتُبْ فَقَالَ مَا أَكْتُبُ قَالَ اكْتُبِ الْقَدَرَ مَا كَانَ وَمَا هُوَ كَائِنٌ إِلَى الْأَبَدِ» . رَوَاهُ التِّرْمِذِيُّ وَقَالَ هَذَا حَدِيثٌ غَرِيبٌ إِسْنَادًا

References1 variant
In-Book Reference
Book 1, Hadith 88