What degree of authority do commanders usually have to give up or negotiate?

EG if in the US Civil War or in France in 1870, a fortress got surrounded and it was clear nobody could help them and their supply situation was hopeless, do they actually have the legal authority from their own side to negotiate for giving up, ideally still with a safe conduct pass, or are they just hoping they won't be court-martialled or would be found innocent if they were?