You will file a Habeas Corpus petition in California if you are arguing that your conviction violated a state law, or that a California law is unconstitutional. A petition for writ of habeas corpus is a legal action that allows individuals to challenge their unlawful imprisonment or restraint.A writ of habeas corpus is a legal proceeding designed to bring a party before a court to test whether they are being held lawfully. The writ of Habeas Corpus is the legal system's last line of defense against unlawful incarceration. The inmate may file a petition for writ of habeas corpus. This means you cannot use a habeas corpus petition to make the same argument that you previously raised in a direct appeal. Habeas petitions provide prisoners whose rights are being violated with a means of requesting assistance from a judge. 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. The Writ of Habeas Corpus protects prison inmates from false imprisonment to ensure people are not thrown into jail unlawfully. The habeas petition is for situations when a legal error occurred, as we say, outside the "four corners" of the court file.