Placing a Pokemon into a friendly gym, or a gym you have just claimed from a rival to defend it will earn you a defender bonus that can be claimed once every 21 hours.
Your reward will be 10 PokeCoins and 500 Stardust for every Pokemon you have stationed at a gym. You can have up to 10 Pokemon at a gym at any one time.
To claim your reward you will need to go to the shop page. Tap the Pokeball icon > Shop > top right icon which will look like a shield with a number on it. This number indicates the number of Pokemon you have defending gyms. Just tap this shield to claim your loot.
Note that you do not need to hold the gym for 21 hours before you can claim your rewards.
The most reliable way to boost your chances of claiming more loot is to quickly place a Pokemon in a number of gyms that are close by and then instantly claim your rewards.
For example, if you quickly took over or placed 2 Pokemon in gyms that are close together you will be able to then press the shield to claim 20 coins and 1000 stardust (providing you haven’t clicked the shield to claim loot in the previous 21 hours).
A new timer will start at the time you claim your last reward. This means you can adjust when the timer starts to suit the time of day that you next expect to be able to play. Timing this correctly should give you time to control more gyms in advance of when the next timer hits zero. The more gyms you defend at the time, the more Pokecoins and Stardust you will receive!
If you find you are unable to place a Pokemon into the gym to defend it then you must train at the gym to increase its prestige to the next level. This will open up an additional slot for you to place your own Pokemon inside.