Electrodeposition from microemulsions using ionic liquids is revealed as a green method for synthesizing magnetic alloyed nanoparticles, avoiding the use of aggressive reducing agents. Microemulsions containing droplets of aqueous solution (electrolytic solution containing Pt(IV) and Co(II) ions) in an ionic liquid (bmimPF6) define nanoreactors in which the electrochemical reduction takes place. Highly crystalline hcp alloyed CoPt nanoparticles, in the 10-120 nm range with a rather narrow size distribution, have been deposited on a conductive substrate. The relative amount of aqueous solution to ionic liquid determines the size of the nanoreactors, which serve as nanotemplates for the growth of the nanoparticles and hence determine their size and distribution. Further, the stoichiometry (Pt(x)Co(1-x)) of the particles can be tuned by the composition of the electrolytic solution inside the droplets. The control of the size and composition of the particles allows tailoring the room-temperature magnetic behavior of the nanoparticles from superparaparamagnetic to hard magnetic (with a coercivity of HC = 4100 Oe) in the as-obtained state.