Petition for Writ of Habeas Corpus. If you want to challenge your immigration detention or other immigration related issues, you should use the form Petition for a Writ of Habeas Corpus under 28.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. Any defendant who has been convicted of a New York state crime in a proceeding should be aware of their right to file a petition for a Writ of Habeas Corpus. A seasoned New York habeas corpus lawyer can guide and represent you in the filing and litigation of a motion for a writ of habeas corpus. If you are incarcerated in a federal prison, you cannot file for state habeas corpus. You must file a petition for federal habeas corpus. This online program from Family Legal Care guides you through filling out a Petition for a Writ of Habeas Corpus. A habeas petition proceeds as a civil action against the State agent (usually a warden) who holds the defendant in custody. (citing CPLR 7002(a)). 46.