Convention (IV) relative to the Protection of Civilian Persons in Time of War:
Article 29: -- "A person can only be considered a spy when, acting clandestinely or on false pretences, he obtains or endeavours to obtain information in the zone of operations of a belligerent with the intention of communicating it to the hostile party.
Thus, soldiers not wearing a disguise who have penetrated into the zone of operations of the hostile army, for the purpose of obtaining information, are not considered spies. Similarly, the following are not considered spies: soldiers and civilians carrying out their mission openly, entrusted with the delivery of despatches intended either for their own army or for the enemy's army. To this class belong likewise persons sent in balloons for the purpose of carrying despatches and, generally, of maintaining communications between the different parts of an army or a territory."
Article 30: -- "A spy taken in the act shall not be punished without previous trial."
Article 31: -- "A spy who, after rejoining the army to which he belongs, is subsequently captured by the enemy is treated as a prisoner of war, and incurs no responsibility for his previous acts of espionage."