For information on application for residency for a non EU Citizen Spouse, please read the information on the website the EU commission.
IMPORTANT If you spouse has a visa of any kind, please apply for an appointment whilst the visa is valid (in date). By doing this, your spouse will have no problems staying in the country until the application is made and finalised. First check with the policia nacional for the right to the spouse to make an application for residency there first.