Knowing that habeas corpus exists is important; knowing how to invoke it when needed is essential. It is not a mechanism that sets itself in motion or that the police will facilitate: it is a right that must be exercised actively, correctly and with the greatest speed, because in an unlawful detention every hour counts.
The first step, before filing anything, is to verify that one of the legal grounds that justify it is present. Organic Law 6/1984 lists them exhaustively: detention without the legal prerequisites, failure to comply with essential formal requirements, exceeding the maximum time limits, detention at an unknown location or in unlawful conditions, and deprivation of liberty by an unauthorised person. An application not based on any of these grounds will not succeed. It is advisable to make a quick assessment: have the 72 hours been exceeded?, were the rights not communicated?, was a lawyer not allowed?, is the detainee at an unknown location? If any applies, habeas corpus is justified. This initial assessment is best made with a criminal lawyer.
The application may be filed by the detainee themselves, their spouse or partner, their ascendants, descendants and siblings, their legal representative, the Public Prosecutor and the Ombudsman. This breadth prevents the procedure from being blocked if the detainee cannot act on their own behalf.
The application must be addressed, as a general rule, to the investigating court of the place where the detainee is held or, outside ordinary hours, to the duty court. If the location is unknown, the court of the place of detention or of the applicant's domicile may be used. An important exception: if the deprivation of liberty was ordered by a judge, for example by an order of pre-trial detention, the route is not habeas corpus but an appeal before the Provincial Court.
The written application does not require rigid formal requirements, but it must contain the identification of the applicant and their relationship with the detainee; the identification of the detainee; the place of detention or known whereabouts; the circumstances of the detention and the grounds of unlawfulness, set out clearly and specifically; and an express request that the procedure be initiated and release be ordered. It may be filed in writing or, in cases of maximum urgency, orally before the court clerk of the duty court, which operates 24 hours a day, every day of the year.
Once the application is received, the judge examines whether the facts could constitute an unlawful detention; if such a possibility is found, the procedure is initiated and the presentation of the detainee is required. After a summary hearing in which the judge hears the detainee, their lawyer and the authority that carried out the detention, a decision is issued. If it is upheld, immediate release is ordered and the nullity of the actions carried out during the unlawful detention may be declared. If it is dismissed, the order may be appealed and, ultimately, an appeal for protection (amparo) may be brought before the Constitutional Court.
Although the law does not require a lawyer, having a criminal lawyer makes a real difference: they know how to identify the ground, know the competent court, draft the application effectively and can act swiftly even in the early hours or on a holiday. The procedure is also exempt from court fees, so the applicant's financial situation is never an obstacle.