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. A petition for writ of habeas corpus is a legal action that allows individuals to challenge their unlawful imprisonment or restraint.The writ of Habeas Corpus is the legal system's last line of defense against unlawful incarceration. A habeas corpus petition in California allows you to challenge your conviction or sentencing. You can file it only after exhausting all criminal appeals. A writ of habeas corpus is used to bring a prisoner or other detainee (e.g. The Writ of Habeas Corpus protects prison inmates from false imprisonment to ensure people are not thrown into jail unlawfully. Habeas corpus is a legal instrument that allows you to contest your incarceration, conviction, or sentencing conditions. The most common claims in a federal Writ are 5th, 6th, and 14th Amendment right violations. Brought before a judge or court (PC 1473).