In the search for the mechanism of high-temperature superconductivity, intense research has been focused on the evolution of the spin excitation spectrum upon doping from the antiferromagnetic insulating to the superconducting states of the cuprates. Because of technical limitations, the experimental investigation of doped cuprates has been largely focused on low-energy excitations in a small range of momentum space. Here we use resonant inelastic x-ray scattering to show that a large family of superconductors, encompassing underdoped YBa$_2$Cu$_4$O$_8$ and overdoped YBa$_2$Cu$_3$O$_{7}$, exhibits damped spin excitations (paramagnons) with dispersions and spectral weights closely similar to those of magnons in undoped cuprates. %The results are in excellent agreement with the spin excitations obtained by exact diagonalization of the $bf t-J$ Hamiltonian on finite-sized clusters. The comprehensive experimental description of this surprisingly simple spectrum permits quantitative tests of magnetic Cooper pairing models. A numerical solution of the Eliashberg equations for the magnetic spectrum of YBa$_2$Cu$_3$O$_{7}$ reproduces its superconducting transition temperature within a factor of two, a level of agreement comparable to Eliashberg theories of conventional superconductors.