As an Autonomo in Spain, trading or providing services you invoice to company in another EU country, you need a NIF-IVA number to do so.
To get this number, consisting of ES followed by your NIE number, you need to register on the Registro de Operadores Intracomunitarios (ROI).
How?
Through modelo 036, page 5. You need to tick box 130 and box 582. Tick for ‘alta’. In box 584 you need to indicate the start date of your activities, which must be in the future as you’re supposed to register before you start invoicing. With a digital certificate or Cl@ve Pin, you can access this form on the online office of the Agencia Tributaria. If you don’t have either installed, you can make an appointment at the tax office that covers your area and arrange for the registration then and there.
Once a NIF-IVA number has been allocated, you should be registered on the census VIES (Sistema de Intercambio de Información sobre el IVA / VAT info exchange system) and companies you do business with can check you are indeed correctly registered, and vice versa of course.
Full info from the Spanish Government.
Note: if you’re an Autonomo living and registered on the Canary Islands, Ceuta or Melilla, then what’s stated under ‘Tipo’ might apply to you.
And about NIF-IVA from the Tax Office.