Within the first 50 seconds after you sent your units outside of your Castle ( Raid / Siege / etc.) you may cancel this action and recall sent units for free. However, in order to recall the units after 50 seconds have already passed, you will need to use the "Instant Recall" item. You may use it in the Tracking tab of your Castle.
If you try to Recall the units without having the item, you will receive the following notification:
You will be charged 300 Sapphires in case you press "Yes". Once you do so, the "Instant Recall" item will be automatically purchased and applied to recall the troops you intended to recall.