As stated in the FAQ:
AP, or Action Points, are used to enter Battlefields. Different Battlefields require varying amounts of AP to enter. AP can be recovered by Sun Fragments or by tapping on the + button next to your AP and spending 5 stars. Earn Sun Fragments by sending and receiving gifts to your friends.
Increasing AP LimitEdit
The maximum amount of AP you can have increases as your Hero levels up. The more Heroes you have, the higher your max AP can go, up to an absolute maximum of 300 AP.
A certain amount of AP is used depending on which stage you enter, with the exception of Secret Stages which consume Honor Medals instead.
AP can be restored using Sun Fragments, or simply by waiting. The timer under your AP indicates how much time is left before you recover 1 AP.
Additionally, AP can be recovered using Star Crystals.
Here's a guide to continually gain AP to help you grind/farm levels. Refreshing AP Guide