Spain's Urban Leases Act requires a cash deposit when the lease is signed (art. 36 LAU) and lets each region require that money to be lodged with the authorities until the lease ends (third additional provision). The Region of Madrid has done so for decades: the lodging scheme is in Decree 181/1996 of 5 December and inspections and penalties in Act 12/1997 of 4 June.
The body that holds the money is the Social Housing Agency (Agencia de Vivienda Social), with offices at Calle Basílica 23, by appointment. According to its website, lodging is compulsory for the landlord and free: there is no fee, but no interest is paid to you either.
Which leases it covers and who lodges
Landlords and sub-landlords of urban property must lodge, as must those leasing a business that includes the use of premises, and utility companies. It covers residential leases, other-use leases (shops, offices, seasonal lets) and sublets. The Agency itself clarifies that a parking space rented on its own, not linked to a home, does not need to be lodged.
The amount is one month's rent for a main home and two for other uses, excluding VAT and withholdings. Watch out with seasonal lets: in Madrid they count as other use, so the deposit to lodge is two months.
The deadline: 30 days, and better not to cut it fine
Decree 181/1996 sets a deadline of thirty days from the day after the lease is signed (or from its start date, according to the Agency's website). Another section of the same website speaks of «30 working days from signing». As the two readings differ, the prudent approach for a firm with many leases is to count calendar days and lodge within the first three weeks.