What is the prayer of thanking a divine blessing? How do you thank allah for a blessing?
Thanking the endless blessings of Allah the Almighty is a duty that all people must do. Showing gratitude increases the blessings; while ingratitude brings about the decline of the blessing and the unthankful receiver of the blessing will be subjected to a severe punishment. Jalal al-Din Rumi quoted:
“Gratitude is like sucking the breasts (divine blessings). No matter how full the breasts are, the milk only comes out after sucking (giving thanks).” (Fihi Ma Fihi, p. 165)
When the Messenger of Allah became happy or received some good news, he would prostrate and perform prayer to thank for it. (Ibn Majah, Salat, 192)
Anas (r.a.) narrates that:
Allah’s Apostle (pbuh) was informed that one of his needs was solved. He immediately went down to prostrate. (Ibn Majah, Salat, 192)
Similarly, companions of the Prophet (pbuh) performed gratitude prayer when they became happy. Ka’b b. Malik (r.a.) had not attended the expedition of Tabuk, and he had very distressed days because of this mistake. When he learned that his repentance had been accepted, he immediately prostrated. (Ibn Majah, Salat, 192) After that he gave all his possessions to the Messenger of Allah (pbuh) and asked him to donate them; however, the Prophet (pbuh) told him to donate half of his possessions and to keep the other half for his family. (Bukhari, Maghazi, 79)
Actually gratitude is an act of the heart; however, in order to strengthen the feelings in the heart, they need to have some kind of external manifestation. For example, aggressiveness and extravagance resulting from the divine blessings should be prevented. Obedience to the real Owner of the blessings and prostrating before Him will eliminate such spiritual diseases.
 Prostration for thankfulness is done just like doing prostration after reciting certain Qur’anic verses (sajdat al-tilawah). First the person makes his/her ablution, intends to make prostration for gratitude, says “Allahu akbar” without raising his/her hands, prostrates, stays prostrating as long as possible, and then stands up.
Source: An Excellent Exemplar, Osman Nuri Topbaş, Erkam Publications