Permits and Visas
If you are not a national or from an EU country (Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Poland, Portugal, Romania, Slovakia, Slovenia, Sweden, the Netherlands, the United Kingdom and the United Kingdom) or from Liechtenstein, Iceland, Norway and Switzerland, you must obtain a study residence permit (NIE) in order to take a course lasting six months or more.
To obtain this document it is necessary that BEFORE your arrival in Spain you process in the consulates of Spain of your country the "visa of stay for studies", with this visa for studies (Type D), once you arrive in Spain, you have 30 days to go to a police station to apply for the NIE. The NIE will allow you to stay legally and even travel in EU countries and all those that have signed the free movement treaty with Spain.
For more information on the details of applying for a student visa for Spain, please contact the Spanish embassy or consulate in your country of residence.
Link of interest