NY CPLR § 7002 (2021)
2021 New York Laws CVP - Civil Practice Law and Rules Article 70 - Habeas Corpus 7002 - Petition.

§  7002.  Petition. (a) By whom made. A person illegally imprisoned or otherwise restrained in his liberty within the state, or one  acting  on his behalf or a party in a child abuse proceeding subsequent to an order of  the  family  court, may petition without notice for a writ of habeas corpus to inquire into the cause of such detention and for  deliverance. A judge authorized to issue writs of habeas corpus having evidence, in a judicial proceeding before him, that any person is so detained shall, on his own initiative, issue a writ of habeas corpus for the relief of that person.  (b)  To  whom  made.  Except  as  provided  in  paragraph five of this subdivision, a petition for the writ shall be made to:   1. the supreme court in the judicial district in which the  person  is detained; or   2.  the  appellate  division  in the department in which the person is detained; or   3. any justice of the supreme court; or   4. a county judge being or residing within the  county  in  which  the person is detained; where there is no judge within the county capable of issuing  the  writ, or if all within the county capable of doing so have refused, the petition may be made to a county judge  being  or  residing within an adjoining county.   5. in a city having a population of one million or more inhabitants, a person  held  as  a  trial  incarcerated  individual in a city detention institution shall petition for a writ to the supreme court in the county in which the charge for  which  the  incarcerated  individual  is  being detained  is pending. Such incarcerated individual may also petition for a writ to the appellate division  in  the  department  in  which  he  is detained  or  to any justice of the supreme court provided that the writ shall be made returnable before a justice of the supreme court  held  in the  county in which the charge for which the incarcerated individual is being detained is pending.  (c) Content. The petition shall be verified and shall state, or  shall be accompanied by an affidavit which shall state,   1.  that  the person in whose behalf the petition is made is detained, naming the person by whom he is detained and the place of  detention  if they  are  known,  or  describing  them if they are not known; where the detention is by virtue of a mandate, a copy of it shall  be  annexed  to the  petition,  or  sufficient  reason  why a copy could not be obtained shall be stated;   2. the cause or pretense of  the  detention,  according  to  the  best knowledge and belief of the petitioner;   3.  that a court or judge of the United States does not have exclusive jurisdiction to order him released;   4. if the writ is sought because of an illegal detention,  the  nature of the illegality;   5. whether any appeal has been taken from any order by virtue of which the person is detained, and, if so, the result;   6.  the  date,  and the court or judge to whom made, of every previous application for the writ, the disposition of each such  application  and of  any  appeal  taken,  and  the  new  facts,  if any, presented in the petition that were not presented in any previous application; and   7. if the petition is made to a county judge  outside  the  county  in which  the  person  is detained, the facts which authorize such judge to act.