You can make a Golden Key in the Pirate Capital from small gold fragments (you can find out more about them in the Journal in the bottom right-hand corner of the screen). These can be found by unlocking reward chests. By collecting enough fragments of the required level (minimum 3) and merging them, you can get a Golden Key. On expeditions, you can come across Golden Chests and Golden Gates, which can be unlocked with Golden Keys. You can also buy Golden Keys for rubies. Upon purchase, the Golden Key will be used immediately.