Any person committed or detained, imprisoned or restrained of his liberty, under any color or pretense whatever, civil or criminal, except as provided herein, may apply to the Supreme or circuit court, or any justice or judge thereof, for a writ of habeas corpus.
SDCL 21-27-1