WHEN EXACTLY AN ALIEN DETAINEE RIE A PETION AND HOW
The most likely answer is that an immigrant detainee files a habeas corpus petition in federal court when they want to challenge unlawful detention. In the immigration context, that usually means asking a judge to review whether the government has legal authority to keep them detained.
When it can happen
A detainee may file after they believe detention is unlawful, especially if other release options have been exhausted. One common example is prolonged immigration detention, where people may challenge detention after months without a bond hearing or after a final removal order.
How it is done
The basic process is to file a petition for writ of habeas corpus in federal court. That filing asks the court to order the government to justify the detention, and if the court finds no lawful basis, it can order release or another remedy.
If you mean Alien Enemies Act cases
For detained migrants under the Alien Enemies Act, a recent filing described a process where the person is given at least 12 hours to say they intend to file a habeas petition, and then at least 24 hours to actually file it after expressing that intent.
Quick note
If the question is about a specific detainee, case, or detention system, the exact timing and filing steps can change depending on the legal basis for detention.