which country was it a part of before getting annexed by the u.s?
Mexico
Republic of Texas
The Republic of Texas () was a sovereign state in North America that existed from March 2, 1836, to February 19, 1846, although Mexico considered it a rebellious province during its entire existence. It was bordered by Mexico to the west and southwest, the Gulf of Mexico to the southeast, the two U.S. states of Louisiana and Arkansas to the east and northeast, and United States territories encompassing parts of the current U.S. states of Oklahoma, Kansas, Colorado, Wyoming, and New Mexico to the north and west. The citizens of the republic were known as Texians.

when was texas admitted to the united states December 29, 1845.
wiki:25697891
Republic of Texas [SEP] Introduction
The major fighting in the Texas war of independence ended on April 21, 1836, but the Mexican Congress refused to recognize the independence of the Republic of Texas, since the agreement was signed by Mexican President General Antonio López de Santa Anna under duress as prisoner of the Texians. There were intermittent conflicts between Mexico and Texas into the 1840s. The United States recognized the Republic of Texas in March 1837 but declined to annex the territory. The Republic-claimed borders were based upon the Treaties of Velasco between the newly created Texas Republic and General Santa Anna, who had been captured in battle.