It is narrated from Abdullah bin Umar (may Allah be pleased with them both) that he stated: I saw the Messenger of Allah (ﷺ) praying on a donkey, while his face was towards Khaybar. Imam Shafi'i (may Allah have mercy on him) said: That is, it was a voluntary (nafl) prayer.
Hadith Referenceمسند الإمام الشافعي / كتاب الصلاة / 377
Hadith Takhrijأخرجه مسلم: صلاة المسافرين، باب جواز صلاة النافلة على الدابة في السفر حيث توجهت (700).