Context.Most disks observed at high angular resolution show signs of substructures like rings, gaps, arcs, and cavities in both the gas and the dust. To understand the physical mechanisms responsible for these structures, knowledge about the gas surface density is essential. This, in turn, requires information on the gas temperature. Aims. The aim of this work is to constrain the gas temperature as well as the gas surface densities inside and outside the mm-dust cavities of two transition disks: LkCa15 and HD 169142, with dust cavities of 68 AU and 25 AU, respectively. Methods. We use some of the few existing ALMA observations of the J = 6 − 5 transition of 13 CO together with archival J = 2 − 1 data of 12 CO, 13 CO and C 18 O. The ratio of the 13 CO J = 6 − 5 to the J = 2 − 1 transition is used to constrain the temperature and is compared with that found from peak brightness temperature of optically thick lines. The spectra are used to resolve the innermost disk regions to a spatial resolution better than the beam of the observations. Furthermore, we use the thermochemical code DALI to model the temperature and density structure of a typical transition disk as well as the emitting regions of the CO isotopologues. Results. The 13 CO J = 6−5 and J = 2−1 transitions peak inside the dust cavity in both disks, indicating that gas is present in the dust cavities. The kinematically derived radial profiles show that the gas is detected down to 10 and 5 − 10 AU, much further in than the dust cavities in the LkCa15 and HD 169142 disks, respectively. For LkCa15, the steep increase towards the star in the 13 CO J = 6 − 5 transition, in contrast to the J = 2 − 1 line, shows that the gas is too warm to be traced by the J = 2 − 1 line and that molecular excitation is important for analysing the line emission. Quantitatively, the 6 − 5/2 − 1 line ratio constrains the gas temperature in the emitting layers inside the dust cavity to be up to 65 K, warmer than in the outer disk at 20−30 K. For the HD 169142, the lines are optically thick, complicating a line ratio analysis. In this case, the peak brightness temperature constrains the gas in the dust cavity of HD 169142 to be 170 K, whereas that in the outer disk is only 100 K. The data indicate a vertical structure in which the 13 CO 6 − 5 line emits from a higher layer than the 2 − 1 line in both disks, consistent with exploratory thermo-chemical DALI models. Such models also show that a more luminous central star, a lower abundance of PAHs and the absence of a dusty inner disk increase the temperature of the emitting layers and hence the line ratio in the gas cavity. The gas column density in the LkCa15 dust cavity drops by a factor > 2 compared to the outer disk, with an additional drop of an order of magnitude inside the gas cavity at 10 AU. In the case of HD 169142, the gas column density drops by a factor of 200−500 inside the gas cavity. Conclusions. The gas temperatures inside the dust cavities steeply increase towards the star and reach temperatures up to 65 K (LkCa15) an...