Spain did not "sell" Florida in a simple transaction. The transfer was formalized by the Adams-Onís Treaty of 1819 (ratified 1821), also known as the Transcontinental Treaty.
Key terms:
Motivations: Spain, weakened by the Peninsular War and Latin American revolts, could not defend Florida against American expansion and Seminole raids. The U.S. sought to eliminate a haven for runaway slaves and hostile tribes and to secure its southern border.