When you are brought to court, the court case usually does not finish on the same day. You have a right to ask the court to be released on bail until the case finishes. You can ask for bail at any time on or after the first day in court.
When you ask for bail you must convince the judge or magistrate that:
If you ask for bail you (or your attorney) must give the court details of where you live, your employment situation, and so on.
When you pay the bail you must get a receipt. Only the person with a receipt for the bail will get the money back after the trial.