A detained person can seek habeas corpus, but because physical detention itself can prevent direct access to court, a relative or another person with a genuine connection to the detainee can also seek relief in appropriate circumstances.
The petition should identify the detainee, detaining authority and why the detention is alleged to be unlawful.