A person prosecuting a writ of habeas corpus may, at any time after the writ is allowed, be admitted to bail by the court allowing the writ, or by another judge or magistrate designated by that court or judge, pending the hearing upon the writ and the final order of the court and, in case of appeal, during the pendency of the appeal and until the final order of the appellate court. The bail shall be by written undertaking and executed as bail upon arrest, and the undertaking shall be conditioned that the person so admitted to bail shall appear in the designated court or before the designated judge or magistrate whenever required, and shall at all times be amenable to the order or process of that court, judge, or magistrate, and that if the person fails to perform either of those conditions, the surety or sureties on the undertaking will pay to the state the sum in which that person is so admitted to bail.
AS 12.75.140