The Messenger of Allah ﷺ had himself cupped when he was fasting. Abu Dawud said: Wuhaib b. Khalid narrated a similar tradition from Ayyub through a different chain of narrators. Ja'far b. Rabi'ah and Hisham, that is, Ibn Hassan, narrated a similar tradition from 'Ikrimah on the authority of Ibn 'Abbas. (Using translation from Abū Dāʾūd 2372)
أَنَّ النَّبِيَّ ﷺ «احْتَجَمَ وَهُوَ صَائِمٌ»