Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:48:18

Certainly was Allah pleased with the believers when they pledged allegiance to you, ˹O Muhammad˺, under the tree, and He knew what was in their hearts, so He sent down tranquillity upon them and rewarded them with an imminent conquest  

Verily God was pleased with the believers when they pledged allegiance to you, at al-Hudaybiyya, under the tree, this was an acacia — they ˹these believers˺ numbered 1300 or more; he took an oath of allegiance from them that they would fight against Quraysh and not ˹attempt to˺ flee from death. And He, God, knew what was in their hearts, of sincerity and loyalty, so He sent down the spirit of Peace upon them, and rewarded them with a near victory, which was the conquest of Khaybar, following their departure from al601 Hudaybiyya,
القرآن:٤٨:١٨

لَقَدْ رَضِيَ اللَّهُ عَنِ الْمُؤْمِنِينَ إِذْ يُبَايِعُونَكَ تَحْتَ الشَّجَرَةِ فَعَلِمَ مَا فِي قُلُوبِهِمْ فَأَنْزَلَ السَّكِينَةَ عَلَيْهِمْ وَأَثَابَهُمْ فَتْحًا قَرِيبًا  

{لقد رضي الله عن المؤمنين إذ يبايعونك} بالحديبية {تحت الشجرة} هي سمرة، وهم ألف وثلثمائة أو أكثر ثم بايعهم على أن يناجزوا قريشا وأن لا يفروا من الموت {فعلم} الله {ما في قلوبهم} من الصدق والوفاء {فأنزل السكينة عليهم وأثابهم فتحا قريبا} هو فتح خيبر بعد انصرافهم من الحديبية.