When the defendant is acquitted in a misdemeanor or infraction case, if the court certifies in the minutes that the prosecution was malicious and without probable cause, the court may order the complainant to pay the costs of the action, or to give an undertaking to pay the costs within 30 days after the trial.
Ca. Pen. Code § 1447