Rav says, (Maseches Berachos 54) that four are obligated to offer thanks: persons who have safely completed a sea or land journey, or who have recovered from a serious illness, or have been released from captivity. One who is obligated to recite the blessing of thanksgiving should do so at the Torah-scroll after the blessing that follows the Torah reading. It is proper not to delay the recital of the blessing for more than three days.
בָּרוּךְ אַתָּה יְהֹוָה Blessed are You, Adonoy
אֱלֺהֵֽינוּ מֶֽלֶךְ הָעוֹלָם our God, King of the Universe,
הַגּוֹמֵל לְחַיָּבִים טוֹבוֹת Who bestows goodness upon the guilty,
שֶׁגְּ֒מָלַֽנִי כָּל טוֹב: Who has bestowed every goodness upon me.
The congregation responds:
מִי שֶׁגְּ֒מָלְ֒ךָ טוֹב He Who has bestowed goodness upon you,
הוּא יִגְמָלְ֒ךָ כָּל־טוֹב may He bestow every goodness upon you,
סֶֽלָה: forever.