A resident minister, or resident for short, is a government official required to take up permanent residence in another country. A representative of his government, he officially has diplomatic functions which are often seen as a form of indirect rule. A resident usually heads an administrative area called a residency. "Resident" may also refer to resident spy, the chief of an espionage operations base. This full style occurred commonly as a diplomatic rank for the head of a mission ranking just below envoy, usually reflecting the relatively low status of the states of origin and/or residency, or else difficult relations. On occasion, the resident minister's role could become extremely important, as when in 1806 the Bourbon king Ferdinand IV fled his Kingdom of Naples, and Lord William Bentinck, the British Resident, authored (1812) a new and relatively liberal constitution. Residents could also be posted to nations which had significant foreign influence. For instance, the British sent residents to the Mameluk Beys who ruled Baghdad province as an autonomous state (17041831) in the north of present-day Iraq, until the Ottoman sultans reasserted control over it (1831) and its Wali (governor). After the Congress of Vienna restored the Grand Duchy of Tuscany in 1815, the British posted a resident to Florence to handle their affairs there. As international relations developed, it became customary to give the highest title of diplomatic rank – ambassador – to the head of all permanent missions in any country, except as a temporary expression of down-graded relations or where representation was merely an interim arrangement. Some official representatives of European colonial powers, while in theory diplomats, in practice exercised a degree of indirect control. Some such residents were former military officers, rather than career diplomats, who resided in smaller self-governing protectorates and tributary states and acted as political advisors to the ruler. A trusted resident could even become the de facto prime minister to a native ruler.