At any time before delivery of the property to the plaintiff, the defendant may, if he does not except to the sureties of the plaintiff, require the return thereof, upon giving to the sheriff a written undertaking, or receipt for cash deposit, as in this chapter provided, in amount and sufficiency as required on the undertaking of the plaintiff for the immediate delivery, and securing the plaintiff for delivery of the property if such delivery be adjudged and for the payment to the plaintiff of such sum as may for any cause be recovered against the defendant.
SDCL 21-15-12