It depends on the type of lens you’re wearing, the composition of your tear film, your general eye health, and other factors.
RGP contact lenses and certain soft lenses can be slept in, but never wear them while sleeping unless your eye care practitioner says you can.