The procedure for filing a petition for a writ of habeas corpus is spelled out in the CPLR Article 70. It demands a person's release from unlawful 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. Petition for Writ of Habeas Corpus - 2254. Habeas Corpus, in the Federal Court, is a petition that claims that you are being detained against your US constitutional rights. Federal habeas corpus is a procedure under which a federal court may review the legality of an individual's incarceration. This Chapter explains an important right—the writ of habeas corpus. A Writ of Habeas Corpus is a civil proceeding that is available in both State and Federal Court to challenge the legality of imprisonment. Any prisoner, or another person acting on their behalf, may petition the court, or a judge, for a writ of habeas corpus. The privilege of the writ of habeas corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it.