If there is no jail or juvenile detention facility in the county, or if the jail or juvenile detention facility in the county is crowded, unsafe, or otherwise insufficient to conform to the requirements of this chapter, every judicial or executive officer of the county who has the power to order, sentence, or deliver any person to the county jail or juvenile detention facility may order, sentence, or deliver such person to the jail or juvenile detention facility of any near or adjoining state, Indian reservation, county, organized township, or municipality, pursuant to a written agreement to house such prisoner. The written agreement shall contain provisions addressing liability issues and facility standards and shall also contain appropriate provisions assuring that the agency housing the prisoner shall release the prisoner to the county from which the prisoner was committed within two days of receiving a request from the committing county. Any written agreement with a federally recognized Indian tribe shall receive approval from the Bureau of Indian Affairs prior to the delivery of any prisoner. The county from which the prisoner was committed shall pay to the agency housing the prisoner all expenses of keeping and maintaining the prisoner in the jail or juvenile detention facility, including the cost of building depreciation, administration, and a reasonable charge for obsolescence of the facility and all other tangible and intangible costs.
SDCL 24-11-3