This Chapter explains an important right—the writ of habeas corpus. The procedure for filing a petition for a writ of habeas corpus is spelled out in the CPLR Article 70.Habeas corpus is available to prisoners challenging their convictions and sentences. The writ of habeas corpus primarily acts as a writ of inquiry, issued to test the reasons or grounds for restraint and detention. In United States law, habeas corpus is a recourse challenging the reasons or conditions of a person's confinement under color of law. You may not petition the court for a writ of habeas corpus if there are still other ways to get the relief you seek. Habeas petitions provide prisoners whose rights are being violated with a means of requesting assistance from a judge. The privilege of the writ of habeas corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it. Any prisoner, or another person acting on their behalf, may petition the court, or a judge, for a writ of habeas corpus. The attorney general represents the state or territory in a federal habeas corpus proceeding.