In a writ of habeas corpus, a defendant seeks to establish that his or her prison sentence is illegal. This can be done in two ways.An application for a writ of habeas corpus asks a court to overturn your conviction because of a state or federal constitutional violation. The state writ of habeas corpus is a legal mechanism that allows individuals to challenge their detention or imprisonment. Win a Texas Writ of Habeas Corpus — A Top Appeals Lawyer Explains. A successful writ of habeas corpus in Texas can overturn a conviction or reduce a sentence. Please carefully read through all the steps listed below before you begin. In Texas, a writ of habeas corpus is a court order in which the judge demands a law enforcement agency to produce a detainee for a court hearing. Essentially, a writ of habeas corpus is a legal means for any person who is restrained in his liberty to challenge an unlawful restraint. The required application for a person currently incarcerated in TDCJ to file for a writ of habeas corpus under Texas Code of Criminal Procedure, Article 11.07.