When I worked in a graphic biz. we used a print firm based in Glasgow and they had 2 different approaches to applying foils to a material. They produced the metal die's which were placed into a pneumatic stamping machine which used pressure and heat to bond the the foil onto the material. This type of production was nearly always used for the larger quantities of printed materials. Things like biz. cards for say around the 2000 or less the used a foil fuser machine which used a toner/glue to bond the foil onto the material. When using this type of machine we always had to state on the PDF which we sent that a certain colour was to be foil. I normally used pink for this but it had to be a flooded area of colour not just a closed line. I did a batch about a year ago using the hot foil machine and the company had reduced the price of the die down, really hugely, as they were using 3D printer to make the die's which laid down aluminium oxide to make the die. I did hear at the same time that the foil could have a gradient applied to the foil before it was stamped but that was too expensive for me so I don't know how they apply it.

I would always talk to the print house when I was getting these things done, as everyone knows things change so quickly these days, and they will tell you what process they use and how they want the PDF to look