Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:21:79

And We gave understanding of the case to Solomon, and to each ˹of them˺ We gave judgement and knowledge. And We subjected the mountains to exalt ˹Us˺, along with David and ˹also˺ the birds. And We were doing ˹that˺.  

And We gave understanding of this, that is, the judgement, to Solomon. ˹It is said that˺ both of their decisions were ˹the result of˺ independent judgement ˹exercised by both˺, and that David consulted Solomon; but it is also said ˹that their decisions were˺ by way of inspiration ˹from God˺ — the second ˹decision˺ abrogated the first. And to each, of the twain, We gave judgement, prophethood, and knowledge, in matters of religion. And We disposed the mountains to glorify ˹God˺ with David, and the birds also, were disposed to glorify ˹God˺ with him, for he ˹David˺ had commanded such ˹glorification on their part˺, so that whenever there was a lapse ˹on his part˺, he would ˹be reminded to˺ apply himself to the task ˹of glorifying God˺ promptly. And We were ˹certainly˺ doers, of this disposing of them to glorify ˹God˺ along with him, even if it should amaze you, that they should ˹be able to˺ respond to the lord David.
القرآن:٢١:٧٩

فَفَهَّمْنَاهَا سُلَيْمَانَ ۚ وَكُلًّا آتَيْنَا حُكْمًا وَعِلْمًا ۚ وَسَخَّرْنَا مَعَ دَاوُودَ الْجِبَالَ يُسَبِّحْنَ وَالطَّيْرَ ۚ وَكُنَّا فَاعِلِينَ  

{ففهمناها} أي الحكومة {سليمان} وحكمهما باجتهاد ورجع داود إلى سليمان وقيل بوحي والثاني ناسخ للأول {وكلا} منهما {آتينا} ه {حكماً} نبوة {وعلماً} بأمور الدين {وسخرنا مع داود الجبال يسبحن والطير} كذلك سخرا للتسبيح معه لأمره به إذا وجد فترة لينشط له {وكنا فاعلين} تسخير تسبيحهما معه، وإن كان عجباً عندكم: أي مجاوبته للسيد داود.