After a criminal conviction, a writ of habeas corpus may be used to claim that the laws were misapplied in your case. 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. It is only used to challenge errors that would make your detention unlawful. How Long Do You Have to File a Writ of Habeas Corpus? 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. Penalty offense, the procedure followed in the sentencing phase must receive the. This petition, called a writ of Habeas Corpus, is filed in Federal Court (US District Court ) whether you are serving time in a federal or state prison. It allows individuals to challenge their detention in a court of law and provides a check on the executive branch's power.