Hadithcore
Musnad Ahmad 1948
da’if· Darussalam

It was narrated from Ibn "Abbas.

The Prophet (ﷺ) was in Makkah, then he was commanded to migrate and the verse was revealed to him: “And say (O Muhammad (ﷺ)) : My Lord! Let my entry (to the city of Al Madinah) be good, and (likewise) my exit (from the city of Makkah) be good. And grant me from You an authority to help me (or a firm sign or a proof" al-Isra" 17:80].

References1 variant
Arabic/English book
Book 25, Hadith 1948