Searches for the prebiotically relevant cyanamide (NH 2CN) towards solar-type protostars have not been reported in the literature. We present here the first detection of this species in the warm gas surrounding two solar-type protostars, using data from the Atacama Large Millimeter/Submillimeter Array Protostellar Interferometric Line Survey (PILS) of IRAS 16293-2422 B and observations from the IRAM Plateau de Bure Interferometer of NGC 1333 IRAS2A. We also detected the deuterated and 13C isotopologs of NH 2CN towards IRAS 16293-2422 B. This is the first detection of NHDCN in the interstellar medium. Based on a local thermodynamic equilibrium analysis, we find that the deuteration of cyanamide (~1.7%) is similar to that of formamide (NH 2CHO), which may suggest that these two molecules share NH 2 as a common precursor. The NH 2CN/NH 2CHO abundance ratio is about 0.2 for IRAS 16293-2422 B and 0.02 for IRAS2A, which is comparable to the range of values found for Sgr B2. We explored the possible formation of NH 2CN on grains through the NH 2 + CN reaction using the chemical model MAGICKAL. Grain-surface chemistry appears capable of reproducing the gas-phase abundance of NH 2CN with the correct choice of physical parameters.