Bonapartist Spain was a Napoleonic client state established in 1808 after Napoleon, who had stationed his Imperial Army in Spain under the pretense of a joint Franco–Spanish invasion of Portugal, forced the ruling Spanish Bourbons to abdicate, and installed his brother, Joseph Bonaparte on the Spanish throne, which ignited a people's revolt by Spanish citizens and led to the Peninsular War, where France was defeated and forced to retreat from Spain.
The kingdom was officially known as Kingdom of (the) Spain(s) and (the) Indies, with "the Indies" referring to the East and West Indies as well as Spain's colonial possessions more broadly. It never managed to exert control over these territories however, not only did the French invasion weaken Spain's grasp on its overseas empire, kickstarting the Spanish American wars of independence, but even on the Spanish mainland, the House of Bonaparte's grip was tenuous. Large parts of the country came under the control of juntas, which remained loyal to Ferdinand VII and the old Bourbon kingdom, allying with the Coalition forces of Britain and Portugal to undermine the French occupation.