If you want to work in Spain, whether self-employed or as an employee, you must get a social security number.
This number will identify you in your relations with the social security system, which is a public system of protection against situations of illness, disability, unemployment, old age, accidents at work, maternity or loss of the family's means of support.
Getting your social security number is a necessary step prior to requesting registration with the social security system, which is what really enables you to start working.
Registering with the social security system is compulsory to start working.
If you are going to be an employee, the company or employer must register you with the general social security system.
If you are going to be self-employed, you must request registration with the special social security system for self-employed workers (RETA). Moreover, if you are going to be self-employed, you must register in the Tax Office register of entrepreneurs, professionals and withholders.