Something is slapping against the roof between the headliner and back roof.
Sounds like a flapping cable, or something.
Assuming this is not part of the moonroof track or sunshade, because the noise is present in either open or closed positions. Nothing dangerous, just annoying.
So to...