If the immigration officers decide to detain someone, they first determine if the person is eligible for an immigration bond, and if so, they will decide how much the bond will be. An immigration bond can range anywhere from $1500 to $25000 or more. If an immigration officer determines that you are not eligible for a bond, then you will be held in immigration detention until your immigration case is over, or an immigration judge gives you a bond.
Sometimes immigration officers will decide you are not eligible for a bond because you are subject to mandatory detention under Section 236(c) of the Immigration and Nationality Act (INA). If you are subject to mandatory detention during your immigration hearings, even the immigration judge has no authority under the law to release you from custody. If immigration officers determine that you are an arriving alien, that is, immigration officers stopped you at a land/sea/air port or border and detained you there or during deferred inspection, then you are not eligible for a bond and an even an immigration judge cannot give you one. If you already have a final order of removal/deportation (an order that is not on appeal with the Board of Immigration Appeals) then you are also not eligible for a bond and an immigration judge cannot give you one. There are a few other categories of people who are not eligible for bond, but those three categories cover the vast majority of people who are not eligible for an immigration bond.
How will you know if you are subject to mandatory detention under INA § 236(c)? You must look at your Form I-862, Notice to Appear (NTA) to determine if you are subject to mandatory detention under this section. If you are being detained and placed in removal/deportation proceedings, you should be served with an NTA within a few days of being detained. If you are charged with any criminal ground of removability under INA § 212(a)(2) (which include controlled substance offenses, crimes involving moral turpitude (CIMT), and controlled substance trafficking offenses) then you are not eligible for a bond. If you are charged under one of the criminal grounds of removability under INA § 237(a)(2), then you may also be subject to mandatory detention. These grounds of removability include any aggravated felony, any firearms offense, any controlled substance offense and any offenses involving two CIMTs. There are only two grounds of criminal removability under INA § 237(a)(2) that do not make you subject to mandatory detention. One of those sections is INA § 237(a)(2)(E), which involves crimes of domestic violence, child abuse, stalking, child neglect and violations of protective orders. The second is a conviction for one CIMT within five years of admission for which you were not sentenced to more than a year in prison.