It tests the legality of a detention or a restraint and the goal is to use it really almost i guess it's an emergency basis. A writ of habeas corpus requires that a person who is in custody be brought before a judge or court and that they be able to challenge that custody.The writ of habeas corpus primarily acts as a writ of inquiry, issued to test the reasons or grounds for restraint and detention. To get a writ of habeas corpus, you must file a petition for a civil (not criminal) proceeding in either state or federal court. The purpose of this order is to ensure that the detainee is not being held unlawfully or without sufficient cause. As an incarcerated person. The Habeas Corpus petition claims the arrest, sentence, or trial violated constitutional law, making imprisonment unlawful. Habeas corpus proceedings test the legality and propriety of a detention in an extradition case. The purpose of the remedy sought in a writ of habeas corpus is to determine the legality of the restraint under which a person has been held.