Regarding the Identification of Individuals by the State Security Forces and Police Corps in Spain
For this particular matter we have to go to the Organic Law 4/2015, of March 30, on security protection of the citizen, specifically to its article 16 on Identification of people:
"1. In the performance of their criminal investigation and prevention functions, as well as for the punishment of criminal and administrative offences, the agents of the State Security Forces and Police Corps may require the identification of persons in the following cases:
a) When there are indications that they may have participated in the commission of an offence.
b) When, in view of the concurrent circumstances, it is considered reasonably necessary to prove their identity to prevent the commission of a crime.
In these cases, the agents may carry out the necessary checks on public roads or in the place where the request was made, including the identification of people whose face is not totally or partially visible due to the use of any type of garment or object that cover, preventing or hindering identification, when necessary for the purposes indicated.
In the practice of identification, the principles of proportionality, equal treatment and non-discrimination based on birth, nationality, racial or ethnic origin, sex, religion or belief, age, disability, sexual orientation or identity, opinion or any other personal or social condition or circumstance will be strictly respected.
2. When identification is not possible by any means, including telematic or telephone means, or if the person refuses to identify himself, the agents, in order to prevent the commission of a crime or in order to sanction an infraction, may require those who could not be identified to be accompanied to the nearest police stations where the appropriate means are available to carry out this diligence, for the sole purpose of their identification and for the time strictly necessary, which in no case may exceed the six hours.
The person who is asked to identify himself or herself will be informed immediately and understandably of the reasons for said request, as well as, where appropriate, of the requirement to accompany the agents to the police station.
3. In the dependencies referred to in section 2, a record book will be kept in which only entries related to citizen security will be made. It will contain the identification procedures carried out, as well as the reasons, circumstances and duration of the same, and their data may only be communicated to the competent judicial authority and the Public Prosecutor's Office. The competent body of the Administration will send monthly to the Public Prosecutor's Office an extract of the identification procedures with an expression of the time used in each one. The entries in this book-registry will be canceled ex officio after three years.
4. Persons transferred to police stations for identification purposes must be issued upon their departure a flyer certifying the length of stay in them, the cause and the identity of the acting agents.
5. In cases of resistance or refusal to identify oneself or to collaborate in verifications or identification practices, the provisions of the Penal Code, the Criminal Procedure Law and, where appropriate, this Law shall apply."