If you are paying into the system, either as employee or autonomo/self employed, or through an invoicing cooperative, and have a digital certificate installed on your computer, or have arranged for a Cl@ve Permanente through the INSS or the Tax Office, so you can access the electronic offices of government organisations, you can register your newborn child, up to 3 months old, as your dependant/beneficiario online, without having to present any further documentation. The child must have a DNI or NIE number though, so in case of a baby born from non-Spanish parents, they would have to apply for NIE number first (need passport to apply for NIE number). If the parent(s) are residents, so would the child have to be registered.
When you enter the electronic office of the Seguridad Social (scroll down for access with digital certificate) the first screen that comes up will inform you of the possibility to register ´beneficiarios´. Click ´añadir nuevo beneficiario´ and proceed.
If your child is older, or you would like to register another relative as your dependant, you would have to go to the INSS office in your area in person. In the grey banner on the right of the page, once logged in to the electronic office, you can access further info, forms etc. by clicking ´aqui´.