This from the UK Government:
a negative COVID-19 test: either a PCR taken within 72 hours prior to departure, or an antigen test taken within 24 hours prior to departure. See ‘If you’re not fully vaccinated’.
This from the Spain Travel Health site I linked earlier:
SpTH QR. If you do not have the EU Digital COVID Certificate or equivalent, you must complete the SpTH Health Control Form, manually entering the details of your vaccination, recovery or diagnostic test certificate.
If the document proves a diagnostic test: date of sampling, identification and contact details of the centre performing the analysis, technique used and negative result.
Nucleic acid amplification tests (NAAT), which detect the genetic material of the virus (e.g. PCR, TMA, LAMP, NEAR etc.), carried out within 72 hours prior to departure for Spain.
Antigen detection tests, which detect the presence of virus antigens, carried out within 24 hours prior to departure for Spain. The accepted tests are those approved by the European Commission, which can be found in the following link.
So it is either a PCR or a Lateral Flow but it has to be an official test and the details entered on the Spain Travel Health form as Caterina99 explained. You will need to complete the Spain Travel Health Form as it gives you a QR Code.