The Writ of Habeas Corpus demands that requires a prisoner must go before the court to determine if there is lawful authority to detain the prisoner. A Writ of Habeas Corpus is a motion which is filed most frequently to ensure that a Defendant's imprisonment or detention is not illegal.This FindLaw article explains the origins of the writ of habeas corpus, how to file, and limitations on filing. Who May Use This Form. Criminal habeas corpus writs are procedures used to test the legality and correctness of a prisoner's detention. The writ of habeas corpus primarily acts as a writ of inquiry, issued to test the reasons or grounds for restraint and detention. A writ of habeas corpus is a legal rule that gives a prisoner the right to request court assistance and show that they've been wrongfully imprisoned. 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. Please note that the term, "federal habeas corpus," refers to habeas corpus in a federal court. Generally, anyone detained or imprisoned can file a petition for a writ of habeas corpus in the United States.