The procedure for filing a petition for a writ of habeas corpus is spelled out in the CPLR Article 70. Category Representing Yourself (Pro Se).First, a U.S.C. § 2254 allows us to file a petition for Habeas Corpus when the client is in custody under sentence of a state court and is in a state prison. To get a writ of habeas corpus, you must file a petition for a civil (not criminal) proceeding in either state or federal court. Habeas corpus is a kind of petition that you can file in federal court to claim that your imprisonment violates federal law. Federal habeas corpus is a procedure under which a federal court may review the legality of an individual's incarceration. A writ of habeas corpus is a judicial mandate to a prison official, usually the warden, ordering that an inmate be brought to the court. A petition for a writ of habeas corpus is a case filed in court, either state or federal court depending on jurisdiction. Any federal court may grant a writ of habeas corpus to a petitioner who is within its jurisdiction. You don't actually file the writ, you file a petition seeking issuance of the writ.