Obligatory "Are you on want medications and if so how long ... has your dosage changed, have you changed, is this a new treatment treatment?"
This comment isn't meant to stigmatise the OP but just to rule out other circumstances. I have a couple of older relatives who have been in antidepressants and other mental health drugs and they've come to normalize witnessing weird things because now they just think it's the drugs affecting their minds.
Whatever you do, DO NOT buy one of those bedside sleep sound recorders. There's just too much iffy shit you hear on those, if you listen closely and you hear stuff you can't ever forget. I tried it once. The one I had would skip to the places where there was noise.
I heard my snore stop suddenly, like my breath stopped or a hand over my mouth silenced me, and then I hear a clear whisper "Don't wake up!"
I don't know if it was me talking or what, but I'd rather not know the noises in my room at night! Never again for me.
I could never use one of those unless it also had a camera with it. If shadowmen are going to mess with me in my sleep, they'll have to live with having their images captured on camera.
So a while back, the smoke alarm in the kid's room directly below mine started going off for no apparent reason at 3 AM. Got up, went downstairs to silence it, checked everything in the house, smelled for smoke, looked at all the outlets, etc. Dug through drawers to find a new 9V battery and figured it was either a battery issue or a literal bug set it off. Never really got back to restful sleep after that, and the next day I kept worrying I had missed something and a shorted wire was quietly smoldering away in the wall somewhere.
Next night, around the same time, I was again jolted out of sleep by a loud beep, but by the time I had gotten downstairs, there was no alarm going off, just my ears ringing. Asked everyone else if they heard an alarm, they said no. I must've hallucinated it, but I was also experiencing the most intense tinitus I have ever had. I don't usually get tinitus at all, but my ears were ringing so loudly I couldn't get back to sleep for a half hour afterwards.
I believe I had a major psychosomatic event, which manifested tinitus. It's either that or the timing of the random tinitus that woke me up was a bizarre coincidence.
Hallucinations while half-asleep are a well known phenomenon, so it's very possible.
If you're trying to know for certain, that's harder. You'll have to consider a lot of things. Not all of them are likely, so how much digging you do is dependent on how concerned you are.
Do you live alone? I assume you do, or already asked the people you live with.
Are all your exterior doors and windows locked? Is anything missing or out of place? I think you'd have already noticed if you'd been robbed, but this is easy stuff to rule out.
Do you have functioning Carbon Monoxide detectors? Do you have sleep apnaea? CO can lead to memory loss, sleep apnaea can contribute to sleep paralysis.
Have you seen your door open while half asleep before? If this is recurring, you can do things like place hairs in the door that will fall if it opens.
Have you done a sleep study? This can help determine if your REM cycle is frequently disrupted and if you need something like a CPAP.
It could be a hallucination or it could not, check your monoxide detector, double check you aren't schitzo/predisposed to more serious forms of hallucinations and setup a webcam pointed at the door + the painters tape like someone else suggested.
Maybe it was a one off groggy sleep hallucination, maybe your being poisioned by gas, maybe your ass is haunted or someone crept into your home.
Follow the other advice about carbon monoxide detectors and whatnot, but an easy trick to monitor your door is to tape the seams with something like painters tape or masking tape. If someone were to open your door while you're sleeping they won't be able to fix the tape even if they close the door when they leave.
If it trips it doesn't tell you who is opening the door or why but it might give you some peace of mind until you get a camera or something set up.
Do you have a window open somewhere? Or have a bathroom fan on?
Sometimes the negative pressure at my house on a windy day when the window in my room is open can cause the bedroom door to close so fast it practically slams.
This happens to me almost every night. Usually while coming out of sleep, but sometimes while I'm still trying to fall asleep. It used to only happen when I was stressed about work, but once I had a kid it became very frequent.
I hear/see the door open, hear my son's door open, see giant spiders on the wall, hear someone rummaging through the fridge, hear my son screaming, etc. If I get up to check it's always nothing.
It's usually not scary, it just jolts me up and out of bed, which interrupts my already limited sleep. It's definitely not great. I'm hoping it'll calm down as my son gets older, but I won't hold my breath.
Yep, hypnogogic/hypnopompic hallucinations are extremely common and generally nothing to worry about. If they happen to you a lot, it might be a sign of a sleep disorder, but they aren't connected to mental health issues.