Quraysh made a peace agreement with the Prophet ﷺ, and among their representatives was Suhayl bin Amr.The Prophet ﷺ said to Ali, "Write, 'In the name of Allah, the Most Merciful, the Bestower of Mercy.'"Suhayl objected, "As for 'In the name of Allah, the Most Merciful, the Bestower of Mercy,' we do not know what that is. But write what we recognize, 'In Your name, O Allah.'"The Prophet ﷺ then said, "Write, 'From Muhammad, the Messenger of Allah.'"Suhayl said, "If we had known you were the Messenger of Allah, we would have followed you. But write your name and the name of your father."So the Prophet ﷺ said, "Write, 'From Muhammad bin Abdullah.'"They stipulated to the Prophet ﷺ, "Whoever comes to you from us, you must return him to us, but whoever comes to us from you, we will not return him to you."The companions said, "Messenger of Allah, are you really going to write this?"He replied, "Yes. Whoever leaves us and goes to them, may Allah cast him far away."
حدثنا عفان حدثنا حماد عن ثابت
أن قريشا صالحوا النبي ﷺ فيهم سهيل بن عمرو فقال النبي ﷺ لعلي اكتب بسم الله الرحمن الرحيم فقال سهيل أما بسم الله الرحمن الرحيم فلا ندري ما بسم الله الرحمن الرحيم ولكن اكتب ما نعرف باسمك اللهم فقال اكتب من محمد رسول الله قال لو علمنا أنك رسول الله لاتبعناك ولكن اكتب اسمك واسم أبيك قال فقال النبي ﷺ اكتب من محمد بن عبد الله واشترطوا على النبي ﷺ أن من جاء منكم لم نرده عليكم ومن جاء منا رددتموه علينا فقال يا رسول الله أتكتب هذا قال نعم إنه من ذهب منا إليهم فأبعده الله
Its isnad is sahih. The story of the treaty was narrated by Bukhari 3/255 in "Conditions," chapter "Conditions in Jihad," Muslim 3/411 no. 1784 in "Jihad," chapter "The Treaty of Hudaybiya," and Abdul-Razzaq 5/330 no. 9720 in "Campaigns," chapter "The Expedition of Hudaybiya."