Sure Yusuf

12:102

ذَٰلِكَ مِنْ أَنۢبَآءِ ٱلْغَيْبِ نُوحِيهِ إِلَيْكَ ۖ وَمَا كُنتَ لَدَيْهِمْ إِذْ أَجْمَعُوٓا۟ أَمْرَهُمْ وَهُمْ يَمْكُرُونَ

Dies gehört zu den Nachrichten vom Verborgenen, das Wir dir (als Offenbarung) eingeben. Denn du warst nicht bei ihnen, als sie sich einigten, indem sie Ränke schmiedeten.

Tafsir 12:102

Allah revealed all that has been mentioned from the story of Joseph and his brothers to the Messenger (peace be upon him). He had no knowledge of it beforehand, since he was not there with the brothers of Joseph when they agreed to throw him into the bottom of a well, and when they planned their trick; but Allah revealed this all to the Messenger (peace be upon him).