According to Francisco Bulnes, the best period for a successful war against USA was before the first government of Santa Anna, in the Bustamante-Alaman administration 1830-1832. He argue that if Mexico government (Alaman administration) have enforced the abolition of slavery in Texas and promoted the immigration of people from the north (mostly catholic irish but perhaps also Anglican settlers that could be easily converted to catholicism) , the only way that have been left to the pro-slavery government of the USA to acquire Texas was War (buying was out of the question). Bulnes doesn't say that Mexico could have won (but maybe they could, because in those years they have probably one of the best generals of the americas: Mier y Terán) but that they could enforce a better deal and some other butterfly effects:
1. Jackson doesn't reelect.
2. The south doesn't have more states to promote slavery and the balance of power could be broken in the next election.
3. The south would seceded earlier.
4. The south would have survived.
All this before 1840.
What do you think?