The writ may be had for the purpose of admitting a prisoner to bail in civil and criminal actions. On all forms, ill out the caption (the top portion of each form naming the county, parties involved, and case number).It demands a person's release from unlawful detention. A writ of habeas corpus requires that a person who is in custody be brought before a judge or court and that they be able to challenge that custody. In United States law, habeas corpus is a recourse challenging the reasons or conditions of a person's confinement under color of law. Prisoners can sometimes use a petition for writ of habeas corpus to challenge the legality of a criminal conviction or inhumane prison conditions. The purpose of this order is to ensure that the detainee is not being held unlawfully or without sufficient cause. A writ of habeas corpus is a petition filed with the court when a prisoner wishes to contest the legality of his imprisonment. The writ's purpose is to challenge the legality of detention and seek relief from unlawful imprisonment. Any prisoner, or another person acting on their behalf, may petition the court, or a judge, for a writ of habeas corpus.