Habeas corpus is a method for a defendant to challenge the legality of confinement.
“Habeas corpus” literally means “you shall have the body,” and that is exactly what happens when this writ is requested. The judge orders the warden of a prison or jail to produce a defendant to the court with proof of authority. The judge will then determine whether the confinement is legal.