What is the reference of hadith which means that Allah is with person with broken heart
أنا عند المنكسرة قلوبهم
This statement can hardly be considered as a hadith most scholars consider it as among the israeli traditions. And no scholar of hadith even considered to qualify it as a hadith.
Nevertheless it usually appears in some mystical books or in the sufi literature It was mentioned by imam al-Ghazali in his bidayat an-Hidayah without quoting a source nor a narrator chain. The sufi scholar 'Abdurrahman at-Tha'alibi عبد الرحمان الثعالبي quoted this in his al-Jawahir al-Hissan fi Tafsir al-Qu'ran and referred to it while discussing -see here in Arabic-
do not be impatient for them
in verse (46:35).
Ibn al-Qayyim quotes it in his Madarij as-Salikyn as an Israelite athar:
In the following I'll try to translate from English, as the translation is mine take it carefully!
ومنه الأثر الإسرائيلي : أن موسى قال : يا رب أين أجدك ؟ قال : عند المنكسرة قلوبهم من أجلي
Among these there's the Israelite athar saying that Musa said: "Oh my Lord where can I find you? HE answered: You'll find ME there where those are whoms herats are broken because of me
about the presence of Allah, which comes close to the known hadith qudsi:
"Allah the Exalted says: 'I am as my slave expects me to be, and I am with him when he remembers Me. If he remembers Me inwardly, I will remember him inwardly, and if he remembers Me in an assembly, I will remember him in a better assembly (i.e., in the assembly of angels)." (Riyad as-Saliheen)
or may also be considered as relevant to another qudsi hadith saying:
Verily, Allah, the Exalted and Glorious, would say on the Day of Resurrection: O son of Adam, I was sick but you did not visit Me. He would say: O my Lord; how could I visit Thee whereas Thou art the Lord of the worlds? Thereupon He would say: Didn't you know that such and such servant of Mine was sick but you did not visit him and were you not aware of this that if you had visited him, you would have found Me by him?
O son of Adam, I asked food from you but you did not feed Me. He would say: My Lord, how could I feed Thee whereas Thou art the Lord of the worlds? He said: Didn't you know that such and such servant of Mine asked food from you but you did not feed him, and were you not aware that if you had fed him you would have found him by My side?
(The Lord would again say: ) O son of Adam, I asked drink from you but you did not provide Me. He would say: My Lord, how could I provide Thee whereas Thou art the Lord of the worlds? Thereupon He would say: Such and such of servant of Mine asked you for a drink but you did not provide him, and had you provided him drink you would have found him near Me.
It was further quoted from or via some mystics among the tabi'is as Allahs word when addressing Musa () who: Asked His Lord: Where can I find you? in abu Na'ym's al-Hilyah -see here-
ثنا أَبُو حَامِدِ بْنُ جَبَلَةَ ، قَالَ : ثنا مُحَمَّدُ بْنُ إِسْحَاقَ ، قَالَ : ثنا هَارُونُ ، قَالَ : ثنا سَيَّارٌ ، قَالَ : ثنا جَعْفَرُ بْنُ سُلَيْمَانَ ، قَالَ : ثنا مَالِكُ بْنُ دِينَارٍ ، قَالَ : " قَالَ مُوسَى عَلَيْهِ السَّلامُ : يَا رَبِّ أَيْنَ أَبْغِيكَ ؟ قَالَ : ابْغِنِي عِنْدَ الْمُنْكَسِرَةِ قُلُوبُهُمْ " .
on the authority of Malik ibn Dinar مالك بن دينار .
And in al-Bayahqi's az-Zuhd al-Kabir as the answer of Dawud's similar question:
أَخْبَرَنَا أَبُو عَبْدِ اللَّهِ الْحَافِظُ ، حَدَّثَنَا أَبُو الْعَبَّاسِ الأَصَمُّ ، حَدَّثَنَا طَاهِرُ بْنُ عَمْرٍو ، حَدَّثَنَا أَبِي ، أَخْبَرَنِي السَّرِيُّ ، عَنْ عَبْدِ الْكَرِيمِ بْنِ رَشِيدٍ , " أَنَّ دَاوُدَ عَلَيْهِ السَّلامُ , قَالَ : " أَيْ رَبِّ أَيْنَ أَلْقَاكَ ؟ قَالَ : تَلْقَانِي عِنْدَ الْمُنْكَسِرَةِ قُلُوبُهُمْ " .
on the authority of 'Abdulkarim ibn Rashid al-Qshayri عبد الكريم بن رشيد from Basra. Both above narrations are disconnected as they don't quote a sahabi nor do they attribute it to the prophet ().
In the name of Allah, the most compassionate, the most merciful
أنا عند المنكسرة قلوبهم
According to my research, its reference is:
منیهُ المرید/ صفحه123.(Monih al-Morid), P.123