If you have paid National Insurance contributions in the UK they are a matter of record, same for social security in Spain. You will need to quote your UK National Insurance number and Spanish social security numbers. Around four months before your pension age, The Pension Service will invite you to claim your pension. If you have paid contributions in Spain you say so at the time, and they will write to the foreign authority for you. You may end up receiving a separate pension from each country.