The night at مزدلفة is part of the الحج journey, and the السنة is to pray Maghrib and Isha combined and shortened (qasr) upon arrival from عرفة, then rest until shortly before Fajr. If a الحاج falls asleep and misses the combined Maghrib and Isha الصلوات, they must pray them as soon as they wake up, because النبي (صلى الله عليه وسلم) said: 'Whoever sleeps through a الصلاة or forgets it, let him pray it when he remembers it, for that is its time.' Prayer is never waived due to sleep or forgetfulness.
Regarding the stay itself at مزدلفة, the majority of scholars (Hanafi, Maliki, Shafi'i) consider it واجب (واجب). The Hanbali school considers it a ركن (pillar) of الحج عند one opinion, though the well-known position is that it is واجب. الشيخ ابن باز held that the stay at مزدلفة is واجب, and missing it without a valid excuse requires a dam (sacrifice). If a الحاج was present at مزدلفة even briefly during the night or before Fajr, they have fulfilled the requirement.
الشيخ ابن عثيمين clarified that if a الحاج arrived at مزدلفة, fell asleep, and woke up after Fajr having missed the entire nighttime الدعاء and the Fajr الصلاة at مزدلفة, they should pray what they missed immediately. Their الحج is valid because they were physically present at مزدلفة. However, they missed the السنة of the lengthy الدعاء after Fajr at Mash'ar al-Haram. The stay itself was fulfilled by their physical presence during the night, even while sleeping.