When you create a legendary monster, you follow the rules for creating a BBEG in addition to the rules for creating a monster. Legendary monsters have the Legendary Resistance perk by default, in addition to the ability to take Legendary Actions, as outlined below.
Legendary Actions
Legendary Actions are additional actions that legendary monsters can take as a bonus action or as a bonus reaction, any time during an encounter. A legendary monster can take a number of legendary actions equal to 1/3 their level, rounded down, until the end of the scene. This is in addition to its Actions Per Round (APR), so a 10th level legendary monster normally has 3 actions per round (1/3 its level, rounded down), and can take 3 legendary actions for the duration of the encounter.
Shake It Off
The monster ends a status effect or dispels a spell it is subject to (enemy spellcasters are not entitled to a spell check). The GM has discretion to include effects in the fiction not indicated here, so long as they impose debility on the monster's freedom to act.
Turn the Tide
The monster creates narrative advantage.
Make an Opening
The monster takes an additional movement and is not subject to attacks of opportunity.
Seize the Moment
The monster takes one of its actions as a reaction.
Press the Attack
The monster takes a bonus action on its turn.