This prayer is mentioned in Adhkār of Imam Nawawi [#369]

We narrate from Kitāb Ibn al-Sunnī  from Abū Mūsā al-Ashárīy rađiyAllāhu ánhū that he said:
RasūlAllāh  şallAllāhu álayhi wa sallam said: “When one is stricken with melancholy or sadness, he should recite this duáā:

[O Allāh!] I am Your slave, the son of Your bondsman; the son of Your bondsmaid; [We are] in Your Power; my forelocks are in Your Power; Your command [concerning my fate] is done; Your decision [concerning me] is just. I ask You [for the sake of] Your [Exalted] Names, which You have mentioned Yourself; or revealed it in Your [Holy] Book; or taught anyone in Your creation; or preferred to keep it [undisclosed] in Your Knowledge [unknown to everyone else;] [I beseech Thee] to make the Qur’ān illuminate my bosom, [give] cheer and comfort to my heart, banish my sadness and ward off melancholy [that afflicts me].

Someone in the gathering said: “O Messenger of Allāh! Verily, deprived is he, who is bereft of these words”.

He şallAllāhu álayhi wa sallam replied: “Certainly. Inform [others] and teach them [this prayer.] Because, whosoever beseeches in these words, Allāh táālā will make his sadness go away and increase his happiness”.

[Adhkār of Imām Nawawī; Kitāb Ámal al-Yawm wa’l Laylah by Ibn al-Sunnī, #339.]

Note:  This ĥadīth is narrated by Ábdullāh ibn Masúūd rađiyAllāhu ánhū in Musnad of Imām Aĥmed, Ad-Dáwāt al-Kabir of Bayhaqī, Mújam al-Kabīr of Ţabarānī, Şaĥīĥ Ibn Hibbān, Musnad Bazzār, Al-Faraj baád al-Shiddah of Ibn Abi’d Dunyā, Musnad Abi Yáalā, Mustadrak of Ĥākim,  another narration of Ibn al-Sunni, Ílal of Dār Quţnī, Musnad Ibn Abi’sh Shaybah. In this narration of Ibn Masúūd, the person asks: “Shall we not learn or teach others” and RasūlAllāh şallAllāhu álayhi wa sallam replies: “Certainly, whosoever learns this should teach others.”
 

dua-huzn