Jabir (May Allah be pleased with him) reported:
Messenger of Allah (ﷺ) used to teach us the Istikharah (seeking guidance from Allah) in all matters as he would teach us a Surah of the Qur'an. He used to say: "When one of you contemplates entering upon an enterprise, let him perform two Rak'ah of optional prayer other than Fard prayers and then supplicate: "Allahumma inni astakhiruka bi 'ilmika, wa astaqdiruka bi qudratika, wa as-'aluka min fadlikal-'azim. Fainnaka taqdiru wa la aqdiru, wa ta'lamu wa la a'lamu, wa Anta 'allamul- ghuyub. Allahumma in kunta ta'lamu anna hadhal-'amra (and name what you want to do) khairun li fi dini wa ma'ashi wa 'aqibati amri, (or he said) 'ajili amri ajilihi, faqdurhu li wa yassirhu li, thumma barik li fihi. Wa in kunta ta'lamu anna hadhal 'amra (and name what you want to do) sharrun li fi dini wa ma'ashi wa 'aqibati amri, (or he said) wa 'ajili amri wa ajilihi, fasrifhu 'anni, wasrifni 'anhu, waqdur liyal- khaira haithu kana, thumma ardini bihi." (O Allah, I consult You through Your Knowledge, and I seek strength through Your Power, and ask of Your Great Bounty; for You are Capable whereas I am not and, You know and I do not, and You are the Knower of hidden things. O Allah, if You know that this matter (and name it) is good for me in respect of my Deen, my livelihood and the consequences of my affairs, (or he said), the sooner or the later of my affairs then ordain it for me, make it easy for me, and bless it for me. But if You know this matter (and name it) to be bad for my Deen, my livelihood or the consequences of my affairs, (or he said) the sooner or the later of my affairs then turn it away from me, and turn me away from it, and grant me power to do good whatever it may be, and cause me to be contented with it). And let the supplicant specify the object."[Al-Bukhari]
App reference: Book 2, Hadith 38
Arabic/English book reference: Book 2, Hadith 718