Once you reach level 20, your energy is capped at 34. The only way to exceed this amount is by earning it from a gift box or purchasing it in the store. Purchases always add to your energy total regardless of the maximum allowed surpassing your cap.
However, you can get an extra 3 more to your cap if you reach thresholds 200, 1200 and 8000 in the Celebrity Perks window. Also, collecting a comeback reward will give you another 3 as a reward; therefore, gaining up to 9 in total when all 3 comebacks have been complete.