Please complete the fields below to schedule a free consultation with a skilled attorney. Answer this writ, stating the authority under which you restrain the prisoner.Exercise custody over the minor child. The court explained that a party filing a federal habeas corpus petition must exhaust their state court remedies prior to filing the petition. The purpose of a writ of habeas corpus is to show that the court decision to imprison a person was based on a legal or factual error. 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 filed in federal court claiming that a state prisoner is being held in violation of federal law. Federal Habeas Corpus Laws. To file a habeas corpus petition, you must prepare a written request to a court or judge, known as a writ of habeas corpus. Though subject to different rules, incarcerated people in both state or federal custody may petition for a federal writ of habeas corpus.